HomeAboutGitlab

Poor man's backup server

Using a rpi3 & zfs as a backup server

For a long time I've been thinking about setting up a simple and cheap backup server that I can access from everywhere. Just the idea of backup is complicated if you don't know where to start and want to be able to have something within your own control.

In the end, my current setup is as follows:

This gives me a way to store my data, and since I'm running a zpool on those disks (with z-raid), it's as secure as I would ever want. The overall capacity of the pool is 1Tb, which I could increase in the future by swapping disks if I ever wanted to (one at a time). For instance, maybe next year I could get 2x3Tb disks.

I made a "hybrid" approach: support for native zfs snapshots, and rsync + server snapshot to backup external devices, like my wife's iMac or my MBP.

The total cost of the entire server was about $180.

The configuration

I already mentioned that the heart of the server is a RPi 3. It's not meant to be a NAS, so I don't care about the slow USB speeds, or even network capacity. It's fast enough to use this as a dump backup, and for $35 it's hard to match.

I opted for an external bay for the sata drives because it seemed more stable and the alternative was to connect two separate external USB drives. The Orico bay so far has proved to be good enough.

As for the server, I started with an ubuntu image, but it contained a lot of crap, so in the end I opted for Archlinux arm, because it was the only easily available "modern" linux distro that worked almost out of the box with the RPi3. I had to manually add the zfs-dkms package to get zfs support, but that was extremely easy: just fetch the package from aur and build it with makepkg.

In the end, the rpi is a regular Archlinux box running zfs on it. Having ZFS allows me to naturally backup my computer (sending snapshots to the remote pool) and also backing up foreign computers, each on its dedicated file system (zfs equivalent of partitions). Right now, it seems to work great. I probably need to improve the backup scripts, as they are very manual, but for now it works.

Why ZFS?

ZFS allows for very easy backups, with its snapshots. For foreign systems (e.g. mac, windows, phones) you can create a new file system for each of them that can work as a bucket and use rsync on each computer to backup your files, as soon the rsync is done, create a snapshot of the file system. That keeps an incremental backup, similar to the Time Machine from Apple, but without the pretty UI.

How it works

On the client side, I have a simple script that will try to create a new snapshot and upload that to the server. It's basically the same script I had before that would upload the snapshots to S3, but with this iteration, I can keep sending incremental snapshots, and because the server is also zfs, reverting or fetching a specific snapshot is trivial.

On a non-zfs machine, I use a very simple rsync script that will upload whatever you want (usually home directory minus a few things) to the backup server to a specific file system, after the rsync is done, create a snapshot of that in the server.

All of this is also available through a tor hidden service: I can backup my personal computer anywhere in the world (yes, it takes a long time to upload ~200mb) because tor will be routing. No need to expose a port in my home network or anything. I did this by setting ssh on the rpi3 as a hidden service.

Future of this project

I would like to create some type of simple web UI that I can use to check the status of the drives and the zpools, as well as be able to clean/manage the snapshots. I would also like to create a simple more visual UI for the non-zfs machines.

Overall, I'm very happy with the system, and I think I'll continue playing with it in the future.

Copyright © 2012-2018 Rolando Abarca - Powered by orgmode

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License unless otherwise noted.