Does Contabo Object Storage Support Lifecycle Policies?

Does Contabo Object Storage support lifecycle policies?

Contabo's S3 Object Storage supports S3 lifecycle policies that allow you to automatically delete objects after a set amount of time. This might be useful for pruning old backups or log files. 


Be careful setting up lifecycle policies. They apply to all objects inside a bucket, irreversibly deleting them if configured so.


How can I setup lifecycle polices with Contabo's Object Storage?

Lifecycle policies can be set through aws cli. Make sure to have it set up with your account before you begin. 


First, you'll need to define the policy as a json file. Here is an example how to delete all files inside a buckup after one year: 


{
"Rules": [
{
"ID": "DeleteAll365",
"Status": "Enabled",
"Prefix": "",
"Expiration": {
"Days": 365
}
}
]
}

To adjust this snippet to your needs and save it as lifecycle-policy.json on your local machine. Then apply to  a bucket with aws cli like this:


aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api put-bucket-lifecycle-configuration --bucket test --lifecycle-configuration file://lifecycle-policy.json

Replace the profile and endpoint with your object storage and replace test with the actual bucket name.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

Modified on 25 Mar 2024

Can’t find what you’re looking for?

Get in Touch

Do you have a pre-sales question?