
I’m sold hook line and sinker on the AWS platform. I’m especially impressed at the product innovation and ever-reducing prices.
A few days ago Amazon announced versioning for S3. This means that with the versioning flag for a bucket switched on, you can retrieve earlier versions of your files. Sweet.
Now, because I’m lazy, I tend to use S3Fox or Cyberduck for setting ACLs and creating european buckets and so on.
Neither of these have updated yet to support the versioning flag, and the AWS Console doesn’t have an S3 interface, so I thought I’d get my hands dirty and find out how to do it with the REST interface.
You issue a PUT to your bucket with the versioning querystring and the relevant XML:
<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Status>Enabled</Status> </VersioningConfiguration>
You can do it all with cURL, but the biggest pain is generating the correct Authorization: header to sign your API call.
Enter Tim Kay’s aws commandline tool – its a swiss knife for S3 and EC2 calls. Enabling the versioning was as simple as:
aws put my.bucket.com?versioning versioning.xml
Where versioning.xml contains the VersioningConfiguration xml snippet listed above.
To check the versioning status of a bucket, you do:
aws get my.bucket.com?versioning
Before you run the aws commandline, you’ll need to create an ~/.awssecret file with your AWS key and secret key. Don’t forget to chmod 600.
Comments
Versioning for already existing objects
Hey, that’s a great stuff. But I wonder if I could enable versioning for already existing objects inside versioning-enabled bucket. Do anybody know, how could it be achieved?
Worked like a charm
Thanks for the write-up. Worked like a charm. Not sure about ‘Toli’ comment – worked for existing buckets for me.
Need updated aws script
I think you skipped over some really important info here — currently Tim Kay’s aws script doesn’t support s3 versioning, so first you need to modify the script to support versioning like Miguel Landaeta has. If you don’t use a modified script, putting to
?versioningdoesn’t turn on versioning — it simply creates a new item named?versioningin your bucket.