What's your backup strategy for your Linux machines?

Curious how everyone here handles backups. Whether it’s a single laptop, a homelab, or a few servers.

A few questions:

  • What do you use? rsync, Borg, Restic, Timeshift, Déjà Dup, something else?
  • Where do backups go? External drive, NAS, cloud, offsite?
  • How often do they run, and have you ever actually tested a restore?

Share your setup, even if it’s simple. A one-line cron job or bash scripts acceptable!

4 Likes

As a retired home user I backup my ~ partition to the external USB drive using rsync

5 Likes

I use USB drives too, but instead of using a traditional backup approach, I use a different group of backup conventions:

  1. Backup hardware
  2. Backup software
  3. Alternative removable system images
  4. An ISO Snapshot tool, that functions in multiple ways: it provides a full backup of an installed system, and it doubles as a redistributable Live ISO image or as a way to install the same image on another computer!

To me, this is a pretty effective approach: no one single point of failure because I have a few DIFFERENT images, a few different hardware systems, so it’s different hardware AND different software PLUS backup copies of the same software; it’s saved me when I’ve overwritten perfectly good systems more than once so it works both as a testing infrastructure and as a very effective every day working environment!

Also I can use a DIFFERENT system while I’m backing up or installing another one!

5 Likes

Being an Ubuntu user,specifically Ubuntu MATE 24.04 I kept it simple and have been using deja-dup. That was until today.

I do backups once a week religiously and today was the day. Started the process as usual and was told there wasn’t enough room on the destination drive and that I need enough room for two full backups which I found odd as it’s a 64gb thumb drive that has never had anything more on it than my /home directory which at this very moment is 17.4gb. That was a message I’ve never seen until today.Ok so I figured a fresh back up on a new 64gb drive and get the message from deja-dup that it’s it waiting for the drive to respond which of course never happened even though it was mounted.Tried with two more drives and the same.

Back in the day I used to use rsync, well actually grsync. I stopped using it because the initial backup would take so long. Well today I’m back to rysnc/grsync for good as it really does a more thorough job and once the initial backup is done the subsequent backups take almost no time.

6 Likes

I’ve been thinking about writing up the change I’ve made to my backup system for a little while now, it takes me time to consolidate my thoughts as I tend to ramble in random directions for awhile. This seems like as good a time and place as any!

In a previous post, I mentioned that I was mostly backing up through a bash script that I custom wrote to Nextcloud, and then relying on the versioning system in Nextcloud as my “deltas” (foreshadowing). The script I used would use tar to build an archive, gz to compress the archive, and then gpg to encrypt the compressed archive. Then I would use curl to upload the backup to Nextcloud.

This idea was cool (to me), as it taught me about building a repeatable backup process, deploying that process with ansible, and managing files with Nextcloud. However, this idea was also fraught with problems:

  1. Often times the script would fail and had no self-healing. I had to rely on Icinga2 alerts days after to tell me that a backup failed and then I would manually go in and resolve the issue.
  2. Relying on Nextcloud’s versioning system does work, but it also very much does eat file space. Neither my script, nor the versioning system, does any de-duplication so 600GB of backups from my script required over 2TB of total disk space on my Nextcloud server.

So I finally decided it’s time to fix these issues and get a more reliable setup. The criteria I used for this was:

  • De-duplication is a top priority. I don’t want backups taking up 2TB of space (unless it really is that much data)
  • More reliability requiring less manual intervention from me
  • Repeatable and deployable, something that works for a server, laptop, desktop, or the offsite backup process

What do I use? Borg Backup. It meets each of my criteria with de-duplication, encryption, compression, and a repeatable and deployable process. Backups have been running for almost a month now, and I’ve only used 122GB of space!

Where do backups go? I chose to re-partition my RAID array with a /data/nextcloud folder and a /data/backups folder, where Borg stores backups.

How often do they run? All backups run nightly. Offsite backup runs once a week to an external USB drive, which every other weekend I physically hand off the drive to a family member who backups up the data to their NAS.

Have I tested a restore? Yes! Borg’s ability to mount your backup as a file system and browse the archives and even copy a file off to the main drive is an insanely useful feature. It absolutely saved my butt when a Raspberry Pi went down (bad SD card) and I needed to get several config files to push to another machine. I mounted the backup on my desktop, copied the files off the mounted archive, and rsync’d them to the new machine, easiest restore I’ve ever done.

I wrote some BASH scripts as wrappers around the Borg commands, put it in a repo, and then used Ansible to deploy this across my network. The borg-init script initializes the program. The borg-backup script does the backup. If you want to check them out, see my repo here, which also includes the files to use for what to backup, what to exclude, pre-scripts, post-scrips, and ansible playbooks. I have two more scripts left to write and some documentation to add before moving it to the main branch, hence why the link is to develop.

So far, Borg has been incredible for what I needed and backups run smoothly every night. I haven’t had to manually intervene in a few weeks now.

6 Likes

Nice write-up, @benowe1717! I came to pretty much the same conclusion: these days, I use Borg for all my backups.

