Creating a proper backup

I set up GitLab on a VPS and want to make backups on an hourly basis. I have made a script that basically runs “sudo gitlab-backup create” and some other commands like “sudo gitlab-ctl backup-etc” and then moves the backup to another server. Testing this I created a backup, changed some data (well actually I only changed a user name) and restored the backup using “sudo gitlab-backup restore BACKUP=some-file-name”. I expected the user to be changed back to what is was before I changed it, but no.

So now I’m wondering: what is included in a backup and what is not? And what is the best way to create a backup that contains all data?

Hi, that’s documented on https://docs.gitlab.com/ce/raketasks/backup_restore.html#creating-a-backup-of-the-gitlab-system

2 Likes

Ok, so the following:

  • Database
  • Attachments
  • Git repositories data
  • CI/CD job output logs
  • CI/CD job artifacts
  • LFS objects
  • Container Registry images
  • GitLab Pages content

That I knew from looking at the backup file. This doesn’t include user accounts?

Note that that piece of documentation was changed silently(? - at least I haven’t found any mention of it) with the release of GitLab 12.2.

Until a few weeks ago when I checked that by coincidence, I didn’t know that our command for taking backups where outdated.

On topic: I don’t think it’s possible to back up the user database.

So what is the point of backing up when it can not be completely restored? Users are connected to projects in GitLab aren’t they? What happens when this connection is disturbed?

Shocking little. I recently set up a second GitLab server in the company (for specialised use, with more tight firewall rules, that would not please all the users of the old one), and for migrating projects, I described (users have to do the work themselves) a process involving exporting projects from the old server and importing them on the new. When I started testing that, I had not created every user of the project I was importing (some of them have stopped working here and won’t get an account on the new server) but everything worked, e.g. commits were attributed to the right people. I’m guessing the reason things just worked is because everything (?) is coupled to an email address, add multiple email addresses to the same user, you might see things go wrong.

(We have scripts for maintaining our user database through the API, so I’m kind of glad the backup process leaves users out.)

@vespino Great question.

Users are backed up as part of the database backup.

You should be able to restore everything, including users, as long as you are running the same version of GitLab as when the backup was taken.

The only items not included by default in the backup are your configuration and secrets files.

As @grove pointed out, there was a change to the GitLab backup rake command in 12.2. The backup rake task is a wrapper for backup:create with an additional fix to improve container registry backups.

Backup/Restore commands for newer (12.2+) and legacy (<12.2) versions were added here to close gitlab-org/gitlab-foss#65889

If you’re using Omnibus 12.2 or newer, use
gitlab-backup create

If you’re using Omnibus 12.1 or older, use
gitlab-rake gitlab:backup:create

2 Likes

I’m currently running the latest version of GitLab CE (v12.5.3) and as I pointed out, on making a backup using the command “sudo gitlab-backup create”, changing a user’s name, restoring the backup using “sudo gitlab-backup restore BACKUP=”, the user’s name was not restored as I expected. No errors were shown.

What you are saying is that what I’m doing and should it work as described?