一,備份
備份默認路徑查看:
gitlab/config/gitlab.yml 中的backup: 默認tmp/backups ====》這個是gitlab/tmp/backups/ 可不是系統的tmp/backups
進入gitlab賬戶下執行備份命令
bundle exec rake gitlab:backup:create ===>必須在Gemfile 所在的目錄下執行
如果備份報錯
rake aborted!
cannot load such file -- rb-inotify
/home/gitlab/gitlab/config/application.rb:9:in `<top (required)>'
/home/gitlab/gitlab/Rakefile:5:in `require'
/home/gitlab/gitlab/Rakefile:5:in `<top (required)>
解決方案:
bundle exec rake assets:precompile RAILS_ENV=production ==》生成資產標籤
bundle exec rake gitlab:backup:create RAILS_ENV=production ===》指定環境變量
二,遷移
停止所有的gitlab服務:
service gitlab stop
pkill nginx
將備份文件放在新服務器的bakups目錄下
備份文件權限修改爲777: chmod 777 xxxx
恢復:sudo -u gitlab -H bundle exec rake gitlab:backup:restore BACKUP=1541820252 RAILS_ENV=production
重啓gitlab nginx服務
該版本會會出現倉庫無法正常還原的問題:
解決方案:
cd /home/git/
tar zcvf repositories.tar.gz ./repositories/ ===》把倉庫壓縮成tar包
scp repositories.tar.gz [email protected]:/opt ===>發送至備份服務器
cp /opt/repositories.tar.gz /home/git
chown git:git repositories.tar.gz
mv repositories repositories_old
tar zxvf repositories.tar.gz -C /home/git/
重啓gitlab nginx 服務