How do I move my s3 upload bucket from one provider to another?

I have setup my upload bucket originally on AWS, but I want to now use Linode. Setup went well and I can see that images are being uploaded to the Linode already.

However, when I look at the old posts, they are still pointing to AWS. How can I move those images to Linode so that I can remove the bucket on AWS?

Thanks!

First sync the buckets using a software that can do it (aws cli, s3cmd, etc) and then do a Replace a string in all posts

2 Likes

I’ve just run this

rake posts:remap["https://royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com/","https://royaleapi-discuss-upload.ap-south-1.linodeobjects.com/"]

but it says 0 posts remapped

Even though I can see that that the URL is correct, e.g. by looking at the image URL here:

1 Like

Try

rake posts:remap["//royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com/","//royaleapi-discuss-upload.ap-south-1.linodeobjects.com/"]
2 Likes

Tried your suggestion. Also tried

rake posts:remap["royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com","royaleapi-discuss-upload.ap-south-1.linodeobjects.com"]

Got the same result:

Remapping

0 posts remapped!

Is there a different command to find all posts that don’t do any replacing to see if the command can actually find valid hits?

You want to inspect the Upload objects:

cd /var/discourse
./launcher enter app
rails c
Upload.order(Arel.sql('RANDOM()')).limit(10).pluck(:id, :url)
1 Like

Excellent question and advice. Should be a #howto ?

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.