Gitlab 迁移恢复数据

背景:腾讯云先买了一台服务器,双十一发现有更优惠的,果断退款备份文件,重新购买
前提条件:新旧gitlab的版本一致,可参考我的另外一篇文章,安装gitlab并汉化
1.备份原gitlab的文件

gitlab-rake gitlab:backup:create
#备份完成,CD进去看一下备份结果
cd /var/opt/gitlab/backups
ls -l
total 244
-rw-r--r-- 1 git git 245760 Nov 12 15:33 1604389250_2020_11_03_12.3.5_gitlab_backup.tar

将改文件下载到本地,同时,备份配置文件(rb和关键的json)

cd /etc/gitlab
[root@VM-0-17-centos gitlab]# ls -l
total 116
-rw------- 1 root root 95205 Nov  3 17:07 gitlab.rb
-rw------- 1 root root 15611 Nov  3 17:27 gitlab-secrets.json
drwxr-xr-x 2 root root  4096 Nov  3 16:51 trusted-certs

备份gitlab.rb(可选)和gitlab-secrets.json(必须备份,不然恢复时系统异常)
将3个文件传到服务器,新服务器装好后,先运行一下,进去设置默认密码
开始上传文件至新服务器,对应文件传至对应目录,给777 root权限
重要!!!
执行gitlab恢复命令,此处请不要gitlab-cli stop,会无法恢复,提示找不到sock


image.png

直接执行恢复命令,不要stop gitlab

gitlab-rake gitlab:backup:restore BACKUP=1604389250_2020_11_03_12.3.5

输入2次交互的YES,等待恢复成功

Deleting tmp directories ... done
done
done
done
done
done
done
done
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
and are not included in this backup. You will need to restore these files manually.
Restore task is done.
[root@VM-0-17-centos gitlab]# gitlab-ctl restart
ok: run: alertmanager: (pid 27661) 0s
ok: run: gitaly: (pid 27676) 0s
ok: run: gitlab-exporter: (pid 27698) 0s
ok: run: gitlab-workhorse: (pid 27712) 1s
ok: run: grafana: (pid 27731) 0s
ok: run: logrotate: (pid 27745) 0s
ok: run: nginx: (pid 27827) 1s
ok: run: node-exporter: (pid 27839) 0s
ok: run: postgres-exporter: (pid 27848) 1s
ok: run: postgresql: (pid 27861) 0s
ok: run: prometheus: (pid 27870) 1s
ok: run: redis: (pid 27885) 0s
ok: run: redis-exporter: (pid 28043) 0s
ok: run: sidekiq: (pid 28066) 0s
ok: run: unicorn: (pid 28082) 0s

恢复成功后,最好重启一些,恢复完成

你可能感兴趣的:(Gitlab 迁移恢复数据)