背景:
假设我们当前的gitlab挂掉了,整个服务器都起不来了,但是我们有对gitlab的归档备份,这时候还可以恢复出数据来。(需要备份gitlab原始安装包、gitalb的tar备份文件、/etc/gitlab/gitlab.rb文件)
[vip]
步骤如下:
1.安装和宿主机相同版本到gitlab到新机器之上
[root@localhost ~]# ll total 2648156 -rw------- 1 root root 2410485760 May 21 16:50 1526882201_gitlab_backup.tar -rw-------. 1 root root 1198 Feb 13 00:00 anaconda-ks.cfg -rw-r--r-- 1 root root 301174310 May 21 16:48 gitlab-ce-8.12.7-ce.0.el7.x86_64.rpm -rw-r--r-- 1 root root 42094 May 21 16:48 gitlab.rb
开始安装
[root@localhost ~]# rpm -ivh gitlab-ce-8.12.7-ce.0.el7.x86_64.rpm
配置并启动
[root@localhost ~]# gitlab-ctl reconfigure
浏览器验证
开始做恢复工作
拷贝备份的gitlab.rb文件到新机器的/etc/gitlab/目录下。
[root@localhost ~]# cd /etc/gitlab/ [root@localhost gitlab]# ll total 52 -rw------- 1 root root 42076 May 21 16:53 gitlab.rb -rw------- 1 root root 6392 May 21 16:54 gitlab-secrets.json drwxr-xr-x 2 root root 6 May 21 16:54 trusted-certs [root@localhost gitlab]# cp gitlab.rb gitlab.rb.back [root@localhost gitlab]# rm -rf gitlab.rb [root@localhost gitlab]# cp /root/gitlab.rb /etc/gitlab/ [root@localhost gitlab]# ll total 96 -rw-r--r-- 1 root root 42094 May 21 17:03 gitlab.rb -rw------- 1 root root 42076 May 21 17:03 gitlab.rb.back -rw------- 1 root root 6392 May 21 16:54 gitlab-secrets.json drwxr-xr-x 2 root root 6 May 21 16:54 trusted-certs
修改下新的服务器的/etc/gitlab/gitlab.rb中的external_url 为新的服务器地址即可(假设我们没有对默认的gitlab备份路径等参数做修改,都是使用默认参数)。
[root@localhost gitlab]# vi /etc/gitlab/gitlab.rb external_url 'http://192.168.1.142'
重新配置
[root@localhost gitlab]# gitlab-ctl reconfigure
修改下文件权限
[root@localhost gitlab]# chown git.root /var/opt/gitlab/backups -R
把文件转移到自动恢复目录
[root@localhost backups]# cp -r /root/1526882201_gitlab_backup.tar /var/opt/gitlab/backups/
开始恢复
[root@localhost backups]# cd /var/opt/gitlab/backups/ [root@localhost backups]# ll total 2353992 -rw------- 1 root root 2410485760 May 21 17:09 1526882201_gitlab_backup.tar [root@localhost backups]# gitlab-rake gitlab:backup:restore BACKUP=1526882201 Unpacking backup ... done Before restoring the database we recommend removing all existing tables to avoid future upgrade problems. Be aware that if you have custom tables in the GitLab database these tables and all data will be removed. Do you want to continue (yes/no)? yes This will rebuild an authorized_keys file. You will lose any data stored in authorized_keys file. Do you want to continue (yes/no)? yes Deleting tmp directories ... done done done done done done done
在恢复的过程中,需要输入几次yes,即可完成恢复。
重启服务
[root@localhost backups]# gitlab-ctl restart
[/vip]
继续阅读
- 我的QQ
- QQ扫一扫
-
- 我的头条
- 头条扫一扫
-
评论