如何让 GitLab 删除旧备份?

Jan*_*ard 12 backup git gitlab

我使用 rake 任务为 GitLab 6.8.2 创建备份。

gitlab-rake gitlab:backup:create
Run Code Online (Sandbox Code Playgroud)

/etc/gitlab/gitlab.rb我添加了以下行:

gitlab_rails['backup_keep_time'] = 60
Run Code Online (Sandbox Code Playgroud)

这应该修剪超过 60 秒的备份。我的期望是,gitlab:backup:create如果 60 秒过去了,第二次运行将删除第一个备份。虽然输出中的最后一行是

删除旧备份...跳过

如何配置 GitLab 以实际删除旧备份?

小智 19

您想要的选项是gitlab_rails['backup_keep_time']. 我不得不

gitlab-ctl reconfigure
Run Code Online (Sandbox Code Playgroud)

设置好后才能生效。请注意,它只会影响本地备份,如果您正在使用它,则不会影响 Amazon-AWS S3。

它们被忽略存在问题,但我不确定它会影响哪些版本。版本 6 已经很旧了。如果您乘坐的是综合巴士,则可能值得升级。

  • 值得一提的是,在更新“gitlab.rb”并运行“gitlab-ctl reconfigure”创建新备份或运行下一次备份时,过期的备份将被删除。 (2认同)

小智 6

也许您正在考虑轮换远程backup_upload_connection文件夹中的陈旧文件。Gitlab 无法从此或任何其他远程位置删除陈旧的备份。该backup_keep_time只用于其内部是backup_path被默认为/var/opt/gitlab/backups

我打算单独运行一个 cron 作业,它会删除我的远程 NFS 安装备份文件夹中除 10 个最新文件之外的所有文件。

ls -dt */ | tail -n +11 | xargs rm -rf
Run Code Online (Sandbox Code Playgroud)

请参阅此合并请求:https : //gitlab.com/gitlab-org/omnibus-gitlab/issues/1453

这个差异: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).
Run Code Online (Sandbox Code Playgroud)