Tools: Backup and Restore Gitea server - Full Analysis

Tools: Backup and Restore Gitea server - Full Analysis

How - Backup

How - Restore

Useful links Need to backup the 1) db, 2) filestorage, 3) some other gitea files. Here we go. In the Testing Gitea post we installed the gitea server. For the complete developer tools collection including Git workflows and Docker management, see Developer Tools: The Complete Guide to Modern Development Workflows. If you're setting up Gitea for the first time, check out Choosing free on-prem git server - Gitea is the winner! for installation details, and Gitea SSL with Apache as reverse proxy for secure deployment. Now just as a precaution of terrible things happenings, need to rehearse the backup and restore procedure. Better be safe then sorry. Gitea server data consists of 3 components In our test environment all togeather they take a bit more then 700MB: As they recommend, need to stop all services and back up them all, kind of in the same transaction. And restore, in the same transaction too. last bit - login to some other server and pull backup folder there, or do some other more elaborated files manipulation Actually, there is a bit more then that, esp with permissions and hooks, but idea is the same. But! check the original doco: https://docs.gitea.com/administration/backup-and-restore Then goto UI and check it For quick reference on Git commands, see GIT Cheatsheet: Most useful GIT commands. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ cd ~/gitea-srv-local # backup the db -weight: 600;">sudo -weight: 500;">docker exec -t gitea-srv-local_db_1 bash -c 'pg_dump gitea -U gitea --file=/var/lib/postgresql/backups/gitea-db-$(date +%Y-%m-%d).sql' # take gitea down -weight: 600;">sudo -weight: 500;">docker-compose down # check the backups folder -weight: 600;">sudo ls postgres-backups # create backup dir mkdir gitea-backups # backup gitea folder -weight: 600;">sudo tar -zcvf gitea-backups/gitea-gitea-$(date +%Y-%m-%d).tgz gitea/gitea # backup repos folder -weight: 600;">sudo tar -zcvf gitea-backups/gitea--weight: 500;">git-$(date +%Y-%m-%d).tgz gitea/-weight: 500;">git # bring it up -weight: 600;">sudo -weight: 500;">docker-compose up -d cd ~/gitea-srv-local # backup the db -weight: 600;">sudo -weight: 500;">docker exec -t gitea-srv-local_db_1 bash -c 'pg_dump gitea -U gitea --file=/var/lib/postgresql/backups/gitea-db-$(date +%Y-%m-%d).sql' # take gitea down -weight: 600;">sudo -weight: 500;">docker-compose down # check the backups folder -weight: 600;">sudo ls postgres-backups # create backup dir mkdir gitea-backups # backup gitea folder -weight: 600;">sudo tar -zcvf gitea-backups/gitea-gitea-$(date +%Y-%m-%d).tgz gitea/gitea # backup repos folder -weight: 600;">sudo tar -zcvf gitea-backups/gitea--weight: 500;">git-$(date +%Y-%m-%d).tgz gitea/-weight: 500;">git # bring it up -weight: 600;">sudo -weight: 500;">docker-compose up -d cd ~/gitea-srv-local # backup the db -weight: 600;">sudo -weight: 500;">docker exec -t gitea-srv-local_db_1 bash -c 'pg_dump gitea -U gitea --file=/var/lib/postgresql/backups/gitea-db-$(date +%Y-%m-%d).sql' # take gitea down -weight: 600;">sudo -weight: 500;">docker-compose down # check the backups folder -weight: 600;">sudo ls postgres-backups # create backup dir mkdir gitea-backups # backup gitea folder -weight: 600;">sudo tar -zcvf gitea-backups/gitea-gitea-$(date +%Y-%m-%d).tgz gitea/gitea # backup repos folder -weight: 600;">sudo tar -zcvf gitea-backups/gitea--weight: 500;">git-$(date +%Y-%m-%d).tgz gitea/-weight: 500;">git # bring it up -weight: 600;">sudo -weight: 500;">docker-compose up -d scp -r uname@gitea-srv-ip-addr:/home/uname/gitea-srv-local/gitea-backups ~/gitea-backups scp -r uname@gitea-srv-ip-addr:/home/uname/gitea-srv-local/postgres-backups ~/postgres-backups scp -r uname@gitea-srv-ip-addr:/home/uname/gitea-srv-local/gitea-backups ~/gitea-backups scp -r uname@gitea-srv-ip-addr:/home/uname/gitea-srv-local/postgres-backups ~/postgres-backups scp -r uname@gitea-srv-ip-addr:/home/uname/gitea-srv-local/gitea-backups ~/gitea-backups scp -r uname@gitea-srv-ip-addr:/home/uname/gitea-srv-local/postgres-backups ~/postgres-backups # -weight: 500;">install it first # then take it down -weight: 600;">sudo -weight: 500;">docker-compose down # restore files tar -zxvf gitea--weight: 500;">git-___.tgz gitea/-weight: 500;">git tar -zxvf gitea-gitea-___.tgz gitea/gitea # bring it up -weight: 600;">sudo -weight: 500;">docker-compose up -d # here some activity with psql or pg_restore -weight: 600;">sudo -weight: 500;">docker exec -t gitea-srv-local_db_1 bash -c 'psql gitea -U gitea --file=/var/lib/postgresql/backups/gitea-db-$(date +%Y-%m-%d).sql' # -weight: 500;">install it first # then take it down -weight: 600;">sudo -weight: 500;">docker-compose down # restore files tar -zxvf gitea--weight: 500;">git-___.tgz gitea/-weight: 500;">git tar -zxvf gitea-gitea-___.tgz gitea/gitea # bring it up -weight: 600;">sudo -weight: 500;">docker-compose up -d # here some activity with psql or pg_restore -weight: 600;">sudo -weight: 500;">docker exec -t gitea-srv-local_db_1 bash -c 'psql gitea -U gitea --file=/var/lib/postgresql/backups/gitea-db-$(date +%Y-%m-%d).sql' # -weight: 500;">install it first # then take it down -weight: 600;">sudo -weight: 500;">docker-compose down # restore files tar -zxvf gitea--weight: 500;">git-___.tgz gitea/-weight: 500;">git tar -zxvf gitea-gitea-___.tgz gitea/gitea # bring it up -weight: 600;">sudo -weight: 500;">docker-compose up -d # here some activity with psql or pg_restore -weight: 600;">sudo -weight: 500;">docker exec -t gitea-srv-local_db_1 bash -c 'psql gitea -U gitea --file=/var/lib/postgresql/backups/gitea-db-$(date +%Y-%m-%d).sql' - https://docs.gitea.com/administration/backup-and-restore - Docker Cheatsheet - Gitflow Explained: Steps, Alternatives, Pros, and Cons