Object storage lifecycle config not working?
Hi,
I have set an expiration policy for the bucket of 13 days. Here is what is returned by s3cmd getlifecyclepolicy
<?xml version="1.0" ?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
<ID>delete-after-14-days</ID>
<Prefix/>
<Status>Enabled</Status>
<Expiration>
<Days>13</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>
Yet objects do not seem to be being deleted as there are objects still in the bucket older than 13 days:
2021-12-04 10:42
2021-12-06 04:18
2021-12-07 04:17
2021-12-08 04:17
Am I missing something here? The documentation suggests the expiration policy should be enforced daily at midnight server time. (This bucket is in the Frankfurt region.)
Thanks.
2 Replies
You will want to enclose your <Prefix/> tag inside a <Filter> tag as it is what you are filtering on. You can also filter on object size and object "Tags".
The <filter>
tag is in the original config sent to s3cmd setlifecycle but is not present in s3cmd getlifecycle.
Setting
<LifecycleConfiguration>
<Rule>
<ID>delete-after-14-days</ID>
<Filter>
<Prefix></Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Days>14</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>
Returns
<?xml version="1.0" ?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
<ID>delete-after-14-days</ID>
<Prefix/>
<Status>Enabled</Status>
<Expiration>
<Days>14</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>
I actually tried various different ways before posting, since the Linode documentation shows <Prefix>
both without and within a <Filter>
tag. I have posted in another thread about how, after several days of not working, it started working for several days in a row and then stopping working again, without any config changes at all.