Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
      ]
    }
  ]
}
like image 501
Charles C. Avatar asked May 31 '16 18:05

Charles C.


2 Answers

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

like image 78
Reza Mousavi Avatar answered Oct 25 '22 05:10

Reza Mousavi


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.

like image 25
harveyd Avatar answered Oct 25 '22 04:10

harveyd