Backing up GitLab on OpenStack

When I walk in a new customer, is not just about OpenStack, but also help them automating their internal processes, usually with Ansible. As soon as I have OpenStack up&running, the first thing I do is deploy an internal Gitlab.

I use git to keep track of the changes and the stable releases of the Ansible scripts I use to customize OpenStack images after provisioning.

Backing up Gitlab is very critical, as it holds many hours of my job. As I’m an OpenStack maniac, I find very handy to use Swift as a backup area. It is technically possibile to backup Gitlab on Swift, but in my opinion poorly documented. Here’s a quick howto I decided to share.

In Gitlab configuration file /etc/gitlab/gitlab.rb add OpenStack as follows:

gitlab_rails['backup_keep_time'] = 604800

gitlab_rails['backup_upload_connection'] = {
'provider' => 'OpenStack',
'openstack_auth_url' => 'http://keystone.openstack:5000/v2.0/tokens',
'openstack_username' => 'admin',
'openstack_api_key' => 'admin',
'openstack_tenant' => 'admin'
gitlab_rails['backup_upload_remote_directory'] = 'gitlab'

Note that the keystone endpoint (auth uri) MUST include the version 2.0 and MUST end with “tokens”, otherwise the fog component will fail (the ruby library used by Gitlab). As openstack_api_key specify your keystone password. If your OpenStack installation has  multiple regions, you need to add the following to the previous:

'openstack_region' => 'region-two'

Now that the file editing is done, you have to refresh the Gitlab configuration with:

sudo gitlab-ctl reconfigure

You can test if the backup is working by using the Gitlab backup command with the following command:

gitlab-rake gitlab:backup:create

In my setups, ansible files aren’t changed that much once done. I usually create a script in /etc/cron.weekly/ to backup the files every week.

Et voila’, bon appetit 🙂

%d bloggers like this: