Use S3 Object Life Cycle to Automatically Migrate Files to Amazon Glacier, or Delete Files Based on Date

by Steve

AWS recently announced Object life Cycle support for S3, which enables automated actions to be performed on objects based on a date or based on a time interval having elapsed. There are currently two actions available:

  • Delete the objects (files)
  • Move the object to low-cost Amazon Glacier storage

To automatically delete files specify a number of days or a specific date and the objects will be deleted after the specified time.

The migrate files to Glacier option moves the object to the AWS Glacier system for archiving using cheaper storage. Files are moved to Glacier after the specified number of days have elapsed or a specific date is reached.

Object life cycle support is based on the object prefix, better known as the folder path.

A bucket may contain folder paths with different rules. For example your BACKUP bucket might contain a sqldb/backup folder path and a sqldb/logs path. The sqldb/backup path could have a rule to move the objects to Glacier after 10 days and delete the objects after 365 days. The sqldb/logs folder may have a rule to simply delete the logs after 60 days.

There are three key things to know about the Object Life Cycle Migrate to Glacier option:

  • It’s cheaper. As of this writing, standard S3 pricing starts at $0.095 per GB. Glacier costs $0.010 per GB, nearly an order of magnitude cheaper.
  • It takes time to get the files back to S3, about three to five hours after you “initiate recovery”.
  • Object Life Cycle (both Glacier migration and automatic delete) is currently incompatible with S3 Versioning. You can’t do both.

Other things to be aware of:

When you tell S3 to migrate files to Glacier the only way to access them is through S3. There is no vault support and you cannot use other Glacier tools to access your files. You don’t sign up for Glacier and you don’t get a separate bill for Glacier. S3 just takes care of it and your S3 bill goes down.

When displaying files in S3 that have been moved to Glacier there will be an indication that the file is in Glacier. To access a file in Glacier you must use an S3 request to recover the file(s) . In FileZoomer you right-click and “Initiate Recovery”. File recovery takes 3-5 hours. Once a file is recovered it is available for a limited time. In FileZoomer you specify the number of days to keep it available. To make the recovery permanent you must copy the recovered file to another file in the S3 bucket. If you don’t the recovered file will be moved back to Glacier.

Configuring Object Life Cycle

  • Navigate to the bucket and folder path for which you want to create a life cycle rule.
  • Select the file drop down menu and then select the Object Life Cycle menu option.
The Object Life Cycle Configuration display will appear.

The display will show the current bucket and the current folder path in the bucket. It will also show the life cycle rules for the current bucket

Save Rules saves the displayed rules for the current bucket. If any rules are added or deleted you must use the Save Rules button to finalize the changes.

To delete a rule select the rule and Delete Selected Rule. When you confirm with Ok the rule will be removed from the rule display but it has not been removed from the bucket. Use Save Rules to apply the displayed rules to the bucket.

Use Add Rule to create a new rule.

The Add Rule dialog will appear. Verify the bucket and path displayed are the bucket and path to which you want to apply the rule.

Name the rule using Rule ID. Use a meaningful description.

Check “Use Transition Rule” to migrate files to Glacier. Check “Use Expiration Rule” to automatically delete files. You can do both. For instance you could migrate files to Glacier after 90 days and then have them deleted automatically after 365 days.

Set the number of days after file upload to apply the transition and/or expiration rules.

You can also specify a date in the future when the migration or deletion will occur. The date must be in the format yyyy-mm-dd.

Add Rule To List saves the new rule..

Leave a Comment

Previous post:

Next post: