This guide explains how to restore a Discourse backup from the command line without using the Discourse web UI.
Required user level: Administrator
Console access required
Here’s how to restore a Discourse backup from the command line, without ever booting the Discourse web UI. This is handy when you’re moving servers.
Prerequisites
Before you start, make sure you complete the following steps:
- Download the latest backup file from the source Discourse instance.
- Bootstrap the destination Discourse instance by running
./discourse-setup
or copying your existingapp.yml
. - Ensure the destination Discourse instance is on the latest version. Update it if necessary.
Transfer the backup
- SSH into the destination server, or otherwise create the backup folder there:
mkdir -p /var/discourse/shared/standalone/backups/default
- Upload your backup file to the destination server.
scp /path/to/backup/backup.tar.gz root@192.168.1.1:/var/discourse/shared/standalone/backups/default
Be sure to replace the paths, filenames, and server names with the ones you are using – but you do want the backup file to end up in:
/var/discourse/shared/standalone/backups/default
You can also upload and download your Discourse backup file from popular web storage sites such as Google Drive, Dropbox, OneDrive, etc – you’ll need to look up the specific command line instructions based on your preferred web storage provider.
DO NOT CHANGE THE FILENAME OF THE BACKUP! Discourse treats the backup filename as metadata, so if you change the filename, restoring will not work. Stick with the original file name.
Replace /path/to/backup/discourse-xyz.tar.gz
with the local path of your backup file, and replace <server_ip_address>
with the IP address of destination server.
If Nginx is used as reverse proxy make sure all paths to the backup are readable by the container and Nginx can read the
.sock
file.
Restore the backup
- Access your destination server and navigate to the Discourse folder:
cd /var/discourse
- Enter the Discourse Docker app container:
./launcher enter app
- Enable restore functionality:
discourse enable_restore
- Restore the backup file:
discourse restore sitename-2019-02-03-042252-v20190130013015.tar.gz
- Exit the Discourse Docker app container:
exit
Rebuild
After restoring the backup, you may choose to rebuild the destination instance to ensure all settings and configurations are applied correctly.
Now is a good time to update
/var/discourse/containers/app.yml
with full HTTPS, additional plugins or CDN configuration. Compare theapp.yml
configuration of both instances to make sure!
cd /var/discourse
./launcher rebuild app
That’s it. Your Discourse server is successfully restored.
Last edited by @SaraDev 2024-08-23T20:49:40Z
Check document
Perform check on document: