Backing up GitLab CE to Amazon S3
Dec 16, 2016

I’ve been using GitLab for several years now and it’s been great! I started around version 6.0 and have been using it ever since. GitLab supports continous integration similar to Travis CI and is pretty easy to set up. Backing up important projects is an absolute must. I’ll be using s3cmd as a cronjob for easy encrypted backups.

Backups are stored in /var/opt/gitlab/backups by default and can be configured by editing the /etc/gitlab/gitlab.rb file. Luckily, there is a simple GitLab command that backs up everything (repositories, database, wikis, etc.).

Script

#!/bin/bash
S3_BUCKET=bucket_name
BACKUP_PATH=/var/opt/gitlab/backups/

/opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
s3cmd put --encrypt --recursive --delete-removed $BACKUP_PATH s3://$S3_BUCKET/

Cron

0 0 * * * /path/to/script
Comments