我正试图将我的 Discourse 实例迁移到另一台服务器。
我尝试在目标服务器的管理仪表板中使用恢复选项,但一直因以下错误而失败:
[2022-04-23 21:59:00] Remapping uploads...
[2022-04-23 21:59:00] Restoring uploads, this may take a while...
[2022-04-23 21:59:00] EXCEPTION: Aws::S3::Errors::NoSuchBucket
用于现有 Discourse 实例和我要迁移到的新服务器的 app.yml 配置完全相同。
我完全无法使其正常工作,因此我决定尝试这里的指南:Restore a backup from the command line
如果我使用相同的 app.yml 配置,我遇到了同样的错误。
所以我决定注释掉所有与 S3 相关的内容,这似乎解决了问题:
Reconnecting to the database...
Reloading site settings...
Disabling outgoing emails for non-staff users...
Disabling readonly mode...
Clearing category cache...
Reloading translations...
Remapping uploads...
Remapping '//bucket.nyc3.digitaloceanspaces.com/' to '/uploads/default/'
optimized_images=480
uploads=35
user_histories=13
Remapping 'https://cdnurl.com/' to 'https://forumurl.com/uploads/default/'
post_revisions=2
posts=4
topic_links=4
Remapping 'cdnurl.com' to 'forumurl.com'
topic_links=4
Restoring uploads, this may take a while...
Posts will be rebaked by a background job in sidekiq. You will see missing images until that has completed.
You can expedite the process by manually running "rake posts:rebake_uncooked_posts"
Clearing emoji cache...
Clear theme cache
Executing the after_restore_hook...
Cleaning stuff up...
Dropping functions from the discourse_functions schema...
Removing tmp '/var/www/discourse/tmp/restores/default/2022-04-23-234852' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[SUCCESS]
Restore done.
恢复成功后,我决定取消注释所有 S3 相关内容并运行 ./launcher rebuild app。
然后我尝试访问我的 Discourse 实例,注意到所有上传的文件都丢失了(徽标、个人资料图片等)。
然后我运行:
./launcher enter app
rake posts:rebake(没有错误,显示重新烘焙了 60 多个帖子)
rake posts:rebake_uncooked_posts(显示重新烘焙了 0 个帖子)
即使这样,所有上传的文件仍然无法正常工作,并返回 404(或者在个人资料图片的情况下,显示默认的个人资料图片)。
从上面的恢复日志来看,URL 肯定被重新映射了,因为它认为 S3 不再被使用,但有没有办法在恢复完成后再次重新映射它,使其恢复到应有的状态?
或者,有没有办法让它在 app.yml 中使用 S3 设置正常工作?我不确定为什么它坚持认为存储桶不存在。
供参考,这是我的 app.yml 中 S3 配置的样子:
DISCOURSE_USE_S3: true
DISCOURSE_S3_REGION: nyc3
DISCOURSE_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
DISCOURSE_S3_ACCESS_KEY_ID: KEY
DISCOURSE_S3_SECRET_ACCESS_KEY: ACCESS_KEY
DISCOURSE_S3_CDN_URL: https://forumcdn.com
DISCOURSE_S3_BUCKET: upload-bucket
DISCOURSE_S3_BACKUP_BUCKET: backup-bucket
DISCOURSE_BACKUP_LOCATION: s3
现有 Discourse 实例和新 Discourse 实例使用的上传存储桶是相同的,所以我期望重建能够正常工作并重新映射 URL。
我不确定我在这里哪里出错了,但我希望有人能给我指明正确的方向。
谢谢。
