Last active
November 18, 2024 19:23
-
-
Save alexpreynolds/f7a85b5f9519f3518b36ade026c383e2 to your computer and use it in GitHub Desktop.
Move list of AWS S3 objects in one bucket to a different storage class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
in_fn=${1} | |
aws_s3_bucket=${2} | |
aws_s3_dest_storage_class=${3} | |
while IFS= read -r line; do | |
aws_s3_key=$(echo "${line}" | cut -d' ' -f1) | |
aws_s3_path="s3://${aws_s3_bucket}/${aws_s3_key}" | |
echo "Moving [${aws_s3_path}] to storage class [${aws_s3_dest_storage_class}]" | |
aws s3 cp ${aws_s3_path} ${aws_s3_path} --storage-class ${aws_s3_dest_storage_class} | |
done < ${in_fn} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get a list of objects in the
STANDARD
storage class:To move
STANDARD
objects to theINTELLIGENT_TIERING
storage class: