Skip to content

Backup and Restore Omnibus Gitlab to older version

Gitlab Community Edition is great. It provides a Github like interface, but completely free and you can run it on your own servers.

Doing backups is simple enough, as are restores. The only part that is problematic is that a backup can only be restored to the exact same version of Gitlab from which the backup was made.

In my case, I’d had a Gitlab install that I’d borked, and didn’t attempt a restore for over a month. I did a fresh Omnibus install, which at the time installed Gitlab version 9.4.0. The problem is that my backup was from version 9.2.5.

The solution was to remove the current Gitlab install with apt purge gitlab-ce. Then running apt-cache madison gitlab-ce gives you a list of available versions of the gitlab-ce package. At that point I installed Gitlab 9.2.5 with apt install gitlab-ce=9.2.5-ce.0.

Then, following the instructions, and assuming you’ve copied your backup to /var/opt/gitlab/backups/ :

gitlab-ctl reconfigure
gitlab-ctl stop sidekiq
gitlab-ctl stop unicorn
gitlab-ctl status # Should show the above two services as "down"

# Do the actual restore (use the appropriate backup filename, obviously)
# Note - the BACKUP parameter is the backup filename without the trailing "_gitlab_backup.tar" string - this is appended by the gitlab-rake task automatically
gitlab-rake gitlab:backup:restore BACKUP=1497288240_2017_06_12_9.2.5

It will then ask you if you want to remove all tables, and assuming this is a brand-new install, it’s safe to answer yes.
After restoring your repositories, it will ask you if you want to rebuild the authorized_keys file. Assuming you don’t want all your users to have to re-add their keys, answer yes.

And Presto! You’re Gitlab instance should be back up and running with your users and their keys restored. If you get a 502 error when you go to your instance, depending on your servers resources, it can take a couple minutes for it to get fully up and running again.

At this point you should be able to do apt update && apt upgrade to get to the newest Gitlab version.

Spread The Love, Share Our Article

  • Delicious
  • Digg
  • Newsvine
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter

Related Posts


  1. thankful_gitlab_user November 7, 2018

    thanks so much for this, saved my day!


There are no trackbacks on this entry.

Add a Comment