19

I'm currently working on migrating the file backup system for my office to Amazon S3. The basic backup is working like a charm but I'm looking to make it a little more robust. Specifically I am looking to add version control for the files in the bucket (using Amazon "Versioning") but there is no mention (that I can find) of a way to limit the number of old versions stashed per file (ie: "File x" has a maximum of 5 previous versions at any given time).

Is it possible to place limits on the number of versions stored per file? Or am I stuck with an unlimited propagation of file versions over time if I go this route?

I've been digging through the AWS forums (as well as anywhere else I look) and have yet to find anything. Any info would be greatly appreciated. Thanks!

user3606089
  • 193
  • 1
  • 1
  • 4

2 Answers2

38

While I don't believe Amazon added the option to limit the versions to a specific count of revisions (say "5" previous revisions), you can certainly use S3 lifecycle management, which does support rules based on time. You can use NoncurrentVersionTransition to transition the old version to a different storage class, and you can use NoncurrentVersionExpiration to finally delete an old revision.

So if you backup your data at a predefined time interval (say once a week), then if you set your NoncurrentVersionExpiration to 6 weeks, you'll only keep the last 5 (maybe 6?) versions.

Reference: AWS S3 Lifecycle

Bernie Habermeier
  • 2,352
  • 2
  • 19
  • 19
  • Example lifecycle rule: Removing Expired Object Delete Markers https://docs.aws.amazon.com/AmazonS3/latest/dev/lifecycle-configuration-examples.html#lifecycle-config-conceptual-ex7 – edzillion Jul 23 '18 at 13:39
  • 1
    If you're looking for a walkthrough of how to do it via the online console: https://darktraining.com/2017/12/23/S3-version-cleanup/ – FirstDivision Mar 15 '19 at 17:29
3

Currently you would need to list and erase old versions manually, as there is no user defined version limit.

Julio Faerman
  • 12,021
  • 9
  • 52
  • 72