gitlab迁移

注意事项:
一、部署gitlab版本需要与旧版本一致,否则在导入备份的时候报错

  1. 安装rpm
    rpm -ivh ./gitlab-ce-11.2.3-ce.0.sles42.x86_64.rpm

  2. 修改配置文件:
    [root@gitlab mnt]# grep -v -E ‘#|$’ /etc/gitlab/gitlab.rb
    external_url ‘http://10.19.0.207’ ##clone域名,可以是外网地址
    gitlab_rails[‘manage_backup_path’] = true ##开启备份
    gitlab_rails[‘backup_path’] = “/mnt/gitlab/backups” ##备份路径
    git_data_dirs({
    “default” => {
    “path” => “/mnt/git-data” ##数据路径
    }
    })

  3. 初始化
    gitlab-ctl reconfigure

  4. 启动gitlab
    gitlab-ctl restart

二、备份 + 导入

1)备份数据 会备份到配置文件中设置的备份目录中
gitlab-rake gitlab:backup:create RAILS_ENV=production

例如:
1661220380_2022_08_23_11.2.3_gitlab_backup.tar

2)导入数据(先拷贝至新服务中)

停止相关数据连接服务

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

2-1)拷贝数据至新服务器中,略
2-2)授权chown -R git.git /mnt/gitlab/backups/
2-3)导入数据
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1661220380_2022_08_23_11.2.3 (注意这里没有后缀_gitlab_backup.tar)

###备份详解
设置定时任务(crontab -e)
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

重启crontab
systemctl restart crond

设置备份的天数
编辑/etc/gitlab/gitlab.rb文件。
###! The duration in seconds to keep backups before they are allowed to be deleted

keep 2 days

gitlab_rails[‘backup_keep_time’] = 172800

恢复备份的数据

停止相关数据连接服务

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

从1628100892_2021_08_05_12.1.1_gitlab_backup.tar 备份中恢复

gitlab-rake gitlab:backup:restore BACKUP=1628100892_2021_08_05_12.1.1

启动Gitlab

gitlab-ctl start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值