# Backup discourse from the command line

**URL:** https://meta.discourse.org/t/backup-discourse-from-the-command-line/64364
**Category:** Self-Hosting
**Tags:** backups, how-to
**Created:** [June 12, 2017, 3:59pm UTC](https://meta.discourse.org/t/backup-discourse-from-the-command-line/64364 "2017-06-12T15:59:45Z")
**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: [June 12, 2017, 3:59pm UTC](https://meta.discourse.org/t/backup-discourse-from-the-command-line/64364/1 "2017-06-12T15:59:45Z")

</div>

> 🔖 This guide covers how to back up and restore your Discourse site using command line tools, specifically designed for self-hosted environments.
> 
> 🙋 Required user level: Administrator

> ℹ You can use the below placeholders to automatically fill out the command line prompts in this guide:

## Backing up

To create a backup of your Discourse site, follow these steps:

1. Enter the container:

```plaintext
./launcher enter app

```

1. Run the backup:

```plaintext
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

To restore a Discourse backup, follow these steps:

1. 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)**
>
> ```plaintext
> ./launcher stop app
> ./launcher destroy app
> rm -r /var/discourse/shared/standalone/
> mkdir -p /var/discourse/shared/standalone/backups/default/
> 
> ```
> 
> * * *

1. Upload the backup file:

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

```

1. Enter the container and start the restore:

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

> ℹ For a two-container setup, use `./launcher enter web_only` and replace `standalone` with `web-only` in the path to backups.

For additional information about restoring Discourse backups, see [Restore a backup from the command line](https://meta.discourse.org/t/restore-a-backup-from-the-command-line/108034).

> Last edited by @SaraDev 2024-08-23T20:50:17Z
> 
> > **Check document**
> >
> > Perform check on document:

---

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