GitLab 数据备份与恢复

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

 

posted @ 2020-04-08 14:29  苏陌宁  阅读(2942)  评论(0编辑  收藏  举报