Automate Gitlab Backups Within Amazon S3 Bucket

Every day data keeps adding to your GitLab application’s production server and all is working fine. But you don’t realize that your server can crash due to a lot of reasons and sometimes by the time you realize all your data is lost. So, taking backup of your applications is as important as adding new features to them and it should be a part of maintaining your application.

Manually taking repeatedly backups sometimes becomes too boring. So, automating the whole process of taking the backup of your GitLab repositories is a good idea. But the smart approach is to keep your backup archive in Amazon S3 bucket rather than gitlab server itself or in any other local repository server because if server crashes then your backups are lost too.

Creating Gitlab Backup :

A backup creates an archive file that contains the database, all repositories and all attachments. The filename will be [TIMESTAMP]_gitlab_backup.tar . To create backup use the following command if you’ve installed GitLab with the Omnibus package :-

Backup archive location :-

Upload backups to cloud storage ( Amazon S3 bucket) :

For omnibus packages, make the following entries in /etc/gitlab/gitlab.rb file :-

Next step is to reconfigure your gitlab after making these changes. Run the following command :-

Setup Cron :-

Lets setup a cron job to create gitlab backup at 5 am everyday :-

Once you are done with the above mentioned gitlab configuration, this cron job will simply create a backup of your gitlab everyday at 5AM and sync that backup to your cloud storage location i.e. Amazon S3 bucket specified in gitlab.rb file. Therefore, you don’t have to bother about manually taking everyday backups and maintain a local repo server for storing those backups. Hope this helps !


Category(s) Uncategorized
. . .


Add Your Comment

Be the first to comment.