How do I make GitLab delete old backups?
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?
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.
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).