#!/bin/bash # This script initiates restoration requests for objects listed in a specified file. # It requires the bucket name, file name, and the number of days for the restoration. # Example usage: # ./restore-glacier-objects.sh my-bucket object-list.txt 3 # (Initiates restoration for objects listed in 'object-list.txt' in 'my-bucket' for 3 days) # Check the number of arguments if [[ $# -ne 3 ]]; then echo "Usage: $0 " exit 1 fi # Retrieve arguments BUCKET="$1" FILE="$2" DAYS="$3" # Check if the file exists if [[ ! -f "$FILE" ]]; then echo "Error: The file '$FILE' does not exist." exit 1 fi # Iterate through the file and initiate restoration requests while read -r KEY; do aws s3api restore-object --restore-request Days=$DAYS --bucket $BUCKET --key "$KEY" done < "$FILE" echo "Restoration requests initiated for objects listed in '$FILE'."