备份
修改配置文件
编辑文件: vim /etc/gitlab/gitlab.rb
# 开启备份 gitlab_rails['manage_backup_path'] = true # 备份的路径 gitlab_rails['backup_path'] = "/backup/gitlab/" # 创建备份生成的文件权限 gitlab_rails['backup_archive_permissions'] = 0644 # 备份保留天数单位秒 gitlab_rails['backup_keep_time'] = 604800
用户授权
mkdir -p /backup/gitlab/ chown -R git.git /backup/gitlab/
添加定时任务
每天凌晨两点执行备份任务.
crontab -e 0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
重启
gitlab-ctl reconfigure gitlab-ctl restart
恢复
查看备份文件
[root@node1 ~]# cd /backup/gitlab/ [root@node1 gitlab]# ll total 372 -rw-r--r-- 1 git git 378880 Jul 30 00:16 1596039380_2020_07_30_12.10.0_gitlab_backup.tar
停止数据写入服务
gitlab-ctl stop unicorn gitlab-ctl stop sidekiq
恢复数据
[root@node1 gitlab]# gitlab-rake gitlab:backup:restore BACKUP=1596039380_2020_07_30_12.10.0_gitlab_backup.tar
重启服务
gitlab-ctl restart