I'm copying json? from two websites to try to achieve my goal
https://softwaredevelopmentstuff.com/2017/05/02/downloading-an-aws-glacier-archive-step-by-step/
https://gist.github.com/veuncent/ac21ae8131f24d3971a621fac0d95be5
This works:
#!/bin/bash
file='/home/nat/Documents/glacier_access/output.json'
if [[ -z ${AWS_ACCOUNT_ID} ]] || [[ -z ${AWS_REGION} ]] || [[ -z ${AWS_VAULT_NAME} ]]; then
echo "Please set the following environment variables: "
echo "AWS_ACCOUNT_ID"
echo "AWS_REGION"
echo "AWS_VAULT_NAME"
exit 1
fi
archive_ids=$(jq .ArchiveList[].ArchiveId < $file)
for archive_id in ${archive_ids}; do
echo "Downloading Archive: ${archive_id}"
aws glacier delete-archive --archive-id=${archive_id} --vault-name ${AWS_VAULT_NAME} --account-id ${AWS_ACCOUNT_ID} --region ${AWS_REGION}
done
as does this:
# file to loop action on archives
#!/bin/bash
file='/home/nat/Documents/glacier_access/output.json'
if [[ -z ${AWS_ACCOUNT_ID} ]] || [[ -z ${AWS_REGION} ]] || [[ -z ${AWS_VAULT_NAME} ]]; then
echo "Please set the following environment variables: "
echo "AWS_ACCOUNT_ID"
echo "AWS_REGION"
echo "AWS_VAULT_NAME"
exit 1
fi
archive_ids=$(jq .ArchiveList[].ArchiveId < $file)
for archive_id in ${archive_ids}; do
echo "Downloading Archive: ${archive_id}"
aws glacier initiate-job \
--account-id 510422384120\
--vault-name ebony-backup \
--job-parameters '{
"Type": "archive-retrieval",
"Description": "Download all my archives",
"ArchiveId": "w0GUthLDLDR6NL1z4c53M1IFktxBCrW_qZ2Qm_",
}'
done
but I cant reference the variable in the loop
so this doesnt work:
"ArchiveId": "${archive_id}"
nor this:
"ArchiveId": "{archive_id}"
An important thing to note is that the ArcihiveID MUST be referenced from inside the job parameters section.
Any help gratefully received. I'm assuming this is a JSON question?