一、备份
1、备份目录路径设置
vim /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/data/gitlab/backups" # gitlab备份目录
gitlab_rails['backup_archive_permissions'] = 0644 # 生成的备份文件权限
gitlab_rails['backup_keep_time'] = 7776000 # 备份保留天数为3个月(即90天,这里是7776000秒)
mkdir -p /data/gitlab/backups; chown -R git.git /data/gitlab/backups; chmod -R 777 /data/gitlab/backups
# 配置生效
gitlab-ctl reconfigure
2、备份操作
# 手动备份
gitlab-rakegitlab:backup:create
# 自动备份
vim /opt/scripts/gitlab_backup.sh
#!/bin/bash
/usr/bin/gitlab-rake gitlab:backup:create CRON=1
crontab -l
0 0 * * * /bin/bash -x /opt/scripts/gitlab_backup.sh> /dev/null 2>&1
二、恢复
# 关闭相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl status
# 指定备份文件恢复(Gitlab的恢复操作会先将当前所有的数据清空,然后再根据备份数据进行恢复)
gitlab-rake gitlab:backup:restore BACKUP=1510472027_2017_11_12_9.4.5
# 启动服务
gitlab-ctl start
gitlab-ctl status
# 检查恢复情况
gitlab-rake gitlab:check SANITIZE=true
三、备注
Gitlab迁移与恢复一样,但是要求两个GitLab版本号一致