一、备份
gitlab在不同安装方式下备份指令也有所区别
(1) 使用Omnibus包安装的请用1
gitlab-rake gitlab:backup:create
(2) 使用源码安装的请用1
2cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
下面是执行成功输出结果1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27Dumping database ...
Dumping MySQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
* root/test ... [DONE]
* pengyang/test1 ... [DONE]
done
Dumping uploads ...
done
Dumping builds ...
done
Dumping artifacts ...
done
Dumping lfs objects ...
done
Dumping container registry images ...
[DISABLED]
Creating backup archive: 1468218434_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
Deleting old backups ... skipping
二、 恢复
PS: gitlab恢复备份文件版本一定和现部署的版本一致,如果不一致,恢复不成功
将步骤1产生的文件传输到服务器B gitlab备份目录下即可(服务器B,是已搭建好新的gitlab环境)
(1) Omnibus安装包恢复方法1
2
3
4
5sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186
sudo gitlab-ctl start
(2) 源码安装恢复方法1
2service gitlab stop
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production BACKUP=1467484671
三、升级服务器gitlab版本(源码升级方法)
(1) 首先停止服务1
service gitlab stop
(2) 在线获取指定版本,本次例子我们获取和目标服务器一样的8.4.4版本1
2
3
4cd /home/git/gitlab
sudo -u git -H git fetch -all
sudo -u git -H git checkout -- Gemfile.lock db/schema.rb
sudo -u git -H git checkout v8.4.4 -b v8.4.4
(3) 更新gitlab-shell到合适的版本1
2
3cd /home/git/gitlab-shell
sudo -u git -H git fetch
sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION` -b v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`
(4) 更新gitlab-workhorse1
2
3
4cd /home/git/gitlab-workhorse
sudo -u git -H git fetch
sudo -u git -H git checkout `cat /home/git/gitlab/GITLAB_WORKHORSE_VERSION` -b `cat /home/git/gitlab/GITLAB_WORKHORSE_VERSION`
sudo -u git -H make
(5) 安装1
cd /home/git/gitlab
(6) 例子中我们使用MYSQL库1
2
3
4
5sudo -u git -H bundle install --without development test postgres --deployment
(sudo -u git -H bundle install --deployment --without development test postgres aws kerberos #线上环境安装时命令)
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
(7) 重新启动服务1
2service gitlab start
service nginx restart
(8) 检查工作是否正常1
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
四、 gitlab遇到问题和解决方法
在使用GITLAB中遇到问题怎么快速查找原因?
使用中GITLAB因为各位调试也遇到一些莫名问题,比如无法在网页版上COMMIT数据,或提交了数据但页面上提交数不发生变更。这个时候第一看日志。第二请使用这个命令1
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
大多问题系统本身都会帮你查找出来
---本文结束感谢您的阅读。微信扫描二维码,关注我的公众号---
本文链接: https://www.yp14.cn/2016/07/11/Gitlab备份升级与恢复/
版权声明: 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。转载请注明出处!