gitlab备份还原

gitlab目录存放

/var/opt/gitlab/git-data/repositories/ 库默认存储目录
/opt/gitlab/ 应用代码和相应的依赖程序
/etc/gitlab/ 配置文件目录
/var/log/gitlab/ 此目录下存放了gitlab各个组件产生的日志
/var/opt/gitlab/backups/ 备份文件生成的目录
变更配置文件,需要以下操作
gitlab-ctl reconfigure 重置配置文件
gitlab-ctl show-config 验证配置文件
一、备份
配置文件中加入
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
gitlab_rails['backup_keep_time'] = 604800

如果自定义备份目录需要赋予git权限

mkdir /data/backup/gitlab
chown -R git.git /data/backup/gitlab

添加定时任务Crontab  

0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create

二、还原

1.停止gitlab进程
只能还原到与备份文件相同的gitlab版本。执行恢复操作时,需要gitlab处于运行状态,备份文件位于gitlab_rails[‘backup_path’]。需要先停掉两个服务,停止连接到数据库的进程(也就是停止数据写入服务,如果是空主机,没有任何操作的话,可以不停止服务,停止相应服务的目的是为了保证数据移植),但是保持GitLab是运行的。

[root@localhost gitlab]# gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
[root@localhost gitlab]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up

2.恢复还原,并且重启

mv 1564562420_2019_07_31_10.0.0_gitlab_backup.tar 1564562420_gitlab_backup.tar
gitlab-rake gitlab:backup:restore BACKUP=1564562420
gitlab-ctl restart
posted @ 2021-06-12 08:34  lucky_tomato  阅读(185)  评论(0编辑  收藏  举报