Manually restoring a Discourse backup for development

backup

(Kane York) #1

You’ve got yourself a Discourse backup file and want to load it into your development database, without using the web UI, or potentially with a different database name. Cool!

This will assume you already have a Postgres database server running, and you’ve already run the createdb command if appropriate.

Restoring the backup manually is easy, you just need a couple extra SQL statements on the end to switch the schema over.

$ tar zxvf backup-file.tar.gz
# you now have the dump.sql and meta.json files
$ DATABASE=discourse_development
$ psql $DATABASE < dump.sql
$ psql $DATABASE <<END
DROP SCHEMA IF EXISTS backup CASCADE;
ALTER SCHEMA public RENAME TO backup;
ALTER SCHEMA restore RENAME TO public;
END
$ bundle exec rake db:migrate

Guide based off this post.


Restoring backups for development
How sam's development environment is configured