SabaKore

Home / Articles / Security

Backups for Self-Hosting: Protecting Your Own Data Yourself

You have to provide yourself what a ready-made service used to do for you. This article covers what to include, where to keep it, and how to check that you can restore.

Ren, a junior infrastructure engineer

Ren

I put my data on my own server, so I no longer have to leave it with someone else!
Procura, a cloud AI robot who explains

Procura

It's true that you've brought it under your own control. But don't forget that you also gave up what a ready-made service quietly did for you. In particular, the mechanisms that keep data from being lost.

What you gave up

  • A mechanism that automatically copies data to several locations
  • A setup that recovers from hardware failures without users noticing
  • A mechanism that lets you restore for a set period after a mistaken deletion
  • None of these exist unless you provide them yourself
Procura, a cloud AI robot who explains

Procura

I'd especially like you to be aware of the third. Ready-made services often have a feature that keeps deleted files for a set period. In a self-hosted environment, it's normal for that not to exist.

What to include

Procura, a cloud AI robot who explains

Procura

Where the data lives differs by software. It won't come down to "take this and you have everything," so check what to include.
  • The contents of the database (it holds settings and user information)
  • Where uploaded files are stored
  • Configuration files
  • If there are encryption keys, those too (you can't restore without them)
Procura, a cloud AI robot who explains

Procura

Missing the fourth is fatal. Even if you have the data, you can't read it without the key. With software that uses encryption, a copy of the key is as important as the application itself.

Where to keep it

What you keep on the same server doesn't count as a backup. Losing the whole server is exactly the situation you want to be ready for. It starts to work only once you also build a mechanism that sends it automatically to somewhere else.

Wilson, the security guard

Wilson

...If the backups are on the same server, I can deal with both at once the moment I get in. It saves me the trouble, though.
  • Don't keep it only on the same server
  • Sending it to storage at a different provider lets you withstand an account-level accident too
  • Narrow the permissions on the storage (in some cases you can make it impossible to delete)
  • Keep several generations (if you only overwrite the latest one, a broken state overwrites it)

Check that you can restore

What's really hard about backups isn't taking them but restoring them. You thought you had them, but they were empty; the compression was corrupted; a necessary file was left out of what was included. You can't tell any of these until you try a restore. On the day you set up the backup, actually restore it once to a different location. A backup that skips this is little different from having none.

  • Temporarily set up a server for verification
  • Restore there and check that the data is complete
  • Also measure how long recovery takes
  • Write the procedure down, and keep a copy outside the server too

Make it possible to notice that it's working

Procura, a cloud AI robot who explains

Procura

The scariest thing is for months to pass without you noticing that it's failing. You only find out when you try to restore and the latest one turns out to be six months old.
  • Set up a notification for failures (staying quiet on success is fine)
  • Once a month, look at the date of the latest backup by eye
  • Check that the file size isn't extremely small
  • Also monitor free space at the storage location
Procura, a cloud AI robot who explains

Procura

The second is easy and reliable. Even if the notification mechanism itself breaks, you'll notice this way.
Ren, a junior infrastructure engineer

Ren

Keep a copy of the keys too. And try a restore at least once. I'll do that.

This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.