Skip to content

Instantly share code, notes, and snippets.

@alastairhm
Created September 7, 2018 13:47
Show Gist options
  • Save alastairhm/f177aa1b6814fdf89a949d5130729b9c to your computer and use it in GitHub Desktop.
Save alastairhm/f177aa1b6814fdf89a949d5130729b9c to your computer and use it in GitHub Desktop.
Restore S3 objects which have been moved to glacier storage.
export MYBUCKET=mybucket
export MYDIR=mydir/1/
aws s3 ls s3://$MYBUCKET/$MYDIR/ | awk '{if ($4) print $4}' > myFiles.txt
for x in `cat myFiles.txt`
do
echo "restoring $x"
aws s3api restore-object \
--bucket $MYBUCKET \
--key "${MYDIR}/$x" \
--restore-request '{"Days":7}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment