Skip to content

Instantly share code, notes, and snippets.

@coorasse
Last active August 6, 2018 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coorasse/d56f7392fefddb6e1accd12fdf3d4ad8 to your computer and use it in GitHub Desktop.
Save coorasse/d56f7392fefddb6e1accd12fdf3d4ad8 to your computer and use it in GitHub Desktop.
Restore glacier files from S3
fileName="$1" # File containing only S3 object key
bucketName="$2"
profileName="$3"
count=0
while read key; do
aws s3api copy-object --bucket $bucketName --copy-source "$bucketName/$key" --key "$key" --query "CopyObjectResult.{LastModified}" --profile $profile
var=$((count+1))
echo "#$count ... $key"
done < $fileName
#!/bin/sh
BUCKET="s3-bucket-name"
PREFIX="foldername"
PROFILE="awscliprofile"
# extract all glacier file names
aws s3api list-objects --bucket BUCKET --profile PROFILE --query 'Contents[?StorageClass==`GLACIER`]' > glacier.json
# extract all file keys
cat glacier.json | jq 'map(.Key)' | jq -r '.[]' > glacier_keys
#restore.sh glacier_keys $BUCKET $PROFILE
#!/bin/sh
fileName="$1" # File containing only S3 object key
bucketName="$2"
profileName="$3"
count=0
while read key; do
aws s3api restore-object --bucket $bucketName --restore-request "Days=30,GlacierJobParameters={Tier=Bulk}" --key "$key" --profile $profileName
count=$((count+1))
echo "#$count ... $key"
done < $fileName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment