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 certain amount of time. This can be useful for pruning old backups or log files.


Be careful when setting up lifecycle policies. They apply to all objects in a bucket and will irreversibly delete them if configured to do 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 that deletes all files within a bucket after one year:


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

Customize this snippet and save it as lifecycle-policy.json on your local machine. Then apply it 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 at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

Modified on Mon, 23 Sep at 12:10 PM

Can’t find what you’re looking for?

Get in Touch

Do you have a pre-sales question?