4 min read

Set up automated server backups with Borg

The Borg deduplicating backup program can automate daily, weekly, and monthly backups with a single script saving space and keeping data safe from mistakes.

Borg backup logo
Author
Isaac Bythewood Isaac Bythewood
June 25, 2022

Borg is a backup program written in Python that has excellent deduplication functionality. For my blog server backups you can see just how much smaller the deduplicated repository size is.

If you run your websites on small servers like I do then this comes in handy to save some money. I currently have two layers of backups on my servers:

  1. Linode provides their "Linode Backup" system. This is a complete backup of the entire disk your server is running on for a reasonable price.
  2. Borg backup for daily automated backups that allow for quick "oops" restores.

These backups serve two different purposes. I can do an emergency full system restore using Linode, and a quick Borg restore if I happen to do something stupid, like accidently delete a blog post.

I currently use a slightly modified script in my /etc/periodic/daily folder based on Borg's quick start automation suggestion.

Borg's documentation can explain this better than I can but the gist is:

  • I run daily backups on all my unique server files in /srv and /etc. I don't backup anything that is a system default.
  • Then prune my backups to only keep 7 daily, 4 weekly, and 6 monthly backups at any given time.
  • Then we compact the repository to save space and exit.

A better option for storing Borg backups would be to set up a Borg repo on another server or a platform like BorgBase. BorgBase is nice since they will notify you by email if a backup doesn't happen or fails however, as I said before, I only use Borg for "oops" backups so if I were to miss a couple I wouldn't stress out about it.

As an extra to this post, I have on my servers a server-health-check.sh script that allows me to quickly check things like auto-updates, Borg backups, free memory, and used disk space! I run it every so often just for peace of mind.

The output of this script is pretty well formatted without much effort and looks a little something like this:

If you're interested in Borg you can read more about it on Borg's website, they have extensive and well written documentation.


Related posts

Some posts in similar tags to this one.

Alpine Linux
Minimal automated updates for Alpine Linux
Many Linux distros have a way to configure automated updates but somewhat surprisingly Alpine Linux does not.
Isaac Bythewood Isaac Bythewood
July 16, 2022
© 2022 Isaac Bythewood. Some rights reserved.