Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hfreire/89a2bd48b683a8078549fec908b31efc to your computer and use it in GitHub Desktop.
Save hfreire/89a2bd48b683a8078549fec908b31efc to your computer and use it in GitHub Desktop.
Upload/download to/from AWS Glacier using aws-cli
# create a vault
aws glacier create-vault --account-id - --vault-name my-vault-name
# check that the vault was created successfully
aws glacier describe-vault --account-id - --vault-name my-vault-name
# upload a file to the vault
aws glacier upload-archive --vault-name my-vault-name --account-id - --archive-description "my-archive-description" --body my-text-file.txt
# request an inventory of the vault
aws glacier initiate-job --account-id - --vault my-vault-name --job-parameters '{ "Type": "inventory-retrieval" }'
# get a list of the current jobs
aws glacier list-jobs --account-id - --vault-name my-vault-name
# get inventory result
aws glacier get-job-output --account-id - --vault-name my-vault-name --job-id my-job-id inventory.json
# request a file download from the vault
cat << EOF | tee request.json
{
"Type": "archive-retrieval",
"ArchiveId": my-archive-id,
"Description": "my-archive-description",
"SNSTopic":"my-sns-topic"
}
EOF
aws glacier initiate-job --account-id - --vault-name my-vault-name --job-parameters file://request.json
# download file
aws glacier get-job-output --account-id - --vault-name my-vault-name --job-id my-job-id my-text-file.txt
@akaihen
Copy link

akaihen commented Nov 16, 2018

Hi, I followed your codes and found that I have some problem downloading files.
When I execute the command
aws glacier initiate-job --account-id - --vault-name --job-parameters file://request.json
I've had an error message which is
Error parsing parameter '--job-parameters': Unable to load paramfile file://request.json: [Errno 2] No such file or directory: 'request.json'
Can you please tell me how to solve this problem?

@akaihen
Copy link

akaihen commented Nov 16, 2018

When I execute the command
aws glacier initiate-job --account-id - --vault sandbox --job-parameters '{ "Type": "inventory-retrieval" }'
I also got this error message

Unknown options: inventory-retrieval, }', Type:

Do you have same issue like this before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment