Skip to content

How to Restore Multiple Objects using AWS CLI

0

Hi

Is there a way to initiate RESTORE of multiple Objects via AWS CLI?

Something like this in AWS Console but in CLI: Enter image description here

if possible, please share the syntax.

Thank you

asked 2 years ago541 views
1 Answer
0

Hello,

Yes, you can initiate the restore of multiple objects in an S3 bucket using the AWS CLI.

First, create a text file (objects-to-restore.txt) listing the objects you want to restore, with each object's key on a new line:

Monch01.mp4
Monch02.mp4
Monch03.mp4

Use the following shell script to initiate the restore for each object listed in the file:

BUCKET_NAME="your-bucket-name"
DAYS=7  # Number of days to keep the restored objects available

while read -r OBJECT_KEY; do
    aws s3api restore-object --bucket "$BUCKET_NAME" --key "$OBJECT_KEY" --restore-request Days=$DAYS
done < objects-to-restore.txt

This script will read each object key from the objects-to-restore.txt file and initiate the restore process using the aws s3api restore-object command.

  • Make sure you have the AWS CLI installed and configured with the necessary permissions to restore objects in your S3 bucket.
aws configure
EXPERT
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.