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
. It needs to be owned by the 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 unicorngitlab-ctl stop sidekiq# Verifygitlab-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 reconfiguregitlab-ctl restartgitlab-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.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。