I have an AWS s3 bucket with a lifecycle attached to it. The lifecycle has moved all the files into Deep glacier.
Now I want to restore all of them. Unfortunately in the GUI (s3 console) I cannot select the entire bucket or parent folder and simple click "init restore". I can only select files individually which is very tedious.
Therefore I thought about using aws cli.
I figured out the command to list all Deep Archive files already:
aws s3api list-objects-v2 --bucket my-backup-bucket --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text
However, I would need a command to init restore on all the files listed by the command above. Any idea how to do that?
(there are many related questions, but I didn't find one matching my exact setup using aws cli)
Update
Meanwhile I found the commands to iterate over all files:
# use awk to select filepath ("key") from output:
aws s3api list-objects-v2 \
--bucket my-backup-bucket \
--query "Contents[?StorageClass=='DEEP_ARCHIVE']" \
--output text | awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > backup_filelist.txt
# run init restore command on every file individually:
while read filename; do
aws s3api restore-object \
--bucket my-backup-nas
--key $filename \
--restore-request '{"Days":25,"GlacierJobParameters":{"Tier":"Standard"}}' ;
done < backup_filelist.txt
I'll update this answer, in case everything is working correctly...
** UPDATE **
Everything working correctly -> case closed!