Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulk glacier restore #11

Open
Tjkent88 opened this issue Jun 20, 2023 · 0 comments
Open

bulk glacier restore #11

Tjkent88 opened this issue Jun 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Tjkent88
Copy link

Tjkent88 commented Jun 20, 2023

ref: https://github.com/geerlingguy/my-backup-plan#retriving-content-from-s3-glacier-deep-archive

You can't just download files from Glacier directly, the trick is to move it to S3 first. Once there, you can start to download all of your files.

Step 1: Create a list of all items that you would like to be restored. I included the prefix option if you want specific folders, but if you are trying to restore a whole bucket it is not necessary.

aws s3api list-objects-v2 --bucket <insert-bucket-name-here> --prefix <only use this if you are interested in a specific folder> --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | awk '{print $2}' > glacier-restore.txt

Step 2: Run this command to start pulling all of the files from "Deep Archive" to S3. If you have time, you can sub "Bulk" for "Standard" but its not that much difference in cost so I go with standard.

for x in `cat glacier-restore.txt`; do aws s3api restore-object --bucket si-dp-prod --key $x --restore-request '{"Days":90,"GlacierJobParameters":{"Tier":"Standard"}}'; done

Unfortunately, the above command will only do one file at a time, but we have hardware and want to save some time. The following command will spread this on all minus one available cores.

cat glacier-restore.txt | xargs -n $(($(nproc --all)-1)) -P $(($(nproc --all)-1)) sh -c 'for x in "$@"; do aws s3api restore-object --bucket si-dp-prod --key "$x" --restore-request "{\"Days\":90,\"GlacierJobParameters\":{\"Tier\":\"Standard\"}}"; echo "Done restoring $x"; done' sh

Once all files have finished the retrieval process, I would suggest running through Steps 1 and 2 again, I found that sometimes it would skip entries but I never did figure out why.

@geerlingguy geerlingguy added the enhancement New feature or request label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants