第8章 gitlab 数据恢复
之前用gitlab-rake gitlab:backup:create 备份过数据
8.1 注意事项:
1、版本要相同,这个已经说了.
2、安装完成后要运行gitlab-ctl reconfigure一次,这次也满足了.
3、gitlab当前要在运行的状态下,如果没有,使用gitlab-ctl start来启动它.
8.2 将备份数据拷贝上传 到/var/opt/gitlab/backups/
[root@gitlab backups]# cd /var/opt/gitlab/backups/ [root@gitlab backups]# ls -l 总用量 52 -rw------- 1 git git 51200 8月 3 15:46 1501746380_2017_08_03_gitlab_backup.tar 恢复文件授权git.git 注意要把你的备份文件的权限设置成git:git chown git:git /var/opt/gitlab/backups/1501746380_2017_08_03_gitlab_backup.tar
停止gitlab连接数据库
.将连接到数据库的gitlab组件停止,其它组件状态不要改变.
[root@gitlab backups]# sudo gitlab-ctl stop unicorn ok: down: unicorn: 1s, normally up [root@gitlab backups]# sudo gitlab-ctl stop sidekiq ok: down: sidekiq: 0s, normally up #查看gitlab状态最后两项为关闭状态 [root@gitlab backups]# gitlab-ctl status run: gitlab-workhorse: (pid 14054) 640s; run: log: (pid 1351) 10504s run: logrotate: (pid 14062) 640s; run: log: (pid 1349) 10504s run: nginx: (pid 14068) 639s; run: log: (pid 1343) 10504s run: postgresql: (pid 14076) 639s; run: log: (pid 1356) 10504s run: redis: (pid 14084) 639s; run: log: (pid 1345) 10504s down: sidekiq: 6s, normally up; run: log: (pid 1355) 10504s down: unicorn: 10s, normally up; run: log: (pid 1350) 10504s
8.3 恢复数据
进入恢复目录 [root@gitlab backups]#cd /var/opt/gitlab/backups [root@gitlab backups]# ls 1501746380_2017_08_03_gitlab_backup.tar [root@gitlab backups]# pwd /var/opt/gitlab/backups #执行命令 [root@gitlab backups]# sudo gitlab-rake gitlab:backup:restore BACKUP=1501746380_2017_08_03
#注意设置你要还原的文件,下面的1501746380_2017_08_03是你的备份文件的前面的数字,例如我1501746380_2017_08_03_gitlab_backup.tar
没有报错的话,中间会叫你确认两次,然后是一大堆的ALERT TABLE DEL TABLE
8.3.1 输入第一次yes [root@gitlab backups]# sudo gitlab-rake gitlab:backup:restore BACKUP=1501746380_2017_08_03 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 #在这里输入 8.3.2 第二次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
8.3.3 查看重启gitlab 和再次查看状态
[root@gitlab backups]# gitlab-ctl restart ok: run: gitlab-workhorse: (pid 14942) 0s ok: run: logrotate: (pid 14950) 1s ok: run: nginx: (pid 14956) 0s ok: run: postgresql: (pid 14964) 1s ok: run: redis: (pid 14966) 0s ok: run: sidekiq: (pid 14976) 0s ok: run: unicorn: (pid 14979) 1s [root@gitlab backups]# gitlab-ctl status run: gitlab-workhorse: (pid 14942) 26s; run: log: (pid 1351) 10964s run: logrotate: (pid 14950) 26s; run: log: (pid 1349) 10964s run: nginx: (pid 14956) 25s; run: log: (pid 1343) 10964s run: postgresql: (pid 14964) 25s; run: log: (pid 1356) 10964s run: redis: (pid 14966) 24s; run: log: (pid 1345) 10964s run: sidekiq: (pid 14976) 24s; run: log: (pid 1355) 10964s run: unicorn: (pid 14979) 24s; run: log: (pid 1350) 10964s
8.3.4 恢复前
8.3.5 恢复后
*************************选择了,剩下的就是坚持和努力!*************************