8

I would like to delete the back up files that is older than 1 week. I have followed this backup document from gitlab and successfully create the backup files to upload to Amazon S3.

I have also set up gitlab_rails['backup_keep_time'] = 604800 but it does not work.

However, from what I observe in the IAM user policy they created. There is no authorization to delete the files.

The backup files are packing up and I would not want to do this manually in AWS.

Is there any standard way to delete the backup files in Amazon S3 for gitlab omnibus package?

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1412062044000",
      "Effect": "Allow",
      "Action": [
        "s3:AbortMultipartUpload",
        "s3:GetBucketAcl",
        "s3:GetBucketLocation",
        "s3:GetObject",
        "s3:GetObjectAcl",
        "s3:ListBucketMultipartUploads",
        "s3:PutObject",
        "s3:PutObjectAcl"
      ],
      "Resource": [
        "arn:aws:s3:::my.s3.bucket/*"
      ]
    },
    {
      "Sid": "Stmt1412062097000",
      "Effect": "Allow",
      "Action": [
        "s3:GetBucketLocation",
        "s3:ListAllMyBuckets"
      ],
      "Resource": [
        "*"
      ]
    },
    {
      "Sid": "Stmt1412062128000",
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my.s3.bucket"
      ]
    }
  ]
}
Charles C.
  • 3,725
  • 4
  • 28
  • 50

3 Answers3

14

You can use S3 lifecycle policy by Following steps:

  1. Click on your S3 property and select Lifecycle tab and click Add rule.

    Step 1

  2. Click on Configure Rule.

    Step 2

  3. Check permanently delete and enter seven days(or any other number you want) and click on review.

    Step 3

  4. Enter rule name and click on "create and activate rule".

    Step 4

  5. Check your rule created successfully and enjoy.

    Step 5

Community
  • 1
  • 1
Reza Mousavi
  • 4,420
  • 5
  • 31
  • 48
1

If you are only interested in purging old backups in the s3 bucket you can achieve this directly in AWS. On the s3 bucket properties you can set up a lifecycle policy to expire files older than a specified number of days or move to glacier which is much cheaper.

oɔɯǝɹ
  • 7,219
  • 7
  • 58
  • 69
harveyd
  • 35
  • 5
0

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)...

https://docs.gitlab.com/ce/raketasks/backup_restore.html

panticz
  • 2,135
  • 25
  • 16