Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete or purge old files on S3?

Are there existing solutions to delete any files older than x days?

like image 743
Erik Avatar asked Jan 24 '12 09:01

Erik


2 Answers

Amazon has introduced object expiration recently.

Amazon S3 Announces Object Expiration

Amazon S3 announced a new feature, Object Expiration that allows you to schedule the deletion of your objects after a pre-defined time period. Using Object Expiration to schedule periodic removal of objects eliminates the need for you to identify objects for deletion and submit delete requests to Amazon S3.

You can define Object Expiration rules for a set of objects in your bucket. Each Object Expiration rule allows you to specify a prefix and an expiration period in days. The prefix field (e.g. logs/) identifies the object(s) subject to the expiration rule, and the expiration period specifies the number of days from creation date (i.e. age) after which object(s) should be removed. Once the objects are past their expiration date, they will be queued for deletion. You will not be billed for storage for objects on or after their expiration date.

like image 175
Ravi Bhatt Avatar answered Sep 28 '22 06:09

Ravi Bhatt


Here is some info on how to do it...

http://docs.amazonwebservices.com/AmazonS3/latest/dev/ObjectExpiration.html

Hope this helps.

like image 24
JonLovett Avatar answered Sep 28 '22 05:09

JonLovett