Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List files in Glacier with AWS CLI

I need to delete files stored in a Glacier Vault, but AWS CLI needs the object id and I can't execute the correct command to obtain this id.

Anyone knows the command to see the file id with AWS CLI?

like image 781
madrikeka Avatar asked Mar 09 '15 14:03

madrikeka


3 Answers

Use aws glacier initiate-job to obtain an inventory of an Amazon Glacier vault.

From the Amazon Glacier documentation:

The following command initiates a job to get an inventory of the vault my-vault:

aws glacier initiate-job --account-id - --vault-name my-vault --job-parameters '{"Type": "inventory-retrieval"}'

Once the job completes, you can call aws glacier get-job-output. The inventory will include the archive-id (files are called archives in Glacier).

Here is a sample output from the get-job-output documentation:

{"VaultARN":"arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault","InventoryDate":"2015-04-07T00:26:18Z","ArchiveList":[{"ArchiveId":"kKB7ymWJVpPSwhGP6ycSOAekp9ZYe_--zM_mw6k76ZFGEIWQX-ybtRDvc2VkPSDtfKmQrj0IRQLSGsNuDp-AJVlu2ccmDSyDUmZwKbwbpAdGATGDiB3hHO0bjbGehXTcApVud_wyDw","ArchiveDescription":"multipart upload test","CreationDate":"2015-04-06T22:24:34Z","Size":3145728,"SHA256TreeHash":"9628195fcdbcbbe76cdde932d4646fa7de5f219fb39823836d81f0cc0e18aa67"}]}
like image 106
John Rotenstein Avatar answered Nov 12 '22 02:11

John Rotenstein


This's ok

aws glacier initiate-job --account-id - --vault-name my-vault --job-parameters "{ \"Type\": \"inventory-retrieval\" }"
like image 24
Mr. Nhã Avatar answered Nov 12 '22 00:11

Mr. Nhã


One problem is that how the strings are quoted depending on whether you are using Linux or Mac or Powershell or Windows. See AWS doc on quoting strings

For the Windows command prompt, this works:

aws glacier initiate-job --account-id 123456789012  --vault-name myvault --job-parameters "{\"Type\": \"inventory-retrieval\"}"

For PowerShell use single quotes around the JSON but still escape the double quotes. With Linux and Mac you shouldn't need to escape the double quotes.

like image 1
InnocentBystander Avatar answered Nov 12 '22 01:11

InnocentBystander