# Restore a backup from the command line

**URL:** https://meta.discourse.org/t/restore-a-backup-from-the-command-line/108034
**Category:** Self-Hosting
**Tags:** how-to
**Created:** [January 31, 2019, 4:36pm UTC](https://meta.discourse.org/t/restore-a-backup-from-the-command-line/108034 "2019-01-31T16:36:07Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [January 31, 2019, 4:36pm UTC](https://meta.discourse.org/t/restore-a-backup-from-the-command-line/108034/1 "2019-01-31T16:36:07Z")

</div>

> 🔖 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:

1. Download the latest backup file from the source Discourse instance.
2. Bootstrap the destination Discourse instance by running `./discourse-setup` or copying your existing `app.yml`.
3. Ensure the destination Discourse instance is on the latest version. Update it if necessary.

## Transfer the backup

1. SSH into the destination server, or otherwise create the backup folder there:

`mkdir -p /var/discourse/shared/standalone/backups/default`

1. 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](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247) make sure all paths to the backup are readable by the container and Nginx can read the `.sock` file.

## Restore the backup

1. Access your destination server and navigate to the Discourse folder:

```plaintext
cd /var/discourse

```

1. Enter the Discourse Docker app container:

```plaintext
./launcher enter app

```

1. Enable restore functionality:

```plaintext
discourse enable_restore

```

1. Restore the backup file:

```plaintext
discourse restore sitename-2019-02-03-042252-v20190130013015.tar.gz

```

> 💡 **Tip:** If you run `discourse restore` without a filename, it will list all available backup files.

> ⚠ If your site’s `backup_location` setting is configured to use S3, but you manually uploaded the backup file to the local filesystem, you need to specify `--location local`:
> 
> ```plaintext
> discourse restore --location local sitename-2019-02-03-042252-v20190130013015.tar.gz
> 
> ```
> 
> Similarly, use `--location s3` to restore directly from an S3 backup without downloading it first.

1. Exit the Discourse Docker app container:

```plaintext
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 the `app.yml` configuration of both instances to make sure!

```plaintext
cd /var/discourse
./launcher rebuild app

```

## Enable Email

When a backup is restored, outgoing mail for non-staff is disabled. You don’t want your test server, new server, or server that you just restored a backup for some other reason to start emailing your users! Change the `disable_emails` site setting to “no” to re-enable email.

🎉 That’s it. Your Discourse server is successfully restored.

> Last edited by @pfaffman 2025-05-18T19:32:40Z
> 
> > **Check document**
> >
> > Perform check on document:

---

_[View the full topic](https://meta.discourse.org/t/restore-a-backup-from-the-command-line/108034)._
