gitlab 備份&恢復
Gitlab 成功執行起來之後,最終的事情就是定期的備份,遇到問題後的還原。
備份配置
預設 Gitlab 的備份檔案會建立在/var/opt/gitlab/backups
資料夾中,格式為時間戳_日期_版本號_gitlab_backup.tar
,例如:1515031353_2018_01_04_10.3.2_gitlab_backup.tar
。
修改備份資料夾,需要修改配置檔案/etc/gitlab/gitlab.rb
中的:
gitlab_rails['backup_path'] = '/your_wish/backups'
然後gitlabctl-reconfigure
生效。
手動備份
命令:gitlab-backup create
For GitLab 12.1 and earlier, use
gitlab-rake gitlab:backup:create
會在命令執行的時間點,在你配置的資料夾或者預設資料夾建立一個備份檔案。
自動備份
0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1
備份恢復
First make sure your backup tar file is in the backup directory described in the gitlab.rb
configuration gitlab_rails['backup_path']
. The default is /var/opt/gitlab/backups
git
user.
cp 11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar /var/opt/gitlab/backups/
chown git.git /var/opt/gitlab/backups/11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar
Stop the processes that are connected to the database. Leave the rest of GitLab running:
gitlab-ctl stop unicorn gitlab-ctl stop sidekiq # Verify gitlab-ctl status
Next, restore the backup, specifying the timestamp of the backup you wish to restore:
# This command will overwrite the contents of your GitLab database!
gitlab-backup restore BACKUP=1493107454_2018_04_25_10.6.4-ce
For GitLab 12.1 and earlier, use
gitlab-rake gitlab:backup:restore
Next, restore /etc/gitlab/gitlab-secrets.json
if necessary as mentioned above.
Reconfigure, restart and check GitLab:
gitlab-ctl reconfigure
gitlab-ctl restart
gitlab-rake gitlab:check SANITIZE=true
If there is a GitLab version mismatch between your backup tar file and the installed version of GitLab, the restore command will abort with an error. Install the correct GitLab version and try again.
本文版權歸作者所有,歡迎轉載,請務必新增原文連結。