Gitlab 从 Ubuntu 机器迁移到 Centos


  • 原机器和目标机器 gitlab 版本保持一致
  • 原机器进行备份并复制到新机器
  • mysql 转为 PG

升级新机器 Python 版本

Please make sure to have Python 2.7.x (or higher) installed.  

Stop GitLab

sudo service gitlab stop  

Create the backup

cd /home/git/gitlab  
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production  

Note the filename of the backup that was created. We will call it TIMESTAMPgitlabbackup.tar below.

Move the backup file we will convert to its own directory

sudo -u git -H mkdir -p tmp/backups/postgresql  
sudo -u git -H mv tmp/backups/TIMESTAMP_gitlab_backup.tar tmp/backups/postgresql/  

Create a separate database dump with PostgreSQL compatibility

cd tmp/backups/postgresql  
sudo -u git -H mysqldump --compatible=postgresql --default-character-set=utf8 -r gitlabhq_production.mysql -u root gitlabhq_production -p  

Clone the database converter

sudo -u git -H git clone -b gitlab  

Convert gitlabhq_production.mysql

sudo -u git -H mkdir db  
sudo -u git -H python mysql-postgresql-converter/ gitlabhq_production.mysql db/database.sql  
sudo -u git -H ed -s db/database.sql < mysql-postgresql-converter/move_drop_indexes.ed  

Compress database backup

Warning: If you have Gitlab 7.12.0 or older skip this step and import the database.sql directly into the backup with:

 sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql

The compressed databasedump is not supported at 7.12.0 and older.

sudo -u git -H gzip db/database.sql  

Replace the MySQL dump in TIMESTAMPgitlabbackup.tar.

Warning: if you forget to replace TIMESTAMP below, tar will create a new file 'TIMESTAMPgitlabbackup.tar' without giving an error.

sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql.gz  


TIMESTAMPgitlabbackup.tar can now be restored into a Postgres GitLab installation. See for more information about backups.

CentOS 新机器安装相同版本 gitlab,建议使用 Omnibus

you need to have a working GitLab installation before you can perform a restore. Omnibus installations

This procedure assumes that:

  • You have installed the exact same version of GitLab Omnibus with which the backup was created
  • You have run sudo gitlab-ctl reconfigure at least once
  • GitLab is running. If not, start it using sudo gitlab-ctl start. First make sure your backup tar file is in the backup directory described in the gitlab.rb configuration gitlabrails['backuppath']. The default is /var/opt/gitlab/backups.
sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/  

Stop the processes that are connected to the database. Leave the rest of GitLab running:

sudo gitlab-ctl stop unicorn  
sudo gitlab-ctl stop sidekiq  


sudo gitlab-ctl status  

Next, restore the backup, specifying the timestamp of the backup you wish to restore:

This command will overwrite the contents of your GitLab database!

sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186  

Restart and check GitLab:

sudo gitlab-ctl start  
sudo gitlab-rake gitlab:check SANITIZE=true  

If there is a GitLab version mismatch between your backup tar file and the installed version of GitLab, the restore command will abort with an error. Install the correct GitLab version and try again.


.ssh 文件权限

authorized 文件