# After backup restore on other server, uploaded images are broken

**URL:** https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463
**Category:** Support
**Created:** [4월 29, 2016, 6:55오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463 "2016-04-29T18:55:20Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![yadlabus](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yadlabus](https://meta.discourse.org/u/yadlabus)
#### Post date: [4월 29, 2016, 6:55오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/1 "2016-04-29T18:55:20Z")

</div>

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.

 ![](https://global.discourse-cdn.com/meta/original/3X/0/a/0abf246d0f07dd95a3ee357112de26d2b50afc2d.png)

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? 😟

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!

---

<div class="post-metadata">

### Author: ![Yuun](https://avatars.discourse-cdn.com/v4/letter/y/977dab/32.png) [@Yuun](https://meta.discourse.org/u/Yuun)
#### Post date: [4월 29, 2016, 7:38오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/2 "2016-04-29T19:38:48Z")

</div>

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 🙂 )

---

<div class="post-metadata">

### Author: ![yadlabus](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yadlabus](https://meta.discourse.org/u/yadlabus)
#### Post date: [4월 29, 2016, 7:57오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/3 "2016-04-29T19:57:55Z")

</div>

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

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 ^^

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [4월 29, 2016, 9:08오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/4 "2016-04-29T21:08:55Z")

</div>

`RAILS_ENV=production script/discourse remap old_hostname new_hostname`

will do the trick.

---

<div class="post-metadata">

### Author: ![yadlabus](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yadlabus](https://meta.discourse.org/u/yadlabus)
#### Post date: [5월 2, 2016, 2:11오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/5 "2016-05-02T14:11:56Z")

</div>

```
./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! 😉

---

<div class="post-metadata">

### Author: ![anon23840344](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@anon23840344](https://meta.discourse.org/u/anon23840344)
#### Post date: [10월 25, 2020, 6:14오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/7 "2020-10-25T18:14:14Z")

</div>

호스트명을 `subdomain.domain.ext` 형식으로 사용하여 다음을 실행하려고 하면:

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

```

다음과 같은 결과가 표시됩니다:

```plaintext
Rewriting all occurences of discourse.old_domain.org to discourse.new_domain.org
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
YES
Warning: no type cast defined for type "name" with oid 19. Please cast this type explicitly to TEXT to be safe for future changes.
Done

```

명령어가 플래그나 변수를 요구하도록 업데이트된 것일까요? 또한 본문(prose) 내의 기존 도메인 발생 위치도 함께 재작성되나요? 저는 사실 이미지를 수정하는 것만 원합니다.

---

<div class="post-metadata">

### Author: ![oluies](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oluies/32/120194_2.png) [@oluies](https://meta.discourse.org/u/oluies)
#### Post date: [10월 28, 2021, 2:45오후 UTC](https://meta.discourse.org/t/after-backup-restore-on-other-server-uploaded-images-are-broken/43463/8 "2021-10-28T14:45:51Z")

</div>

이것도 마찬가지인데, 어딘가에 문서화되어 있나요?
