gitlab数据备份恢复
备份前必须先停止gitlab两个服务
[root@ubuntu1804 ~]#gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
[root@ubuntu1804 ~]#gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
手动备份数据
#在任意目录即可备份当前gitlab数据
[root@ubuntu1804 ~]#gitlab-rake gitlab:backup:create
2020-03-07 14:34:56 +0800 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2020-03-07 14:34:57 +0800 -- done
2020-03-07 14:34:57 +0800 -- Dumping repositories ...
* testgroup/testproject ... [DONE]
[SKIPPED] Wiki
2020-03-07 14:34:58 +0800 -- done
2020-03-07 14:34:58 +0800 -- Dumping uploads ...
2020-03-07 14:34:58 +0800 -- done
2020-03-07 14:34:58 +0800 -- Dumping builds ...
2020-03-07 14:34:58 +0800 -- done
2020-03-07 14:34:58 +0800 -- Dumping artifacts ...
2020-03-07 14:34:58 +0800 -- done
2020-03-07 14:34:58 +0800 -- Dumping pages ...
2020-03-07 14:34:58 +0800 -- done
2020-03-07 14:34:58 +0800 -- Dumping lfs objects ...
2020-03-07 14:34:58 +0800 -- done
2020-03-07 14:34:58 +0800 -- Dumping container registry images ...
2020-03-07 14:34:58 +0800 -- [DISABLED]
Creating backup archive: 1583562898_2020_03_07_11.11.8_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
Deleting old backups ... skipping
#备份完成后启动gitlab
[root@ubuntu1804 ~]#gitlab-ctl start
查看要恢复的文件
/var/opt/gitlab/backups/ # Gitlab数据备份目录,需要使用命令备份的
/var/opt/gitlab/nginx/conf #nginx配置文件
/etc/gitlab/gitlab.rb #gitlab配置文件
备份后可以在/var/opt/gitabl/backups目录下看到备份文件
[root@ubuntu1804 ~]#ll /var/opt/gitlab/backups/
total 108
drwx------ 2 git root 4096 Mar 7 14:34 ./
drwxr-xr-x 20 root root 4096 Mar 7 11:12 ../
-rw------- 1 git git 102400 Mar 7 14:34 1583562898_2020_03_07_11.11.8_gitlab_backup.tar
删除项目和用户信息
略
执行恢复
#恢复前先停止两个服务
[root@ubuntu1804 ~]#gitlab-ctl stop unicorn
[root@ubuntu1804 ~]#gitlab-ctl stop sidekiq
#恢复时指定备份文件的时间部分,不需要指定文件的全名
[root@ubuntu1804 ~]# gitlab-rake gitlab:backup:restore BACKUP=备份文件名
确认恢复数据:
恢复后再将之前停止的两个服务启动
[root@ubuntu1804 ~]# gitlab-ctl start sidekiq
ok: run: sidekiq: (pid 16859) 0s
[root@ubuntu1804 ~]# gitlab-ctl start unicorn
ok: run: unicorn: (pid 16882) 1s
#或者执行下面也可以
[root@ubuntu1804 ~]# gitlab-ctl start
本文链接:http://www.yunweipai.com/35696.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52602.html