# Restoring backup fails due to Postgres version mismatch

**URL:** https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536
**Category:** Self-hosting
**Created:** [7월 20, 2016, 9:04오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536 "2016-07-20T09:04:21Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [7월 20, 2016, 9:04오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/1 "2016-07-20T09:04:21Z")

</div>

I have created backup of Discourse using web UI on Ubuntu with docker-installed Discourse. Now I want it to restore on my development machine Ubuntu (finally - no docker, no vagrant 🙂 ) and I’m getting errors when importing database:

```
[2016-07-20 10:48:53] 'overgrow' has started the restore!
[2016-07-20 10:48:53] Marking restore as running...
[2016-07-20 10:48:53] Making sure /home/overgrow/discourse/tmp/restores/default/2016-07-20-104852 exists...
[2016-07-20 10:48:53] Copying archive to tmp directory...
[2016-07-20 10:48:53] Unzipping archive, this may take a while...
[2016-07-20 10:48:53] Extracting metadata file...
[2016-07-20 10:48:53] Validating metadata...
[2016-07-20 10:48:53] Current version: 20160719002225
[2016-07-20 10:48:53] Restored version: 20160719002225
[2016-07-20 10:48:53] Extracting dump file...
[2016-07-20 10:48:53] Restoring dump file... (can be quite long)
[2016-07-20 10:48:53] SET
[2016-07-20 10:48:53] SET
[2016-07-20 10:48:53] SET
[2016-07-20 10:48:53] SET
[2016-07-20 10:48:53] SET
[2016-07-20 10:48:53] SET
[2016-07-20 10:48:53] psql:/home/overgrow/discourse/tmp/restores/default/2016-07-20-104852/dump.sql:16: ERROR: unrecognized configuration parameter "row_security"
[2016-07-20 10:48:53] psql:/home/overgrow/discourse/tmp/restores/default/2016-07-20-104852/dump.sql:18: ERROR: current transaction is aborted, commands ignored until end of transaction block
... (lots of lines like this)

[2016-07-20 10:48:54] psql:/home/overgrow/discourse/tmp/restores/default/2016-07-20-104852/dump.sql:5230: invalid command \N
... (lots of lines like this)

[2016-07-20 10:48:57] psql:/home/overgrow/discourse/tmp/restores/default/2016-07-20-104852/dump.sql:7456: invalid command \n

```

Maybe previous dump of database is in another format? Different psql versions? Sorry I’m new to psql and rails.  
“invalid command \n” maybe string escaping problem? or different EOL?  
Any help is really appreciated!

---

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [7월 20, 2016, 9:19오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/2 "2016-07-20T09:19:17Z")

</div>

I’ve created new backup on development machine to compare dump.sql and looks like database version is different…

```
-- Dumped from database version 9.5.3
-- Dumped by pg_dump version 9.5.3
-- Started on 2016-07-19 12:42:45 UTC

vs.

-- Dumped from database version 9.3.13
-- Dumped by pg_dump version 9.3.13
-- Started on 2016-07-20 11:16:02 CEST

```

So backup made on newer pg can’t be imported… Any chance to make SQL dumps from different versions compatible? MySQL has its compatibility mode - is there equivalent in Postgres?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [7월 20, 2016, 9:28오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/3 "2016-07-20T09:28:25Z")

</div>

You could try removing the lines that PostgreSQL 9.3 is complaining about, but we don’t make any guarantees about anything working on PostgreSQL older than 9.5. Although we don’t (knowingly) use any 9.5isms at present (`pg_dump` is doing that `row_security` stuff, not us), we only test on 9.5, run all of our customer sites on 9.5, and we could start using something from 9.5 at any time because it solves a problem.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [7월 20, 2016, 1:21오후 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/4 "2016-07-20T13:21:05Z")

</div>

And since you are on Ubuntu just use the official [apt repo](https://wiki.postgresql.org/wiki/Apt) and remove the 9.3 and install 9.5, it’s easy 😉

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2월 14, 2019, 10:27오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/5 "2019-02-14T10:27:45Z")

</div>



---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2월 14, 2019, 10:38오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/6 "2019-02-14T10:38:47Z")

</div>

@Overgrow did you get it to work by upgrading postgresql?

---

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [2월 14, 2019, 10:53오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/7 "2019-02-14T10:53:32Z")

</div>

Exactly. I’ve upgraded postgres to make it work..

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2월 14, 2019, 10:53오전 UTC](https://meta.discourse.org/t/restoring-backup-fails-due-to-postgres-version-mismatch/47536/8 "2019-02-14T10:53:47Z")

</div>


