# How to backup Docker discourse from command-line before rebuilding broken Discourse?

**URL:** https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052
**Category:** Support
**Created:** [July 14, 2015, 8:20pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052 "2015-07-14T20:20:14Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![trudat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/trudat/32/104354_2.png) [@trudat](https://meta.discourse.org/u/trudat)
#### Post date: [July 14, 2015, 8:20pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/1 "2015-07-14T20:20:14Z")

</div>

I set up a Discourse site, and a couple days later it suddenly stopped working - tries to load for a couple minutes then “This web page is not available - ERR\_CONNECTION\_RESET”. It might be a RAM issue.  
I am ready to use the launcher scripts to rebuild the container. But if possible I would like to backup the content that was added to the site so far.  
Is there a preferred way to backup the DB and/or uploaded files manually from the command line?  
I’ve been unable to track down the pgsql credentials in order to do a pgdump.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 14, 2015, 11:06pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/2 "2015-07-14T23:06:51Z")

</div>

No need to backup anything, containers are disposable, all important data is stored outside the container

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [July 15, 2015, 4:31am UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/3 "2015-07-15T04:31:36Z")

</div>

You’ll be safe doing a rebuild, or a reboot (except EC2). Get it back running again, then take a backup from /admin/backups.

---

<div class="post-metadata">

### Author: ![lumadelaplace](https://avatars.discourse-cdn.com/v4/letter/l/ecb155/32.png) [@lumadelaplace](https://meta.discourse.org/u/lumadelaplace)
#### Post date: [May 18, 2017, 4:02pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/4 "2017-05-18T16:02:58Z")

</div>

Is there a way to start a backup from command-line through SSH ?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 18, 2017, 7:07pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/5 "2017-05-18T19:07:56Z")

</div>

I haven’t confirmed, but I’d assume there is a backup script just as there is a restore.

