# Restoring backup from 2.0.0.beta5 disables Discourse

**URL:** https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505
**Category:** Bug
**Created:** [April 3, 2018, 10:38pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505 "2018-04-03T22:38:06Z")
**Posts on this page:** 9
**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: [April 3, 2018, 10:38pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/1 "2018-04-03T22:38:06Z")

</div>

I’m trying to restore a backup from a hosted site running `"Discourse 2.0.0.beta5 - https://github.com/discourse/discourse version 6f32de186aa1d9e0814183f354bb01f5b66d1c0e`.

When I restore on a clean build, or one that’s gone through the setup wizard, it fails and leaves the database in such a state that Discourse doesn’t run anymore.

This is `(PostgreSQL) 9.5.10` in the container.

```plaintext
Starting restore: discourse-2018-04-03-183844-v20180328180317.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2018-04-03-222730 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
tar: meta.json: Not found in archive
tar: Exiting with failure status due to previous errors
No metadata file to extract.
Validating metadata...
  Current version: 20180328180317
  Restored version: 20180328180317
tar: dump.sql: Not found in archive
tar: Exiting with failure status due to previous errors
Extracting dump file...
Cannot restore into different schema, restoring in-place
Enabling readonly mode...
Pausing sidekiq...
Waiting for sidekiq to finish running jobs...
Restoring dump file... (can be quite long)

```

Here’s the whole log: [Restoring from Discourse 2.0.0.beta5 - https://github.com/discourse/discourse version 6f32de186aa1d9e0814183f354bb01f5b66d1c0e · GitHub](https://gist.github.com/pfaffman/af61e1ae43b3e193232cdeb9b477ab13)

And then, when it’s done, Discourse says:

> [@](#):
>
> # Oops
> 
> The software powering this discussion forum encountered an unexpected problem. We apologize for the inconvenience.
> 
> Detailed information about the error was logged, and an automatic notification generated. We’ll take a look at it.
> 
> No further action is necessary. However, if the error condition persists, you can provide additional detail, including steps to reproduce the error, by posting a discussion topic in the site’s feedback category.

---

<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: [April 5, 2018, 7:08pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/2 "2018-04-05T19:08:52Z")

</div>

### Update:

I upgraded the target site to the latest postgres with a couple `./launcher rebuild app`s (great job, @tgxworld!), downloaded a new backup from the Discourse hosted site, and it restored without a hiccup.

---

<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: [April 5, 2018, 8:10pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/3 "2018-04-05T20:10:26Z")

</div>

So you were experiencing [this](https://meta.discourse.org/t/restoring-a-corrupt-file-does-not-roll-back-the-database/84663) except for the fact that your database dump wasn’t actually broken, the 10.3 dump just _appeared_ broken to your 9.5.10 `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: [April 5, 2018, 8:13pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/4 "2018-04-05T20:13:16Z")

</div>

I don’t pretend that I completely understand everything that’s going on here, but that seems right to me.

---

<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: [April 5, 2018, 8:19pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/5 "2018-04-05T20:19:08Z")

</div>

What is happening is this:

- You have a dump created by pg\_dump version 10.3
- You are attempting to restore it on Postgresql 9.5.
- The restore script [moves all tables to a different scheme](https://github.com/discourse/discourse/blob/master/lib/backup_restore/restorer.rb#L66) called ‘backup’. The purpose of this is to move them out of the way, so the restore will have an empty database to restore to. They are moved to a different scheme instead of being deleted, so when the restore fails, they can be moved back where they came from.
- psql bails out because it isn’t able to handle a dump made by a newer version of Postgres. (“[old versions of pg\_restore will therefore refuse to process files made with new versions of pg\_dump](https://github.com/postgres/postgres/commit/3d2aed664ee8271fd6c721ed0aa10168cda112ea).”)
- the restore script usually moves the files back from the backup scheme to the public scheme when the restore fails, [but it does not](https://github.com/discourse/discourse/blob/master/lib/backup_restore/restorer.rb#L441), leaving you with an empty scheme.

---

<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: [April 6, 2018, 5:33pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/6 "2018-04-06T17:33:50Z")

</div>

Well, I don’t know what the problem is today. I swear that I got it to restore yesterday, but now that I’ve rebuilt, neither yesterday’s nor today’s backup will restore.

I’m trying to restore to a [standard install](https://meta.discourse.org/t/142537?silent=true) that I just rebuilt.

Dump file from `Discourse 2.0.0.beta5 - https://github.com/discourse/discourse version b1cc368da8ce1715ddaa6bc640b361505b22f1be"` states:

```plaintext
-- Dumped from database version 10.2 (Ubuntu 10.2-1.pgdg16.04+1)
-- Dumped by pg_dump version 10.3 (Ubuntu 10.3-1.pgdg16.04+1)

```

Restore does this:

```plaintext
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2018-04-06-172529 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
tar: meta.json: Not found in archive
tar: Exiting with failure status due to previous errors
No metadata file to extract.
Validating metadata...
  Current version: 20180328180317
  Restored version: 20180328180317
tar: dump.sql: Not found in archive
tar: Exiting with failure status due to previous errors
Extracting dump file...
Cannot restore into different schema, restoring in-place
Enabling readonly mode...
Pausing sidekiq...
Waiting for sidekiq to finish running jobs...
Restoring dump file... (can be quite long)
SET
SET
SET
SET
SET
set_config
------------
(1 row)
SET
SET
SET
ERROR: function "raise_topic_status_updates_read_only" already exists with same argument types
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block

```

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [April 12, 2018, 3:41pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/7 "2018-04-12T15:41:34Z")

</div>

Does @tgxworld’s fix ([FIX: Restorer wasn't rolling back if restore fails. · discourse/discourse@5da7c2a · GitHub](https://github.com/discourse/discourse/commit/5da7c2a4ad6c9eae5cb80887433d4a20fb50a221)) resolve this?

---

<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: [April 12, 2018, 5:08pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/8 "2018-04-12T17:08:10Z")

</div>

Something worked. (I’m not sure exactly what.)

It’s working now!

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [April 13, 2018, 10:00pm UTC](https://meta.discourse.org/t/restoring-backup-from-2-0-0-beta5-disables-discourse/84505/9 "2018-04-13T22:00:02Z")

</div>

This topic was automatically closed after 28 hours. New replies are no longer allowed.