I tried a few alternatives along the way, including Kopia, but had some bad experiences with it. Eventually I went back to Borg and haven’t looked back.

My setup has two parts:

  • Local backups to external USB SSDs: I use Vorta as a GUI for Borg. It makes scheduling backups and browsing archives easy.

  • NAS backups to a Hetzner Storage Box: I built my own Docker container to handle these automatically, without needing to babysit anything on the NAS.

If anyone is interested in the container or wants to reuse it, it’s on GitHub:

A few details about how it works:

  • It’s based on Alpine Linux and runs as a persistent container with its own cron scheduler.

  • Each source folder gets its own Borg repository, so retention and restores can be managed independently.

  • Source folders are mounted read-only, so the backup process can’t modify the original data.

  • Backups are encrypted using Borg’s repokey mode. Make sure to export your key with borg key export and keep it somewhere safe. You’ll need both the key and the passphrase to recover your backups if the repository’s key data is lost.

  • Retention is configurable, with defaults of 7 daily, 4 weekly and 6 monthly backups.

  • A lockfile prevents scheduled jobs from overlapping.

  • Email notifications are sent on failure, with optional notifications for successful runs.

  • Everything is configured through docker-compose.yml, so there’s no need to edit scripts.

  • Despite the name, it also works with locally mounted drives or NAS shares instead of Hetzner.

And regarding your point about discovering failed backups days later: that was actually one of my main reasons for building it this way. I wanted backups to run quietly in the background, but to hear about it immediately when something goes wrong.

Greetings, Patrick

5 Likes

Thanks for the kind words @Bitpainter75! I tried duplicity before trying out Borg. While duplicity is good, it just felt more difficult to manage and it also felt much slower in terms of performance.

It’s possible I was misusing or misunderstanding the setup/instructions, but Borg made things super clear and easy to work with.

I had not heard of a Hetzner Storage Box before, but you’ve seemed to pair Borg perfectly with this and your dockerized setup is awesome! Great work!

I have an old Dell PowerEdge R510 that I inherited from a previous company. They were decommissioning it and were just going to throw it away! I couldn’t let that happen. I bought a 2nd CPU for it (since it has 2 CPU sockets) and set up a RAID 10 array on the 12 3TB drives available.

It has since served as my Nextcloud server, but I’ve recently decided to restructure. I had one mount point of /nextcloud and everything sat under that. Not a very forward-thinking or good use of space (past me didn’t know a lot).

Now the same array sits at /data and I have directories for Nextcloud, Borg, and several NFS shares for Docker containers running on other hosts where I expect storage to accumulate quickly (Navidrome music and Immich photo storage).

That was a tangent I didn’t expect to go on, so back to the main point of your post, Borg is definitely an excellent choice, and the right choice for us it seems!

3 Likes

Like this (one of two mirrored sets):

No tar, no dar, no zip, no dejadup or anything.
Just a simple scipt based on cp -au so all files are readable/restorable without any 3rd party software
(no restore-software deprecation or python deprecation risk).

6 Likes

Mine got a lot more serious after I learned the hard way lol.

The wake up call

My Proxmox VM backups were going to an NFS share on my TrueNAS VM. Then one of the pool disks faulted and the pool went degraded. The backup job tried to write to it, the NFS mount hung, and the whole hypervisor sat wedged for 38 hours. That’s when I found out TrueNAS had zero backup tasks set up. No snapshots, no replication, nothing. Everything on the pool was a single copy on a degraded array. First thing I did was rsync the whole thing to two USB drives before I touched anything else.

What I run now

  • VMs: vzdump to Proxmox Backup Server on my second node, so the backups don’t live on the box they’re protecting. Snapshot mode with zstd, keep last 4 plus 3 monthly. TrueNAS is excluded because it can’t back itself up to itself.
  • Kubernetes: Velero backs up the cluster every night at 2am with 7 days kept. It goes to an S3 bucket on TrueNAS, plus a second copy offsite in Oracle Cloud object storage.
  • NAS: hourly and daily ZFS snapshots on TrueNAS.
  • Media: that one I back up by hand to an external drive since it’s way too big for everything else.

Restore testing

Yes, and I’d say it matters more than the backup itself. I restored a VM to a new ID, booted it, then deleted it. I also restored my whole Wazuh namespace from Velero into a test namespace, and it finished in 11 seconds. If you’ve never restored it, you don’t really know you have a backup.

The thing I’d tell anyone with a homelab is don’t put your backups on the same storage you’re backing up. Learned that one the expensive way.

3 Likes

My process is pretty simple. I keep weekly Timeshift/Snapshots on my primary machine, and regularly save documents and bookmarks to my secondary machine using Warpinator. The documents and bookmarks on my secondary machine are then saved to a USB drive. There’s nothing else on my primary system that can’t be easily replaced. No scripts or command line required. I’ll be testing out the Butterbian distro by doing a full install on my secondary system either today or tomorrow, so documents and bookmarks will be saved to a USB drive on my primary system during the testing process.

4 Likes