0.This blog information
Creation time: 2023-04-01Latest
modification time: 2023-04-01Official
reference document: https://gitea.io/en-us/
1.docker-compose file
Official document reference.
Note that I have mounted the tmp directory here for backup.
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.19.0
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST=db:3306
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
- TZ=Asia/Shanghai
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- ./gitea/tmp:/tmp
ports:
- "3000:3000"
- "3422:22"
depends_on:
- db
db:
image: mysql:8
restart: always
environment:
- MYSQL_ROOT_PASSWORD=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
- TZ=Asia/Shanghai
networks:
- gitea
volumes:
- ./mysql:/var/lib/mysql
2. Post-run status
My directory is as follows
3. Input some test data
Just create some accounts and then add some organizations and data
4. Make a backup
Refer to the official document https://docs.gitea.io/en-us/backup-and-restore/
to back up the zip to the tmp directory
backup command
docker exec -u git -it -w /tmp 094341c71e68 bash -c '/usr/local/bin/gitea dump'
5. Perform data restoration
5.1 only requires docker-compose.yml and gitea-dump-1680355388.zip
5.2 docker compose up -d Start the container
Enter the gitea container and execute the following command
# open bash session in container
docker exec --user git -it 2a83b293548e bash
# unzip your backup file within the container
unzip gitea-dump-1610949662.zip
cd gitea-dump-1610949662
# restore the gitea data
mv data/* /data/gitea
# restore the repositories itself
mv repos/* /data/git/repositories/
# adjust file permissions
chown -R git:git /data
# Regenerate Git Hooks
/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks
5.3 Enter the mysql container
mysql --default-character-set=utf8mb4 -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE <gitea-db.sql
5.4 Enter the gitea interface
and check the three options below. At
this time, the data will be restored to its previous state.