Reputation: 71
I want to delete object after the retention date is end. Can I do it with Bucket Lifecycle? If so, how?
And the second question, is it possible to automatically delete an object if there is a newer one available?
Upvotes: 7
Views: 19356
Reputation: 2063
This will only work with a versioned bucket
Enable object lifecycle configuration on buckets to setup automatic deletion of objects after a specified number of days
or a specified date
.
Example:
Create a bucket lifecycle configuration which expires the objects under the prefix old/
on 2020-01-01T00:00:00.000Z
date and the objects under temp/
after 7 days.
Enable bucket lifecycle configuration using mc
:
{
"Rules": [{
"Expiration": {
"Date": "2020-01-01T00:00:00.000Z"
},
"ID": "OldPictures",
"Filter": {
"Prefix": "old/"
},
"Status": "Enabled"
},
{
"Expiration": {
"Days": 7
},
"ID": "TempUploads",
"Filter": {
"Prefix": "temp/"
},
"Status": "Enabled"
}
]
}
the same can be found in :https://docs.min.io/docs/minio-bucket-lifecycle-guide.html
{
"Rules": [
{
"ID": "Removing all old versions",
"Filter": {
"Prefix": "users-uploads/"
},
"NoncurrentVersionExpiration": {
"NoncurrentDays": 365
},
"Status": "Enabled"
}
]
}
Upvotes: 3