Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rollback to previous version in Amazon S3 bucket?

I upload folders/files by:

aws s3 cp files s3://my_bucket/
aws s3 cp folder s3://my_bucket/ --recursive

Is there a way to return/rollback to previous version?

Like git revert or something similar?

UPDATE: here the is test file that I uploaded 4 times.

How to get to previous version (make it the "Latest version")

For example make this "Jan 17, 2018 12:48:13" or "Jan 17, 2018 12:24:30" to become the "Latest version" not in gui but by using command line? enter image description here

like image 762
whitesiroi Avatar asked Jan 17 '18 03:01

whitesiroi


People also ask

Can we recover deleted S3 bucket?

All I can find is information on how to restore deleted objects within a bucket - nothing for restoring a bucket itself. Unfortunately, no there is not.

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.


1 Answers

Here is how to get that done:

If you are using cli,

https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html

Get the object with the version you want.

Then perform a put object for the downloaded object.

https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html

Your old S3 object will be the latest object now.

AWS S3 object is immutable and you can only put and delete. Rename is GET and PUT of the same object with a different name.

Hope it helps.

like image 174
Kannaiyan Avatar answered Nov 07 '22 06:11

Kannaiyan