由於Gitlab自身的兼容性問題,高版本的Gitlab無法恢復低版本備份的數據,需要注意在b服務器部署和a服務器一樣版本的gitlab
查看gitlab版本的命令:
[root@xxxx ~]# gitlab-rake gitlab:env:info System information System: CentOS 7.2.1511 Current User: git Using RVM: no Ruby Version: 2.3.5p376 Gem Version: 2.6.13 Bundler Version:1.13.7 Rake Version: 12.3.0 Redis Version: 3.2.11 Git Version: 2.14.3 Sidekiq Version:5.0.4 Go Version: unknown GitLab information Version: 10.3.4 Revision: 56dc722 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://192.168.0.246:7023 HTTP Clone URL: http://192.168.0.246:7023/some-group/some-project.git SSH Clone URL: git@192.168.0.246:some-group/some-project.git Using LDAP: no Using Omniauth: no GitLab Shell Version: 5.10.2 Repository storage paths: - default: /home/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git [root@xxxxx ~]#
備份原192.168.0.108服務器上的的數據
gitlab-rake gitlab:backup:create RAILS_ENV=production
備份后的文件一般是位於/var/opt/gitlab/backups下, 自動生成文件名文件名如1558334901_2019_05_20_10.3.4_gitlab_backup.tar
將生成的tar文件拷貝到192.168.0.246服務器上相應的backups目錄下
可以利用scp進行直接拷貝.
scp root@192.168.0.108:/var/opt/gitlab/backups/1558334901_2019_05_20_10.3.4_gitlab_backup.tar /var/opt/gitlab/backups
在192.168.0.246服務器恢復數據
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1558334901_2019_05_20_10.3.4