Posts tagged with "tool" - Jay Caines-Gooby 2010-02-10T13:36:05+00:00 Jay Caines-Gooby Versioning your Amazon S3 buckets 2010-02-10T13:36:05+00:00 2010-02-10T13:39:56+00:00 <p><img src="/media/logo_aws.gif"/></p> <p>I&#8217;m sold <a href="">hook</a> <a href="">line</a> and <a href="">sinker</a> on the <span class="caps">AWS</span> platform. I&#8217;m especially impressed at the product innovation and ever-reducing prices.</p> <p>A few days ago Amazon announced <a href="">versioning for S3</a>. This means that with the versioning flag for a bucket switched on, you can retrieve earlier versions of your files. Sweet.</p> <p>Now, because I&#8217;m lazy, I tend to use <a href="">S3Fox</a> or <a href="">Cyberduck</a> for setting ACLs and creating european buckets and so on.</p> <p>Neither of these have updated yet to support the versioning flag, and the <a href=""><span class="caps">AWS</span> Console</a> doesn&#8217;t have an S3 interface, so I thought I&#8217;d get my hands dirty and find out how to do it with the <a href=""><span class="caps">REST</span> interface</a>.</p> <p>You issue a <span class="caps">PUT</span> to your bucket with the versioning querystring and the relevant <span class="caps">XML</span>:</p> <pre name="code" class="xml:nogutter"> &lt;VersioningConfiguration xmlns=""&gt; &lt;Status&gt;Enabled&lt;/Status&gt; &lt;/VersioningConfiguration&gt; </pre> <p>You can do it all with <a href="">cURL</a>, but the biggest pain is <a href="">generating the correct Authorization: header</a> to sign your <span class="caps">API</span> call.</p> <p>Enter Tim Kay&#8217;s <a href="">aws commandline tool</a> &#8211; its a swiss knife for S3 and EC2 calls. Enabling the versioning was as simple as:</p> <pre name="code" class="bash:nogutter"> aws put versioning.xml </pre> <p>Where versioning.xml contains the VersioningConfiguration xml snippet listed above.</p> <p>To check the versioning status of a bucket, you do:</p> <pre name="code" class="bash:nogutter"> aws get </pre> <p>Before you run the aws commandline, you&#8217;ll need to create an ~/.awssecret file with your <span class="caps">AWS</span> key and secret key. Don&#8217;t forget to chmod 600.</p>