Skip to content

Instantly share code, notes, and snippets.

@sammcj
Last active August 29, 2015 14:11
Show Gist options
  • Save sammcj/10820760be5e2454178c to your computer and use it in GitHub Desktop.
Save sammcj/10820760be5e2454178c to your computer and use it in GitHub Desktop.
migrate_gitlab
#!/bin/sh
# Upgrades from gitlab installed via puppet module to a new server with gitlab omnibus (installed with puppet)
#
# Assumes:
# - Databases have been copied to /var/tmp/gitlab(_ci).sql
# - Repositories are to be located at /mnt/repositories
#
# Note:
# - Ensure any hooks / scripts you have are correctly pathed, for example:
# Dont use: #!/usr/bin/env python , Instead use: #!/usr/bin/python
puppet agent --disable "upgrading gitlab"
gitlab-ctl stop
rsync -ar root@old-gitlab-server:/home/git/repositories /mnt/repositories/
rsync -ar root@old-gitlab-server:/home/git/.ssh /var/opt/gitlab
chown -R git:git /var/opt/gitlab/.ssh /var/opt/gitlab
gitlab-ctl start postgresql
# Import database
sudo -u gitlab-psql /opt/gitlab/embedded/bin/dropdb gitlabhq_production
sudo -u gitlab-psql /opt/gitlab/embedded/bin/dropdb gitlab_ci_production
sudo -u gitlab-psql /opt/gitlab/embedded/bin/createdb gitlabhq_production -O gitlab
sudo -u gitlab-psql /opt/gitlab/embedded/bin/createdb gitlab_ci_production -O gitlab_ci
sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql gitlabhq_production < /var/tmp/gitlab.sql
sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql gitlab_ci_production < /var/tmp/gitlab_ci.sql
# Remove old hooks
find /mnt/repositories -name post-receive -exec rm -f {} \;
sudo -u git /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks
gitlab-rake gitlab:satellites:create RAILS_ENV=production
gitlab-rake db:migrate
gitlab-ci-rake db:migrate
# Check the install
gitlab-ctl reconfigure
gitlab-rake gitlab:check
puppet agent --enable
puppet agent --test
gitlab-ctl start
gitlab-ctl status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment