Restoring Discourse when you can't make a backup

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:

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

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.

إعجابَين (2)

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

./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.

4 إعجابات

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

إعجاب واحد (1)

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