These scripts were developed to help users restore files that have been accidentally deleted from Amazon S3.
-
Restore files from all buckets:
This script iterates through all of the files in all of the buckets in an AWS account. If the files have been deleted after a specific point in time (point_of_restore), then the script restores the files to their latest state.
-
Restore files from one specific bucket:
This script iterates through all of the files in a specific bucket in an AWS account. If the files have been deleted after a specific point in time (point_of_restore), then the script restores the files to their latest state.
- Attention! In order for this script to work, versioning must have been enabled in the Amazon S3 bucket before the files were deleted.
- Edit the chosen script to set the point_of_restore variable. This should represent the date and time of the incident. Make sure to round down, so we don't miss any files.
- If you chose the script that restores from one specific bucket, set the name of the bucket (bucket_name) as well
- If you need a list of all of the objects restored, set list_all_restored_objects to True
- If you feel more comfortable running Jupyter Notebooks, a .ipynb file has also been provided.
In order for you to run this Python 3 script, you will need a User with the permissions described in this IAM policy.
There are a few options to run this script. We describe two possibilities below. Choose the one that best fits your needs:
a. Access AWS Cloud Shell
For more information on AWS Cloud Shell: https://aws.amazon.com/cloudshell/
b. Clone this GitHub repository
git clone https://github.com/aws-samples/restore-s3-deleted-objects
c Execute the desired script. Example:
cd restore-s3-deleted-objects/
python3 revive_s3_objects_from_all_buckets.py
d. Logs will show up as the script runs
a. If you have AWS CLI configured, you may skip this. Otherwise, configure AWS CLI in a command line tool/terminal.
b. Clone this GitHub repository
git clone https://github.com/aws-samples/restore-s3-deleted-objects
c. Execute the desired script. Example:
cd restore-s3-deleted-objects/
python3 revive_s3_objects_from_all_buckets.py
d. Logs will show up as the script runs
This script executes requests made against Amazon S3 buckets and files, like GET, LIST, and PUT. Costs will vary depending on how many objects and buckets a customer is restoring. For more details on Amazon S3 pricing, take a look at Amazon S3 pricing page
This script is for information purposes only and should not be used for production workloads.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.