Project

General

Profile

Support #459

How to Migrate GitLab Repositories to a New Server

Added by Daniel Curtis over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Source Code Management
Target version:
-
Start date:
09/21/2014
Due date:
% Done:

100%

Estimated time:
2.00 h
Spent time:

Description

Migrate Database

In this case, I’m using MySQL.

Use mysqldump to create dump of old database, then create a new database on the new server and import this:
  1. On old:
    mysqldump gitlab | gzip > gitlab.sql.gz
    
  2. On new:
    gunzip < gitlab.sql.gz | mysql gitlab
    
  3. Run the db migrate command to make sure the schema is updated to the latest version.
    sudo -u gitlab -H bundle exec rake db:migrate RAILS_ENV=production
    

Migrate Repositories

  • Rather than creating a new SSH key on the new server, copy over the old SSH key pair to the new server. Also copy of the authorized_keys file.
  • Set up gitolite on the new server using the old SSH key
  • Copy contents of /home/git/.gitolite/keydir/ from old to new server so that users don’t have to add their SSH keys again and change ownership to git:git.
  • Copy repositories from old to new
    sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/
    sudo chown -R git:git /home/git/repositories/
    sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_keys RAILS_ENV=production
    sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_repos RAILS_ENV=production
    
  • Update projects to use namespaces. This will move any projects that are in groups to a namespace. bundle exec rake gitlab:enable_namespaces RAILS_ENV=production
  • I could not get this working, easier to remove all projects from groups on the old install before migrating.
  • Run the rake:check command and see if it complains about anything. You may need to run the create satellites command or the run the script to update the hooks.
    bundle exec rake gitlab:check RAILS_ENV=production
    sudo -u git -H /home/gitlab/lib/support/rewrite-hooks.sh
    

Troubleshooting

  • If you get
    FATAL: split conf set, gl-conf not present for ‘gitolite-admin’
    fatal: The remote end hung up unexpectedly
    
    • Then you need to re-run the gitolite setup. This I think is because gitolite-admin is still in version 2 format.
  • If you get
    Error “cannot load such file — rb-inotify”
    
    • Add gem “ib-notify” to the bottom of the gemfile and run bundle install again.
  • If you get
    Error about invalid SSH keys
    
    • Keep deleting the offending keys until the errors go away.

Resources

#1

Updated by Daniel Curtis over 9 years ago

  • Status changed from New to Resolved
  • % Done changed from 10 to 100
#2

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#3

Updated by Daniel Curtis over 9 years ago

  • Status changed from Resolved to Closed
#4

Updated by Daniel Curtis about 9 years ago

  • Project changed from 98 to GNU/Linux Administration
  • Category set to Source Code Management

Also available in: Atom PDF