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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With