Created
August 18, 2020 07:15
-
-
Save bst27/1bf1590c5ec0b8b1c331d2a03e237894 to your computer and use it in GitHub Desktop.
A Gitea backup script for Docker: It creates a .zip backup of Gitea running inside Docker and moves the backup file to the current working directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script creates a .zip backup of gitea running inside docker and copies the backup file to the current working directory | |
echo "Creating gitea backup inside docker containter ..." | |
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_server_1") bash -c '/app/gitea/gitea dump -c /data/gitea/conf/app.ini --file /tmp/gitea-dump.zip' | |
echo "Copying backup file from the container to the host machine ..." | |
docker cp $(docker ps -qf "name=gitea_server_1"):/tmp/gitea-dump.zip /tmp | |
echo "Removing backup file in container ..." | |
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_server_1") bash -c 'rm /tmp/gitea-dump.zip' | |
echo "Renaming backup file ..." | |
BACKUPFILE=gitea-dump-$(date +"%Y%m%d%H%M").zip | |
mv /tmp/gitea-dump.zip $BACKUPFILE | |
echo "Backup file is available: "$BACKUPFILE | |
echo "Done." |
I managed to restore. My procedure is here:
https://discourse.gitea.io/t/error-500-on-repositories-after-backup-and-restore/6154
For reference, restore info is here https://docs.gitea.io/en-us/backup-and-restore/#using-docker-restore
Since we are using docker, how about backup the top gitea folder of host wich contains docker-compose.yml using tar -cvfp
and restore using tar -pzxvf
?
With -p parameter we can keep permission of files.
host file tree is:
$ sudo tree -L 4
.
└── gitea
├── docker-compose.yml
└── gitea
├── git
│ ├── lfs
│ └── repositories
├── gitea
│ ├── attachments
│ ├── avatars
│ ├── conf
│ ├── gitea.db
│ ├── home
│ ├── indexers
│ ├── jwt
│ ├── log
│ ├── packages
│ ├── queues
│ ├── repo-archive
│ ├── repo-avatars
│ ├── sessions
│ └── tmp
└── ssh
├── ssh_host_dsa_key
├── ssh_host_dsa_key.pub
├── ssh_host_ecdsa_key
├── ssh_host_ecdsa_key.pub
├── ssh_host_ed25519_key
├── ssh_host_ed25519_key.pub
├── ssh_host_rsa_key
└── ssh_host_rsa_key.pub
nice one, this was very usefull, thanks for posting
Thanks for this tool.
I use docker compose
and I add by default the volume: ***:/data_backup:rw
that permit to simply store data with:
docker compose exec -u git -w /tmp gitea_service /app/gitea/gitea dump -c /data/gitea/conf/app.ini --file /data_backup/gitea-dump-$(date +"%Y-%m-%d_%Hh%Mm%Ss").zip
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do you restore the data? Do you have a script to restore ?