Skip to content

Instantly share code, notes, and snippets.

@simonespa
Created August 4, 2023 11:06
Show Gist options
  • Select an option

  • Save simonespa/44c37df4e18bdacefe8747e870eccf1d to your computer and use it in GitHub Desktop.

Select an option

Save simonespa/44c37df4e18bdacefe8747e870eccf1d to your computer and use it in GitHub Desktop.
Download S3 versions
aws s3api list-object-versions --bucket ${BUCKET} --prefix ${FILE} --max-items ${MAX_ITEM} --no-cli-pager > versions
cat versions | jq -r '.Versions[].VersionId' > versionids
cat versions | jq -r '.Versions[] | "\(.LastModified) \(.VersionId)"' > lastmodified_versionids
aws s3api get-object --bucket ${BUCKET} --key ${FILE} --version-id ${VERSION_ID}
let "index = 1"
while read version
do
echo "${index}) downloading version ${version}"
aws s3api get-object --no-cli-pager --bucket ${BUCKET} --key ${FILE} --version-id "${version}" ./catalogue-"${index}.json"
let "index += 1"
done < versionids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment