Search code examples
amazon-web-servicesaws-cliamazon-glacier

retrieving archive from glacier using aws cli


Im looking for a way to retrieve archive from glacier, and ended up with below error. couldnt get an idea about "Range is not megabyte aligned" error i'm getting.

#aws glacier initiate-job --account-id - --vault-name first-vault --job-parameters file://job-archive-retrieval_1.json
A client error (InvalidParameterValueException) occurred when calling the InitiateJob operation: Invalid range RetrievalByteRange [0, 536870912] Range is not megabyte aligned


cat job-archive-retrieval_1.json
{
        "Type": "archive-retrieval",
        "ArchiveId": "XXXXXX",
        "Description": "Retrieve archive on 2016-08-09 Part 1",
        "RetrievalByteRange": "0-536870912"
}

cat job-archive-retrieval_2.json
{
        "Type": "archive-retrieval",
        "ArchiveId": "XXXXXX",
        "Description": "Retrieve archive on 2016-08-09 Part 2",
        "RetrievalByteRange": "536870913-1073741823"
}

Any help ?

What I'm trying to do is, to download 1GB test file from Glacier vault, as 2 chunks (512MB) each in 2 jobs, and combine the file into one. Couldn't figure out how to specify the size aligned with MB. This is a testing scenario, and cost doesn't matter.


Solution

  • If you choose to provide retrieval byte parameter, it must be in the form StartByte-EndByte. The value provided for StartByte must be megabyte aligned (a multiple of 1,048,576). The value provided for EndByte + 1 must be megabyte aligned if you are retrieving data from somewhere within the archive. If you want to retrieve data from StartByte up to the end of the archive, simply specify a value that is one less than the archive size.

    So I guess 0-536870912 should be 0-536870911 and 536870913-1073741823 should be 536870912-1073741823.