S3 Bucket wijzigen en alle verwijzingen

AI-generated summary

Samir_Faci changed the S3 bucket for their website and copied assets to the new bucket, but some URLs still reference the old bucket name. They attempted to fix this using rake posts:rebake and rake posts:remap, but the latter failed due to incorrect syntax. As a workaround, they manually updated several database tables via SQL, including uploads, badges, optimized_images, and others. Despite these changes, images in existing posts remain broken, though they appear correctly when editing. The issue persists even after re-uploading images, but new posts work fine. Samir_Faci seeks help to resolve this persistent problem.

I changed the S3 bucket for my website and copied all the assets to the new one. Everything is the same, I also made sure that all the files are publically readable at the very least

 for i in $(cat files.txt | awk '{print $4}'); do  aws --profile gb_root  s3api put-object-acl --bucket gb-www-forum  --key $i --acl public-read ; done;

Some of the URLs and Images that it’s referencing are still based on the old bucket name.

For example: the Logo URL is set to:

https://geek-beacon-www-forum.s3.dualstack.us-west-1.amazonaws.com/original/2X/8/8d0ac51fff56cdc704af2807c1c2efee13a3fd89.png

that was an old bucket that should all be referencing the new bucket name.

Things I’ve tried:

Rebake

cd /var/discourse
./launcher enter app
rake posts:rebake

That work successfully but didn’t change anything.

Remap (Failed to Invoke)

Remap was mentioned but can’t seem to figure out how to make this work.

root@forum-app:/var/www/discourse# rake --tasks  | grep remap
rake posts:remap[find,replace,type,ignore_case]                        # Remap all posts matching specific string
root@forum-app:/var/www/discourse# rake posts:remap["geek-beacon-www-forum", "gb-www-forum", "string",  false]
rake aborted!
Don't know how to build task 'posts:remap[geek-beacon-www-forum,' (See the list of available tasks with `rake --tasks`)
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

Since nobody has answered, I ended up just doing some SQL queries to try to fix this.

sudo ./launcher enter app
sudo -u postgres psql discourse

This is probably not a completely list but I update the following tables:

  • uploads
  • badges
  • optimized_images
  • post_custom_fields
  • post_revisions
  • posts
  • stylesheet_cache

the forum is in much better shape, but i’m still getting a peculiar behavior. When I go to a post that had a photo, I see that the image is still broken, but when I try to edit the post it shows the image and preview and everything is good.

If I save the post, it’s still broken. If I download the image, and re-submit the image, it’s still broken.

If I create a new post then it all works fine.

Any ideas on what I’ve missed?