更改 S3 存储桶及所有引用

我更改了网站的 S3 存储桶,并将所有资源复制到了新存储桶中。所有内容都保持一致,我还确保所有文件至少具有公共可读权限。

 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;

但部分 URL 和图片引用仍基于旧存储桶名称。

例如:Logo 的 URL 设置为:

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

这指向的是旧存储桶,所有引用都应更新为新存储桶名称。

我已尝试的操作:

重新烘焙(Rebake)

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

该操作成功执行,但没有任何变化。

重映射(Remap,调用失败)

Remap 功能曾被提及,但我似乎无法正确调用它。

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)

由于无人回应,我最终只好执行一些 SQL 查询来尝试修复此问题。

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

这恐怕不是完整的列表,但我更新了以下表:

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

论坛状况已大为改善,但我仍遇到一种奇怪的行为。当我访问包含图片的帖子时,图片依然显示为损坏;但当我尝试编辑该帖子时,图片、预览等一切正常。

如果我保存帖子,图片仍然显示为损坏。如果我下载图片并重新提交,图片依然损坏。

但如果我创建新帖子,则一切正常。

请问我可能遗漏了什么?