Search code examples
amazon-s3crongitlabgitlab-omnibus

Gitlab Omnibus: Delete backup from Amazon S3


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"
      ]
    }
  ]
}

Solution

  • 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