How to move content from one S3 bucket to another?
Jimmy Shimizu last edited by
I have ended up in a state where I had to move all content from one bucket to another. I was hoping that I would only need to change the bucket name in the settings, but that seems to only affect new uploads.
Is there an easy way to actually migrate all currently uploaded media from one bucket name to another in the DB? Or am I stuck with serialized values that will be hard to replace with a simple DB query?
jong last edited by
Do you have command line access and have WP-CLI installed?
I'll be pushing an update tomorrow that will include a command to update the bucket metadata. It won't move files or anything, just simply changed Media Cloud's metadata in the database:
wp mediacloud swapbucket <oldbucket> <newbucket>
It'll be on you to make sure everything is moved to the correct places in the new bucket.
Jimmy Shimizu last edited by Jimmy Shimizu
I could get access, I think. I'm running it with AWS Fargate which sort of limits any kind of CLI access, but I can run a local instance against the same DB to give me CLI access.
I however managed to do an s3 sync dance back and forth and end up with the same bucket name again, however I think this could be really useful in the future either way. It could also be very useful if you are restoring data from production to staging, and sync s3 buckets from production to staging as well (to avoid having to run the same bucket between environments).