Changing S3 Bucket and all references

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:

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

Things I’ve tried:


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)
1 Like

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?

1 Like