# Restoring Discourse when you can't make a backup

**URL:** https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988
**Category:** Support
**Created:** [15.Июнь.2018 18:59:36 UTC](https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988 "2018-06-15T18:59:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![samnazarko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/samnazarko/32/109010_2.png) [@samnazarko](https://meta.discourse.org/u/samnazarko)
#### Post date: [15.Июнь.2018 18:59:37 UTC](https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988/1 "2018-06-15T18:59:37Z")

</div>

Hi,

Is there some kind of trick to restoring Discourse if you can’t access the interface to make a backup?

A machine is in a bad way, but I was able to get /var/discourse entirely.  
I tested installing Postgres on a local machine and changing the data directory and can see the database is there.

If I copy everything over and run ./launcher rebuild app, I see the next user wizard when I log in to Discourse. During the rebuild, I also get:

```plaintext
I, [2018-06-15T18:21:18.896019 #14] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
2018-06-15 18:21:22.501 UTC [416] discourse@discourse ERROR: relation "users" does not exist at character 566
2018-06-15 18:21:22.501 UTC [416] discourse@discourse STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
	                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
	                     c.collname, col_description(a.attrelid, a.attnum) AS comment
	                FROM pg_attribute a
	                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
	                LEFT JOIN pg_type t ON a.atttypid = t.oid
	                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
	               WHERE a.attrelid = '"users"'::regclass
	                 AND a.attnum > 0 AND NOT a.attisdropped
	               ORDER BY a.attnum
	
2018-06-15 18:21:22.952 UTC [416] discourse@discourse ERROR: relation "user_actions" does not exist at character 566
2018-06-15 18:21:22.952 UTC [416] discourse@discourse STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
	                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
	                     c.collname, col_description(a.attrelid, a.attnum) AS comment
	                FROM pg_attribute a
	                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
	                LEFT JOIN pg_type t ON a.atttypid = t.oid
	                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
	               WHERE a.attrelid = '"user_actions"'::regclass
	                 AND a.attnum > 0 AND NOT a.attisdropped
	               ORDER BY a.attnum
	

```

Is there something I need to set to stop Discourse from creating a new database each time?

I believe a ./launcher rebuild app was running when the other node experienced a problem. I hope that the database is not in a partial state.

Thanks in advance

Sam

---

<div class="post-metadata">

### Author: ![samnazarko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/samnazarko/32/109010_2.png) [@samnazarko](https://meta.discourse.org/u/samnazarko)
#### Post date: [15.Июнь.2018 19:15:01 UTC](https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988/2 "2018-06-15T19:15:01Z")

</div>

I don’t know what the problem was.

pg\_dump and restoring seems to have fixed it. I then re-ran bundle exec rake db:migrate.

---

<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: [15.Июнь.2018 21:45:49 UTC](https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988/3 "2018-06-15T21:45:49Z")

</div>

Glad you got it. FWIW, if you stick the backup in `/var/discourse/shared/standalone/backups/default` you can

```plaintext
./launcher enter app
rails c
discourse enable_restore
discourse restore

```

You’ll then be presented with a set of backups and can copy/paste the restore command with the backup you want to restore.

---

<div class="post-metadata">

### Author: ![samnazarko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/samnazarko/32/109010_2.png) [@samnazarko](https://meta.discourse.org/u/samnazarko)
#### Post date: [15.Июнь.2018 21:57:48 UTC](https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988/4 "2018-06-15T21:57:48Z")

</div>

Thank you very much for this advice.

I wasn’t able to take a tarball based backup, and the backups I had were several hours old, hence the need to restore the Postgres DB.

Sam

---

<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: [15.Июль.2018 21:57:49 UTC](https://meta.discourse.org/t/restoring-discourse-when-you-cant-make-a-backup/89988/5 "2018-07-15T21:57:49Z")

</div>

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