6.gitlab备份和恢复
建议备份策略:本地保留3-7天,异地永久备份
查看版本
cat /etc/redhat-release
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
备份
修改配置文件
vim /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = 'true'
gitlab_rails['backup_path'] = '/data/backup/gitlab' # 备份路径
gitlab_rails['backup_keep_time'] = 604800 # 本地保留时间7天=604800秒,备份完成会生成当天日期的tar包
如果没目录,就创建
mkdir -p /data/backup/gitlab
chown -R git:git /data/backup/gitlab
gitlab-ctl reconfigure
gitlab-ctl restart
手动备份
/usr/bin/gitlab-rake gitlab:backup:create
计划任务
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
恢复
需要安装gitlab server
停止数据写入服务,为了保障数据一致性
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
执行恢复
注意文件的权限和所有者
gitlab-rake gitlab:backup:restore BACKUP=1596693022_gitlab_backup.tar
gitlab-ctl start unicorn
gitlab-ctl start sidekiq
代码存放位置
/var/opt/gitlab/git-data/repositories/java/app1.git
java为创建的组
app1.git为项目
直接备份项目也行,但是不会备份权限等关系,因为权限存在数据库中
邮件配置
每种邮箱的配置可能不同,以下是参考
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]' # 发件人
gitlab_rails['gitlab_email_display_name'] = 'gitlab'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.126.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "caolixun"
gitlab_rails['smtp_password'] = "mypassword"
gitlab_rails['smtp_domain'] = "126.com"
gitlab_rails['smtp_authentication'] = "login"
标签:恢复,备份,gitlab,smtp,rails,ctl,backup
From: https://www.cnblogs.com/lixunblogs/p/18167122