Last active
August 6, 2018 10:15
-
-
Save coorasse/d56f7392fefddb6e1accd12fdf3d4ad8 to your computer and use it in GitHub Desktop.
Restore glacier files from S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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