# שחזור נכשל עם "hotlinked\_media\_status" כבר קיים

**URL:** https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795
**Category:** Support
**Created:** [28 באוגוסט,‏ 2024,‏ 3:00pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795 "2024-08-28T15:00:27Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [28 באוגוסט,‏ 2024,‏ 3:00pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/1 "2024-08-28T15:00:27Z")

</div>

Continuing the discussion from [Upgrade fails on duplicate key error ("index post hotlinked media on post id and url md5")](https://meta.discourse.org/t/upgrade-fails-on-duplicate-key-error-index-post-hotlinked-media-on-post-id-and-url-md5/226002/10):

I’m now trying to restore from one prod site to a staging site and I’m getting:

```plaintext
ERROR: type "hotlinked_media_status" already exists
EXCEPTION: psql failed: ERROR: type "hotlinked_media_status" already exists

```

@david is there some case you somehow missed when you fixed this before (I think it was failing on migrations then, and this is a restore).

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [28 באוגוסט,‏ 2024,‏ 4:25pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/2 "2024-08-28T16:25:16Z")

</div>

How are you restoring the site? Via the UI? discourse CLI? direct psql?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [28 באוגוסט,‏ 2024,‏ 4:37pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/3 "2024-08-28T16:37:01Z")

</div>

From the command line restoring the most recent backup (I figured out this `sed` trick today, but it was the same if I copy/pasted).

```plaintext
$(discourse restore |sed -n '3p')

```

And the backup is on S3 restored from a slightly older version:

```plaintext
Discourse 3.4.0.beta1-dev - https://github.com/discourse/discourse version a3d61ba1c43931eb688f9b2b85c207b5bab02b8c

```

to

```plaintext
Discourse 3.4.0.beta2-dev - https://github.com/discourse/discourse version f405c021ebd36d5f11499159bd2b54098356a8f9"

```

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [28 באוגוסט,‏ 2024,‏ 5:53pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/4 "2024-08-28T17:53:34Z")

</div>

Are you able to reproduce the issue on any other installation?

It’s quite surprising that this issue is cropping up more than 2 years later, and without any other reports 🤔

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [28 באוגוסט,‏ 2024,‏ 8:40pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/5 "2024-08-28T20:40:45Z")

</div>

> [@david](#):
>
> Are you able to reproduce the issue on any other installation?

Maybe not? I did successfully restore that same backup on my dev box.

~~Do you have any idea what I might have done to cause this or what I can do to fix it?~~ I dropped the database and than was able to restore. Dropping the database was the actual solution, but I don’t deserve a solution for a problem I (seem to have) caused.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [27 בספטמבר,‏ 2024,‏ 8:40pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/6 "2024-09-27T20:40:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [14 בנובמבר,‏ 2024,‏ 4:50pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/7 "2024-11-14T16:50:13Z")

</div>

One very valuable insight that I just had is that `hotlinked_media_status` is simply the first thing happening in the restore file. If you remove it manually in the existing database the restore will fail on the next statement (`CREATE TABLE public.admin_notices`).

So this is not about that specific type definition. It’s just a symptom of a bigger problem, I suspect that `BackupRestore.move_tables_between_schemas(MAIN_SCHEMA, BACKUP_SCHEMA)` fails to do what it’s gotta do.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [14 בנובמבר,‏ 2024,‏ 4:50pm UTC](https://meta.discourse.org/t/restore-fails-with-hotlinked-media-status-already-exists/323795/8 "2024-11-14T16:50:22Z")

</div>


