12

I use the rake task to create backups for GitLab 6.8.2.

gitlab-rake gitlab:backup:create

In /etc/gitlab/gitlab.rb I added the following line:

gitlab_rails['backup_keep_time'] = 60

This is supposed to prune backups older than 60 seconds. My expectation was that a second run of gitlab:backup:create would remove the first backup if 60 seconds have passed. Though the last line in the output is

Deleting old backups ... skipping

How do I configure GitLab to actually remove old backups?

Anthony Mastrean
  • 441
  • 1
  • 6
  • 18
Jan Deinhard
  • 2,363
  • 5
  • 26
  • 33
  • can you provide a `ls -ls` in the dir with the backups and also the output of the `date` command – Mike Jul 25 '16 at 13:51
  • You possibly forgot to `gitlab-ctl reconfigure && gitlab-ctl restart` your installation? – bossi May 08 '17 at 10:29

2 Answers2

20

The option you want is gitlab_rails['backup_keep_time']. I had to

gitlab-ctl reconfigure

after setting it for it to have any effect. Note that it will only affect local backups, not Amazon-AWS S3 if you're using that.

There was an issue with them being ignored, but I'm not sure what versions it affects. Version 6 is pretty old. If you're on the omnibus, it might be worth an upgrade.

Uwe Keim
  • 2,370
  • 4
  • 29
  • 46
Tad M.
  • 301
  • 1
  • 6
  • 1
    +1 for mentioning what (most likely) was the solution (`gitlab-ctl reconfigure`) – bossi May 08 '17 at 10:49
  • 1
    Would be worth mentioning that after updating `gitlab.rb` and running `gitlab-ctl reconfigure` creating a new backup or when the next backup is run, expired backups will be removed. – Mark Carpenter Jr Nov 28 '18 at 15:29
6

Perhaps you are looking at rotating out stale files in the remote or backup_upload_connection folder. Gitlab is not able to remove stale backups from this or any other remote locations. The backup_keep_time is only for its internal backup_path which is defaulted to /var/opt/gitlab/backups.

I am planning to run a cron job separately which deletes all but 10 of the newest files in my remote, NFS mounted, backup folder.

ls -dt */ | tail -n +11 | xargs rm -rf

See this merge request: https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1453

And this diff: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5567/diffs

Note that the `backup_keep_time` configuration option only manages local
files. GitLab does not automatically prune old files stored in a third-party
object storage (e.g. AWS S3) because the user may not have permission to list
and delete files. We recommend that you configure the appropriate retention
policy for your object storage. For example, you can configure [the S3 backup
policy here as described here](http://stackoverflow.com/questions/37553070/gitlab-omnibus-delete-backup-from-amazon-s3).
instantchow
  • 161
  • 1
  • 1