• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

企业级Gitlab的备份与恢复【显哥出品,必为精品】

Gitlib lixian 4年前 (2020-05-12) 21528次浏览 0个评论 扫描二维码

1.修改配置文件

[root@gitlab ~/tlbb]# vim /etc/gitlab/gitlab.rb 
[root@gitlab ~/tlbb]# 
[root@gitlab ~/tlbb]# grep '^gitlab_rails' /etc/gitlab/gitlab.rb 
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/data/gitlab/backups"
gitlab_rails['backup_archive_permissions'] = 0644
gitlab_rails['backup_keep_time'] = 604800

2.配置文件生效

[root@gitlab ~/tlbb]# gitlab-ctl  reconfigure
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - mattermost (0.1.0)
  - consul (0.0.0)
  - registry (0.1.0)
  - gitaly (0.1.0)
  - runit (0.14.2)
Installing Cookbook Gems:
Compiling Cookbooks...

3.手动备份

[root@gitlab ~/tlbb]# ls
1.txt  2.txt  3.txt  dev01.log  lixian.log  master.txt  test.txt  Windows.lx
[root@gitlab ~/tlbb]# gitlab-rake  gitlab:backup:create
Dumping database ...

4.查看备份文件

[root@gitlab ~/tlbb]# ll /data/gitlab/backups/
total 512
-rw-r--r-- 1 git git 522240 May 13 15:12 1589353976_2020_05_13_10.2.2_gitlab_backup.tar

5.删除远程仓库文件及本地文件

[root@gitlab ~/tlbb]# git rm -f *
rm '1.txt'
rm '2.txt'
rm '3.txt'
rm 'Windows.lx'
rm 'dev01.log'
rm 'lixian.log'
rm 'master.txt'
rm 'test.txt'
[root@gitlab ~/tlbb]# ls
[root@gitlab ~/tlbb]# git commit -m "del all file"
[master 8e07612] del all file
 8 files changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 1.txt
 delete mode 100644 2.txt
 delete mode 100644 3.txt
 delete mode 100644 Windows.lx
 delete mode 100644 dev01.log
 delete mode 100644 lixian.log
 delete mode 100644 master.txt
 delete mode 100644 test.txt
[root@gitlab ~/tlbb]# git push -u origin master
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 185 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@10.0.0.100:Dev/tlbb.git
   a26c31d..8e07612  master -> master
Branch master set up to track remote branch master from origin.

企业级Gitlab的备份与恢复【显哥出品,必为精品】

6.恢复数据

[root@gitlab ~/tlbb]# gitlab-ctl  stop unicorn
ok: down: unicorn: 76s, normally up
[root@gitlab ~/tlbb]# gitlab-ctl  stop sidekiq
ok: down: sidekiq: 73s, normally up
[root@gitlab ~/tlbb]# gitlab-rake gitlab:backup:restore BACKUP=1589353976_2020_05_13_10.2.2
#如果有要提示要输入yes即可
[root@gitlab ~/tlbb]# gitlab-ctl  restart

7.发现web界面已经有了数据,然后拉取数据

[root@gitlab ~]# git clone git@10.0.0.100:Dev/tlbb.git
Cloning into 'tlbb'...
remote: Counting objects: 20, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 20 (delta 7), reused 20 (delta 7)
Receiving objects: 100% (20/20), done.
Resolving deltas: 100% (7/7), done.
[root@gitlab ~]# ls tlbb/
1.txt  2.txt  3.txt  dev01.log  lixian.log  master.txt  test.txt  Windows.lx

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:企业级Gitlab的备份与恢复【显哥出品,必为精品】
喜欢 (0)

您必须 登录 才能发表评论!