GitLab部署方式:Docker
GitLab版本: gitlab/gitlab-ce:12.9.2-ce.0
1、備份命令
1 gitlab-backup create
同時需要手動備份 /etc/gitlab/gitlab-secrets.json,/etc/gitlab/gitlab.rb
2、恢復數據
創建的數據包位於原gitlab服務器目錄 /var/opt/gitlab/backups下,如
1586312717_2020_04_08_12.9.2_gitlab_backup.tar
需要先拷貝數據包到要恢復的新Gitlab服務器的/var/opt/gitlab/backups,並建議修改文件權限777
執行命令
1 gitlab-ctl stop unicorn 2 gitlab-ctl stop puma 3 gitlab-ctl stop sidekiq 4 # verify 5 gitlab-ctl status 6 7 8 # 恢復 9 gitlab-backup restore BACKUP=1586312717_2020_04_08_12.9.2
之后再次手動恢復 /etc/gitlab/gitlab-secrets.json,/etc/gitlab/gitlab.rb
再次執行命令
1 gitlab-ctl reconfigure 2 gitlab-ctl restart 3 gitlab-rake gitlab:check SANITIZE=true
3、小技巧
gitlab內置自動清理過期的備份文件,需要修改gitlab.rb中的
1 gitlab_rails['backup_keep_time'] = 604800
定時產生備份文件。每天早晨2點產生一個備份文件
1 0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1