# Hot off the presses, automated backup support!

**URL:** https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805
**Category:** Feature
**Created:** [17 maart 2014 om 16:35 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805 "2014-03-17T16:35:26Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [17 maart 2014 om 16:35 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/1 "2014-03-17T16:35:27Z")

</div>

If you are on the latest version of Discourse, you can now enable automated daily backups, with support for uploading them offsite to S3!

I’m super proud of this feature because in my opinion not enough software (and certainly no forum software I am aware of) encourages users to create offsite backups of their data. The last thing you want in the event of a server failure is to lose all the awesome content your forum users have created.

Enabling this feature is easy! First go to the admin section and find backups under site settings. You’ll see the following options:

![](https://global.discourse-cdn.com/meta/original/2X/f/f46ae50203e32ff9762fa9e465d7b078f10a3483.png)

Note that for the uploading to S3 support you’ll need to have defined your s3 credentials as well. If you don’t upload to S3 the backups will be left on the server filesystem.

Once you enable this, you can go to the backups tab in admin to view a list of backups that were performed with links to download or restore any images.

 ![](https://global.discourse-cdn.com/meta/original/2X/6/676ede3996997089cb563a8bd82450c9258a565b.png)

Let us know what you think of the feature and please help us try it out by enabling backups for your forums!

---

<div class="post-metadata">

### Author: ![ArmedGuy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/armedguy/32/107987_2.png) [@ArmedGuy](https://meta.discourse.org/u/ArmedGuy)
#### Post date: [18 maart 2014 om 18:03 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/2 "2014-03-18T18:03:08Z")

</div>

Might already be in the works, but will you extend this to, lets say, FTP backup? =)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [18 maart 2014 om 18:21 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/3 "2014-03-18T18:21:06Z")

</div>

We have no plans to implement FTP but I purposely created a function called `after_create_hook` in `Backup` so that a plugin could easily be added to handle custom behaviour like FTP. I imagine a FTP plugin would not be very complicated.

---

<div class="post-metadata">

### Author: ![cfstras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cfstras/32/103104_2.png) [@cfstras](https://meta.discourse.org/u/cfstras)
#### Post date: [18 maart 2014 om 20:00 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/4 "2014-03-18T20:00:55Z")

</div>

Wow! That’s a great feature.

Currently testing this, but somehow the upload is going wrong:

```erlang
[2014-03-18 20:49:04] Executing the after_create_hook for the backup
[2014-03-18 20:49:14] EXCEPTION: Connection reset by peer (Errno::ECONNRESET)
[2014-03-18 20:49:14] /home/discourse/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/openssl/buffering.rb:375:in `syswrite_nonblock'
/home/discourse/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/openssl/buffering.rb:375:in `write_nonblock'
/home/discourse/discourse/vendor/bundle/ruby/2.0.0/gems/excon-0.28.0/lib/excon/socket.rb:91:in `write'
/home/discourse/discourse/vendor/bundle/ruby/2.0.0/gems/excon-0.28.0/lib/excon/ssl_socket.rb:98:in `write'
[... stack trace ...]
/home/discourse/discourse/app/models/backup.rb:41:in `upload_to_s3'
/home/discourse/discourse/app/models/backup.rb:32:in `after_create_hook'
/home/discourse/discourse/lib/export/exporter.rb:244:in `after_create_hook'
[... more trace ...]
[2014-03-18 20:49:14] Cleaning stuff up...
[2014-03-18 20:49:14] Removing tmp '/home/discourse/discourse/tmp/backups/default/2014-03-18-204859' directory...
[2014-03-18 20:49:14] Unpausing sidekiq...
[2014-03-18 20:49:14] Disabling readonly mode...
[2014-03-18 20:49:14] Marking backup as finished...
[2014-03-18 20:49:14] Finished!

```

Before this, I got 403 Forbidden, but that was due to wrong permissions in my bucket…

any Ideas?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [18 maart 2014 om 20:39 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/5 "2014-03-18T20:39:21Z")

</div>

Hmmm that’s quite unusual. I actually have no idea what would cause that.

What region is your bucket in?

---

<div class="post-metadata">

### Author: ![cfstras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cfstras/32/103104_2.png) [@cfstras](https://meta.discourse.org/u/cfstras)
#### Post date: [18 maart 2014 om 20:44 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/6 "2014-03-18T20:44:17Z")

</div>

I set it to eu-west (ireland).

---

<div class="post-metadata">

### Author: ![darwin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darwin/32/104144_2.png) [@darwin](https://meta.discourse.org/u/darwin)
#### Post date: [19 maart 2014 om 02:02 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/7 "2014-03-19T02:02:18Z")

</div>

I hit another minor issue. I wanted to name my bucket discuss-backup, but because S3 buckets have global namespace this name was already taken. So I decided to append my domain name to it and created bucket named `discuss-backup-discuss.binaryage.com`.

And this is a mistake! after\_create\_hook fails with some SSL error when do you use a bucket name with dots in it.

```
[2014-03-18 22:00:25] Executing the after_create_hook for the backup
[2014-03-18 22:00:25] EXCEPTION: hostname "discuss-backup-discuss.binaryage.com.s3.amazonaws.com" does not match the server certificate (OpenSSL::SSL::SSLError)
[2014-03-18 22:00:25] /usr/local/lib/ruby/2.0.0/openssl/ssl.rb:139:in `post_connection_check'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/excon-0.28.0/lib/excon/ssl_socket.rb:85:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/excon-0.28.0/lib/excon/connection.rb:373:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/excon-0.28.0/lib/excon/connection.rb:373:in `socket'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/excon-0.28.0/lib/excon/connection.rb:122:in `request_call'
...

```

---

<div class="post-metadata">

### Author: ![darwin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darwin/32/104144_2.png) [@darwin](https://meta.discourse.org/u/darwin)
#### Post date: [19 maart 2014 om 02:07 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/8 "2014-03-19T02:07:59Z")

</div>

Also one more note. When automated backup finishes successfully I get system message “Export completed successfully”. But when it fails I don’t get anything. Of course during manual backup execution, I get popup that backup failed and I should go and see the logs. But in case of automated backup I would appreciate to get system message with full log embedded, so I can inspect it right away without trying to reproduce the issue with manual backup (the issue may be no longer reproducible).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [19 maart 2014 om 02:08 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/9 "2014-03-19T02:08:37Z")

</div>

I believe @zogstrip has run into bucket name with dots issues before, anything to add here? Agree that failed backups should include some sort of log attachment @eviltrout.

---

<div class="post-metadata">

### Author: ![darwin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darwin/32/104144_2.png) [@darwin](https://meta.discourse.org/u/darwin)
#### Post date: [19 maart 2014 om 02:13 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/10 "2014-03-19T02:13:21Z")

</div>

@codinghorror I would just restrict the configuration field in settings to safe characters maybe with some explanation. There is no need for dots in names. AFAIK Amazon has some naming convention and requires them only if you want to host buckets on open web and map bucket name to your domain name (which should not be the case here).

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [19 maart 2014 om 08:21 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/11 "2014-03-19T08:21:41Z")

</div>

> [@codinghorror](#):
>
> run into bucket name with dots issues before

Definitely related to bucket with dots in their name. They are not compatible with https…

> [@darwin](#):
>
> I would just restrict the configuration field in settings to safe characters maybe with some explanation. There is no need for dots in names.

Added that to my list.

> [@darwin](#):
>
> But in case of automated backup I would appreciate to get system message with full log embedded, so I can inspect it right away without trying to reproduce the issue with manual backup

While I agree this is nice to have, you can already see the **last** backup logs when you directly navigate to the `/admin/backup/logs` page.

---

<div class="post-metadata">

### Author: ![darwin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darwin/32/104144_2.png) [@darwin](https://meta.discourse.org/u/darwin)
#### Post date: [19 maart 2014 om 11:44 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/12 "2014-03-19T11:44:14Z")

</div>

> [@zogstrip](#):
>
> While I agree this is nice to have, you can already see the last backup logs when you directly navigate to the /admin/backup/logs page.

This does not work for me. I can see there only “No logs yet…”. This works for me only immediately after running a manual backup.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [24 maart 2014 om 18:36 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/13 "2014-03-24T18:36:10Z")

</div>

@darwin I just pushed a fix that will send the logs to the admin user when the backup/restore operation fails.

[https://github.com/discourse/discourse/commit/0def4747da9e086e0dc0e0a4d1759fdac4bd9f1e](https://github.com/discourse/discourse/commit/0def4747da9e086e0dc0e0a4d1759fdac4bd9f1e)

---

<div class="post-metadata">

### Author: ![wgross](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wgross/32/108381_2.png) [@wgross](https://meta.discourse.org/u/wgross)
#### Post date: [9 april 2014 om 18:27 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/14 "2014-04-09T18:27:13Z")

</div>

Do the new automated backups include images/attachments or just the database? My Discourse forum is still using local file storage, not S3. I am trying to decide if I should start using S3 for images/attachments.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [9 april 2014 om 19:31 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/15 "2014-04-09T19:31:30Z")

</div>

The backup images include all uploaded files, right @zogstrip?

So if you enable the option your content will be created with your backup files.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [9 april 2014 om 19:36 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/16 "2014-04-09T19:36:37Z")

</div>

> [@eviltrout](#):
>
> The backup images include all uploaded files, right @zogstrip?

Exactly. But only if you’re using the local storage.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9 april 2014 om 23:29 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/17 "2014-04-09T23:29:27Z")

</div>

When you say “using the local storage” you mean “not using S3” right?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [10 april 2014 om 07:48 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/18 "2014-04-10T07:48:25Z")

</div>

> [@codinghorror](#):
>
> you mean “not using S3” right?

Right. RIght now, there’s 2 file stores: local store and S3 store.

---

<div class="post-metadata">

### Author: ![jrgifford](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jrgifford/32/107029_2.png) [@jrgifford](https://meta.discourse.org/u/jrgifford)
#### Post date: [15 april 2014 om 15:53 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/19 "2014-04-15T15:53:17Z")

</div>

So I have a question… would it be possible to have a hourly option? We’ve had a few situations where it would have been nice to have a hourly backup instead of a nightly backup, since we are on the master discourse instead of the releases.

Of course, I’d also accept “you’re being dumb by staying on the development branch” as a acceptable answer. 😄

---

<div class="post-metadata">

### Author: ![probus](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@probus](https://meta.discourse.org/u/probus)
#### Post date: [17 april 2014 om 05:32 UTC](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805/20 "2014-04-17T05:32:43Z")

</div>

I would like to see more frequent options as well, _in the future_. On another topic I suggested using [WAL-E](https://github.com/wal-e/wal-e) from Heroku for database backups. That would provide a simple way to set up continuous backups. WALs use little disk space and the system works on the background with no downtime taking advantage of the features of PostgreSQL database.

[Volgende pagina](https://meta.discourse.org/t/hot-off-the-presses-automated-backup-support/13805.md?page=2)
