一 摘要
本文主要介绍基于gitlab 备份包恢复gitlab
二 环境信息
科目 | 老环境 | 新环境 |
---|---|---|
操作系统 | centos7.3 | centos7.6 |
docker | 19.0.3 | 19.0.3 |
gitlab | 12.7 | 12.7 |
三 实施
主要有安装docker\docker-compose\gitlab
备份恢复三个文件
1.gitlab 配置文件gitlab.rb
2.gitlab 加密文件gitlab-secrets.json
3.backup 目录下备份文件
3.1 安装基础软件
安装操作系统,安装docker、安装gitlab
3.2 备份数据移到新gitlab 备份目录
bash
root@1591e6e16e02:/var/opt/gitlab/backups# ls -al
total 115855504
drwx------. 3 git root 83 Nov 13 07:42 .
drwxr-xr-x. 20 root root 4096 Nov 13 07:30 ..
-rw-r--r--. 1 root root 118636032000 Nov 13 07:21 1699301977_2023_11_06_12.7.7-ee_gitlab_backup.tar
drwx------. 3 git git 21 Nov 13 07:42 repositories
root@1591e6e16e02:/var/opt/gitlab/backups# date
Mon Nov 13 07:50:48 UTC 2023
root@1591e6e16e02:/var/opt/gitlab/backups#
3.3 关闭unicorn 和sidekiq
bash
root@1591e6e16e02:/# gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
root@1591e6e16e02:/# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
root@1591e6e16e02:/# gitlab-ctl status
run: alertmanager: (pid 327) 3132s; run: log: (pid 325) 3132s
run: gitaly: (pid 302) 3132s; run: log: (pid 301) 3132s
run: gitlab-exporter: (pid 320) 3132s; run: log: (pid 312) 3132s
run: gitlab-workhorse: (pid 315) 3132s; run: log: (pid 308) 3132s
run: grafana: (pid 321) 3132s; run: log: (pid 314) 3132s
run: logrotate: (pid 316) 3132s; run: log: (pid 307) 3132s
run: nginx: (pid 319) 3132s; run: log: (pid 309) 3132s
run: postgres-exporter: (pid 324) 3132s; run: log: (pid 318) 3132s
run: postgresql: (pid 306) 3132s; run: log: (pid 305) 3132s
run: prometheus: (pid 322) 3132s; run: log: (pid 313) 3132s
run: redis: (pid 300) 3132s; run: log: (pid 299) 3132s
run: redis-exporter: (pid 317) 3132s; run: log: (pid 310) 3132s
down: sidekiq: 35s, normally up; run: log: (pid 311) 3132s
run: sshd: (pid 22) 3147s; run: log: (pid 21) 3147s
down: unicorn: 45s, normally up; run: log: (pid 303) 3132s
root@1591e6e16e02:/#
3.4 执行恢复命令
bash
gitlab-rake gitlab:backup:restore BACKUP = 1699301977_2023_11_06_12.7.7-ee