# Error when restore DB backup

**URL:** https://meta.discourse.org/t/error-when-restore-db-backup/93145
**Category:** Self-hosting
**Created:** [July 25, 2018, 11:15pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145 "2018-07-25T23:15:05Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 27, 2018, 1:00am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/23 "2018-07-27T01:00:10Z")

</div>

Hmm what do you think @tgxworld?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 27, 2018, 4:51am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/25 "2018-07-27T04:51:44Z")

</div>

Hmm OK this is tricky but I have a temporary fix out for this.

[https://github.com/discourse/discourse/commit/6740631fdb379f764e8d3007447341f4496dc350](https://github.com/discourse/discourse/commit/6740631fdb379f764e8d3007447341f4496dc350)

The problem here is that the Discourse restorer only migrates table to the backup schema and not functions that we create. The fix here is to ensure that the restorer migrates functions created by the Discourse code base as well but I’ll need to work on a pattern to identify “Discourse PostgreSQL functions”. I’ll probably just namespace the functions that we create with `_discourse_`.

---

<div class="post-metadata">

### Author: ![UnivacTwo](https://avatars.discourse-cdn.com/v4/letter/u/df705f/32.png) [@UnivacTwo](https://meta.discourse.org/u/UnivacTwo)
#### Post date: [July 27, 2018, 8:55am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/26 "2018-07-27T08:55:42Z")

</div>

So, is it enough a to run a ./launcher rebuild app and then to try to import again the backup?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 27, 2018, 11:18am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/27 "2018-07-27T11:18:09Z")

</div>

Yes that will fix it

---

<div class="post-metadata">

### Author: ![UnivacTwo](https://avatars.discourse-cdn.com/v4/letter/u/df705f/32.png) [@UnivacTwo](https://meta.discourse.org/u/UnivacTwo)
#### Post date: [July 27, 2018, 12:29pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/28 "2018-07-27T12:29:53Z")

</div>

it seems to be working. Thanks

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 23, 2018, 5:04am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/32 "2018-08-23T05:04:40Z")

</div>

> [@tgxworld](#):
>
> The fix here is to ensure that the restorer migrates functions created by the Discourse code base as well but I’ll need to work on a pattern to identify “Discourse PostgreSQL functions”. I’ll probably just namespace the functions that we create with `_discourse_` .

Turns out it was much easier to create the functions in a dedicated schema which we do not backup.

[https://github.com/discourse/discourse/pull/6304](https://github.com/discourse/discourse/pull/6304)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 27, 2018, 10:00am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/33 "2018-08-27T10:00:15Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.

[Previous page](https://meta.discourse.org/t/error-when-restore-db-backup/93145.md?page=1)