> [@Is there any way to restore your site from backup in the terminal?](https://meta.discourse.org/t/is-there-any-way-to-restore-your-site-from-backup-in-the-terminal/42377/2):
>
> Yes. They’re stored in public/backups/default/. Just run the following command (in the discourse directory) script/discourse restore \<filename.of.the.backup.tar.gz\>

---

<div class="post-metadata">

### Author: ![BobbyZopfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bobbyzopfan/32/149374_2.png) [@BobbyZopfan](https://meta.discourse.org/u/BobbyZopfan)
#### Post date: [May 22, 2019, 11:06am UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/6 "2019-05-22T11:06:45Z")

</div>

> [@trudat](#):
>
> a preferred way to backup the DB and/or uploaded files manually from the command line?  
> I’ve been unable to track down the pgsql credentials in order to do a p

- Is there a way to create a backup from SSH Terminal of my forum/site?
- If my site is half broken (some pages open and some not), should I run the setup again, will my contents will be intact or they’d be thrown away once I run the setup or rebuild the app?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 22, 2019, 3:53pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/7 "2019-05-22T15:53:56Z")

</div>

> [@BobbyZopfan](#):
>
> Is there a way to create a backup from SSH Terminal of my forum/site?

Yes there is. SSH to your server, and run the following:

```plaintext
cd /var/discourse
./launcher enter app
discourse backup

```

> [@BobbyZopfan](#):
>
> If my site is half broken (some pages open and some not), should I run the setup again, will my contents will be intact or they’d be thrown away once I run the setup or rebuild the app?

Running `./discourse-setup` or `./launcher rebuild app` are both safe, neither will throw your data away, they solely modify the application.

---

<div class="post-metadata">

### Author: ![BobbyZopfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bobbyzopfan/32/149374_2.png) [@BobbyZopfan](https://meta.discourse.org/u/BobbyZopfan)
#### Post date: [May 22, 2019, 4:20pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/8 "2019-05-22T16:20:06Z")

</div>

> [@jomaxro](#):
>
> cd /var/discourse ./launcher enter app discourse backup

This command will create the backup locally, in the server only. In other words, within Ubuntu instance.

- how can I know backup’s location/path?
- How can I download this backup to my local pc (so that I could use this backup in another, same type of, instance)?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 22, 2019, 4:27pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/9 "2019-05-22T16:27:57Z")

</div>

> [@BobbyZopfan](#):
>
> how can I know backup’s location/path?

Backups are by default stored in `/var/discourse/shared/standalone/backups/default/`.

> [@BobbyZopfan](#):
>
> How can I download this backup to my local pc (so that I could use this backup in another, same type of, instance)?

This isn’t really a Discourse question. You can use any method you like to download the backup off your server. FTP, SCP, upload to a cloud service, etc. Assuming your Discourse site is working, the easiest method is likely to download the backup from within Discourse.

---

<div class="post-metadata">

### Author: ![BobbyZopfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bobbyzopfan/32/149374_2.png) [@BobbyZopfan](https://meta.discourse.org/u/BobbyZopfan)
#### Post date: [May 23, 2019, 3:34am UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/10 "2019-05-23T03:34:59Z")

</div>

If we create our site backup from frond-end/admin area. And click ‘download backup’ button (which sends us a mail to download the backup data). And then we update the site, run rebuild command and our site breaks down.

And then we want to download the backup file from the link given in our mail. Will we be able to download the same? Given the fact that site has already broken in the mean time after updating the same?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 23, 2019, 2:29pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/11 "2019-05-23T14:29:40Z")

</div>

> [@BobbyZopfan](#):
>
> And then we update the site, run rebuild command and our site breaks down.

If you update the site via `./launcher rebuild app`, there is going to be downtime while that runs. That is expected.

> [@BobbyZopfan](#):
>
> And then we want to download the backup file from the link given in our mail. Will we be able to download the same? Given the fact that site has already broken in the mean time after updating the same?

The link provided via email will only work if your Discourse instance is up and running. You’ll need to download the backup before you start the rebuild, or wait until it finishes.

---

<div class="post-metadata">

### Author: ![BobbyZopfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bobbyzopfan/32/149374_2.png) [@BobbyZopfan](https://meta.discourse.org/u/BobbyZopfan)
#### Post date: [May 23, 2019, 3:08pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/12 "2019-05-23T15:08:22Z")

</div>

> [@jomaxro](#):
>
> e link provided via email will only work if your Discourse instance is up and running. You’ll need to download the backup before you start the rebuild, or wait unt

Excuse me, I was not clear enough in my query. Let me repeat it once.

1. My site is ok and I send my self a link (thru email) to my latest backup.
2. Then I update my website, along with all themes, plugins etc (thru whatever means). And after this update, after rebuilding command (in SSH Terminal), my website breaks.
3. Now my question is, can I download that latest backup from my discourse instance from that email link which I had sent myself earlier?

Or, I’ll first have to start my website (by rebuilding from a sample app.yml may be), and only then I can use that email link to download the backup?

And last, can that email link be clicked more than once (in some websites, I’ve seen that you can click/use such links only once).

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 23, 2019, 3:20pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/13 "2019-05-23T15:20:39Z")

</div>

> [@BobbyZopfan](#):
>
> can I download that latest backup from my discourse instance from that email link which I had sent myself earlier?

No. If your instance is down, you cannot use that link.

> [@BobbyZopfan](#):
>
> Or, I’ll first have to start my website (by rebuilding from a sample app.yml may be), and only then I can use that email link to download the backup?

Correct, you need Discourse to be running. As I previously mentioned, you can download the backup by any other file transfer system you like. If Discourse isn’t working, using something like FTP or SCP would be suggested.

> [@BobbyZopfan](#):
>
> And last, can that email link be clicked more than once (in some websites, I’ve seen that you can click/use such links only once).

I’m fairly certain this is a one time link. However, Discourse is what tracks usage of the link, so if you click it while your site is completely down, the click should not be counted.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [January 6, 2020, 9:22pm UTC](https://meta.discourse.org/t/how-to-backup-docker-discourse-from-command-line-before-rebuilding-broken-discourse/31052/14 "2020-01-06T21:22:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
