Backup discourse from the command line

These are some simple instructions on how to backup and restore your Discourse site from the command line.

Backing up

Enter the container:

./launcher enter app

Run the backup:

discourse backup
exit

This will print out the final filename of your backup. Download the backup and container configuration (if needed) to your local machine:

scp =USER=@=HOST=:/var/discourse/shared/standalone/backups/default/=FILENAME= .
scp =USER=@=HOST=:/var/discourse/containers/app.yml .

Restoring

First, install a Discourse site on the server you are restoring to.

If you’re testing this procedure multiple times, you can wipe the data on your test server.

Wipe Discourse data (optional)
./launcher stop app
./launcher destroy app
rm -r /var/discourse/shared/standalone/
mkdir -p /var/discourse/shared/standalone/backups/default/

Upload the backup file:

scp =FILENAME= =USER=@=HOST=:/var/discourse/shared/standalone/backups/default/

Enter the container and start the restore:

./launcher enter app
discourse enable_restore
discourse restore =FILENAME=

If you happen to forget what the filename was, run the “discourse restore” command by itself to get a list of available backup files.

If you’re using a two-container setup, you’ll ./launcher enter web_only and replace standalone with web-only in the path to where the backups belong.

34 Likes