Rewriting paths during S3 bucket to local syncing through AWS Command Line Interface

46 Views Asked by At

I regularly need to sync a WordPress uploads directory from a S3 bucket towards a dev/local server.

On the S3 bucket, the uploads have a /version/ intermediate folder on top of the standard:

/wp-content/uploads/20**/**/file.* uploads folder architecture, so that it looks like

/uploads/20**/**/{version}/file.*

I know I can sync S3 to local with the AWS CLI following command: "aws s3 sync s3://your-bucket-name my-local-dir". But is there a way to sync the data while removing the {version}/ part during de process?

Thanks!

1

There are 1 best solutions below

0
A. Kendall On

There's no way to do this via AWS CLI alone. You would need to develop a script to run after the s3 sync command finishes to move the files to a new directory and then deletes the old directories.