前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >gitlab 备份&恢复

gitlab 备份&恢复

原创
作者头像
陈不成i
修改2021-06-04 18:05:58
1.7K0
修改2021-06-04 18:05:58
举报
文章被收录于专栏:ops技术分享ops技术分享

Gitlab 成功运行起来之后,最终的事情就是定期的备份,遇到问题后的还原。

备份配置

默认 Gitlab 的备份文件会创建在/var/opt/gitlab/backups文件夹中,格式为时间戳_日期_版本号_gitlab_backup.tar,例如:1515031353_2018_01_04_10.3.2_gitlab_backup.tar。 修改备份文件夹,需要修改配置文件/etc/gitlab/gitlab.rb中的:

代码语言:javascript
复制
gitlab_rails['backup_path'] = '/your_wish/backups'

然后gitlabctl-reconfigure生效。

手动备份

命令:gitlab-backup create

For GitLab 12.1 and earlier, use

代码语言:javascript
复制
gitlab-rake gitlab:backup:create

会在命令执行的时间点,在你配置的文件夹或者默认文件夹创建一个备份文件。

自动备份

  1. 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.

代码语言:javascript
复制
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:

代码语言:javascript
复制
gitlab-ctl stop unicorngitlab-ctl stop sidekiq# Verifygitlab-ctl status

Next, restore the backup, specifying the timestamp of the backup you wish to restore:

代码语言:javascript
复制
# 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

代码语言:javascript
复制
gitlab-rake gitlab:backup:restore

Next, restore /etc/gitlab/gitlab-secrets.json if necessary as mentioned above.

Reconfigure, restart and check GitLab:

代码语言:javascript
复制
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 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 备份配置
  • 手动备份
  • 自动备份
  • 备份恢复
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com