Page 1 of 1

Amazon S3 bucket migration

Posted: Tue Oct 13, 2020 10:31 am
by jar
Hi,

We use amazon S3 to store all documents and images used by Cyclos.
First, we used one bucket to store all images in one region. Then, we decided to create another bucket in another region and setup cyclos to use this new bucket for all images. We had no problem with this configuration. Works fine. But it only stores the new images in the new bucket.
We want to copy images from the first bucket to the second one and change the links of images from the first bucket to the new bucket. Is this possible? If yes, how can we do it?

Re: Amazon S3 bucket migration

Posted: Wed Oct 14, 2020 1:40 pm
by andres
Hi,

You should first move/copy the files to the new bucket (without changing the file names) using the AWS console.

Later, you need to update the stored_files table to point to the new bucket. Suppose the old bucket name is: old_bucket and the new one is new_bucket, then you can run the following SQL statement:

Code: Select all

UPDATE stored_files SET metadata = replace(metadata, 'old_bucket/', 'new_bucket/') 
WHERE position('old_bucket/' in metadata) > 0;
Regards.

Re: Amazon S3 bucket migration

Posted: Wed Oct 14, 2020 4:57 pm
by jar
Thanks!