After backup restore on other server, uploaded images are broken

Hello guys!

I have 2 instances of the same forum: an old one hosted in DigitalOcean, and a new one hosted on our company server and accessible only on our company intranet. I am original admin of the old forum only.

The backup of 1st forum has been restored to the new one, everything worked fine except user uploaded images in posts. They are all broken.

As you can see in this snapshot where I edit a post with a broken image, the image does appear in the preview and the url seems to be relative, so I assume it points to the picture hosted on the new intranet server.

But the link on the rendered post is absolute and refers to the old forum (inaccessible from our intranet):
https://www.oldforum.com/uploads/default/original/1X/be73346d397d355ee1e03e817a2beecfac28bad3.png

It should point to https://www.newforum.com/uploads/...

What can I do to solve this issue? :worried:

PS: I’m far from a specialist, I somehow managed to set up my first discourse instance following the great step-by-step guides available out there…

Thanks!

Is the domain in your app.yml correctly set for the new forum?

(I boot up new test instances on DO all the time and occasionally forget about this, worth checking :slight_smile: )

I’ll ask for my fellow admin to check this, sure worth it! :thumbsup:

I’ve found out that I can simply force an absolute path for the image by editing the url to the newer domain. But doing this for each uploaded picture is quite a challenge ^^

RAILS_ENV=production script/discourse remap old_hostname new_hostname

will do the trick.

./launcher enter app
gem install thor
RAILS_ENV=production discourse remap old_hostname new_hostname
rake posts:rebake

Did the trick. I wrote the complete list of commands for newbies like me who might run into the same problem.

Thanks! :wink:

ホスト名に subdomain.domain.ext という形式を使用しようとすると、以下のようになります。

./launcher enter app
gem install thor
RAILS_ENV=production discourse remap old_hostname new_hostname
rake posts:rebake

すると、以下のような結果になります。

discourse.old_domain.org のすべての出現箇所を discourse.new_domain.org に書き換え中
このタスクはデータを書き換えます。確実に入力してください (YES と入力)
YES
警告: oid 19 の型 "name" に対する型キャストが定義されていません。今後の変更に対して安全にするには、この型を明示的に TEXT にキャストしてください。
完了

もしかして、このコマンドはフラグや変数を追加で必要とするように更新されたのでしょうか?また、これは文章内の旧ドメインの出現箇所も書き換えてしまうのでしょうか?私は画像の修正だけを行いたいのですが。

これと同じ現象が発生しました。どこかドキュメント化されていますか?