How to restore gitlab from backup

Updated 14 June 2017

Gitlab is a tool for managing git repositories on a centralized server. Sometimes due to some reasons system crashes and we lose our valuable data. Therefore it is necessary to take regular backups of the gitlab server. So in case of any emergency we should be able to restore gitlab server with the backup data as soon as possible. In this tutorial I will show you how to restore a gitlab server from gitlab backup.

Before restoring gitlab you must consider the following points.

  • Gitlab backup directory is /var/opt/gitlab/backups . You must put your gitlab backup files in this directory.
  • Gitlab backup file format should be “timestamp_gitlab_backup.tar”
  • Example of valid gitlab backup file name is  “1468787928_gitlab_backup.tar”. where 1468787928 is the timestamp.
  • Owner of the backup file should be git.
  • You should restore the backup to the proper version of gitlab. If you have taken the backup from gitlab version 7.7.2, you should use the backup in version 7.7.2. You should not try to restore the backup in other versions.

Restoring gitlab from backup

Put your backup file in /var/opt/gitlab/backups/ and change the ownership to git. To change the ownership, run the following command.


I have already put the back up file in /var/opt/gitlab/backups/

To restore a gitlab back up, run the following command.


Sometimes you can get this error. To resolve this error you must increase the RAM of your system and try again.

At last it will ask for rebuild an authorized_keys file. Select “no”.

Now, you have successfully restored your gitlab from the backup.

Suppose your backup filename is backup.tar. In this case you can not restore your data. Don’t worry, you have to only change the name to proper format. All you have to do is to get the exact timestamp of backup file.

Extract your backup file and read the backup_information.yml file.

backup_information.yml file is generally contains the following.


Now, you know when the backup was created. You need to generate the timestamp from these details.You need to focus the line backup_created_at. For generating timestamp go to http://www.timestampgenerator.com/

Enter all the details.

After you click on generate, it will show you the timestamp of the backup file.In my case the timestamp is 1468701528.

So I should rename my file to 1468701528_gitlab_backup.tar


Now, the name is in proper format. You can able to restore your gitlab from the backup.

If you have any doubts regarding restoration of gitlab backup, you can ask me in the comment.

IN CASE OF ANY QUERY,CONTACT US

Tag(s) Backup gitlab
Category(s) Uncategorized
author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project






    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home