Gitlab 备份还原
备份数据:通过命令进行备份操作
gitlab-rake gitlab:backup:create
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
...
[DISABLED]
Creating backup archive: 1575855187_2019_12_09_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
....
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
ls /var/opt/gitlab/backups
1575855187_2019_12_09_gitlab_backup.tar
还原数据:停止相关服务进行还原
# 停止相关数据连接服务 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq # 从1575855187备份中恢复/取决于备份文件前缀数字串
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1575855187_2019_12_09
# 启动Gitlab
sudo gitlab-ctl start
Gitlab 迁移
前提
迁移端搭建好同版本的Gitlab
迁移
备份数据:通过命令进行备份操作
gitlab-rake gitlab:backup:create
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
备份文件:主要备份相关服务的配置文件
# gitlab配置文件须迁移,迁移后需要调整数据存放目录 /etc/gitlab/gitlab.rb # nginx配置文件目录须迁移 /var/opt/gitlab/nginx/conf/* # 复制新服务器相同的目录下 /etc/gitlab/gitlab-secrets.json # 复制到新服务器相同目录下,解决ssh key认证不成功问题 /etc/ssh/*key*
迁移:将配置文件与备份数据文件上传到迁移服务器
scp /var/opt/gitlab/backups/1575855187_2019_12_09_gitlab_backup.tar root@x.x.x.x:/var/opt/gitlab/backups/ scp /etc/gitlab/gitlab.rb root@x.x.x.x:/etc/gitlab/ scp /var/opt/gitlab/nginx/conf/* root@x.x.x.x:/var/opt/gitlab/nginx/conf/ scp /etc/gitlab/gitlab-secrets.json root@x.x.x.x:/etc/gitlab/ scp /etc/ssh/*key* root@x.x.x.x:/etc/ssh/
还原:在迁移服务器内操作
# 停止服务 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq # 添加权限 chmod 755 /var/opt/gitlab/backups/1575855187_2019_12_09_gitlab_backup.tar chown git:git /var/opt/gitlab/backups/1575855187_2019_12_09_gitlab_backup.tar # 还原数据 gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1575855187_2019_12_09 # 启动gitlab服务 gitlab-ctl start