Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting specific version of file from S3 bucket

I have a file in a S3 bucket with versioning turned on. Using the aws-cli is there a way to copy a specific version of this file, rather than the latest version?

like image 639
masterforker Avatar asked Jul 26 '16 20:07

masterforker


People also ask

Does S3 have version control?

Versioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. You can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.

Can S3 bucket store multiple versions of same file?

You can use S3 Versioning to keep multiple versions of an object in one bucket and enable you to restore objects that are accidentally deleted or overwritten. For example, if you delete an object, instead of removing it permanently, Amazon S3 inserts a delete marker, which becomes the current object version.

How do I extract files from S3 bucket?

In the Amazon S3 console, choose your S3 bucket, choose the file that you want to open or download, choose Actions, and then choose Open or Download. If you are downloading an object, specify where you want to save it.

Is S3 versioning incremental?

Versioning in AWS S3 can be described simply as keeping incremental copies of the same file as you make modifications. In S3 versioning stores, all versions of an object and including all write even if you delete an object.


1 Answers

Yes you can do that see this example you will need the version ID for the object.

aws s3api get-object --bucket mybucket --key file1.txt --version-id Mj1.PcWG8e.C._7LhvFU131pXJ98abIl foo.txt

Also you can list the version for getting the version ID using this commands.

aws s3api list-object-versions --bucket mybucket
like image 170
error2007s Avatar answered Sep 22 '22 15:09

error2007s