[root@tom01 tools]# vim /etc/gitlab/gitlab.rb
202 gitlab_rails[‘backup_path’] = “/data/backups/gitlab” 存储路径可自定义
206 gitlab_rails[‘backup_keep_time’] = 604800 保留备份时间 单位秒
创建存储目录
[root@tom01 tools]# mkdir -p /data/backups/gitlab
[root@tom01 tools]# chown -R git.git /data/backups/gitlab
重新加载配置
[root@tom01 tools]# gitlab-ctl reconfigure
[root@tom01 tools]# gitlab-ctl restart
ok: run: gitlab-workhorse: (pid 43180) 0s
ok: run: logrotate: (pid 43187) 1s
ok: run: nginx: (pid 43194) 1s
ok: run: postgresql: (pid 43204) 0s
ok: run: redis: (pid 43206) 1s
ok: run: sidekiq: (pid 43221) 1s
ok: run: unicorn: (pid 43226) 0s
备份命令
[root@tom01 tools]# gitlab-rake gitlab:backup:create
加入定时任务
[root@tom01 tools]# crontab -e
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
也可以在使用rsync增量备份
查看备份文件
[root@tom01 tools]# ls /data/backups/gitlab/
1552834038_gitlab_backup.tar
恢复备份
[root@tom01 tools]# gitlab-ctl stop unicorn
ok: down: unicorn: 1s, normally up
[root@tom01 tools]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
[root@tom01 tools]# gitlab-rake gitlab:backup:restore BACKUP=1552834038
注:1552834038为备份文件开头部分 时间戳
一路yes
[root@tom01 tools]# date -d @1552834038
Sun Mar 17 22:47:18 CST 2019
恢复完后重启服务
[root@tom01 tools]# gitlab-ctl start unicorn
ok: run: unicorn: (pid 43869) 0s
[root@tom01 tools]# gitlab-ctl start sidekiq
ok: run: sidekiq: (pid 43920) 0s