How to Make Data Backups on Ubuntu & Other Distros
Would you be okay if your disk drive died right this moment? Or would you lose a lot of sensitive files and information? That’s why, if you aren’t already, you should be making regular data backups . You never know when disaster will strike.
But as a Linux user, backing up data isn’t as user-friendly as it might be on other operating systems . Not that it’s difficult, but the learning curve is just a bit harder, so we’re going to run you through the most common and effective backup methods for home users.
We’ve split these methods into two types: incremental backups (daily, weekly, monthly, etc.) and one-time backups (done manually whenever you want).
Linux Incremental Backups
Incremental backups are ideal for when you need your backups to stay as current as possible. These are usually scheduled to be automatic, but it’s possible to make incremental backups using a manual method if you want to, though we don’t necessarily recommend that.
One of the biggest draws of Linux is that its community is all about free and open source software , which results in users who aren’t as likely to spend money on apps and services . But this is one case where money is worth spending.
CrashPlan handles all of your data backups for you behind the scenes. All you have to do is install the client, designate which directories and files you want to keep backed up, and let it do its thing. It works across Windows, Mac, and Linux.
As a free user, you have unlimited access to backups stored to local and external drives along with automatic daily backups. With an Individual account at $5 per month, you get unlimited online storage and continuous, minute-by-minute backups. Files are stored indefinitely using 448-bit encryption.
CrashPlan is one service where you can actually save money by opting for the family plan instead , so consider getting one for $12.50 per month and splitting it with up to nine other computers.
This is the best option for Linux newbies and those who prefer the “out of sight, out of mind” approach to data backups.
Duplicati is another desktop client that handles backups on your behalf using its built-in scheduler. It supports many cloud and off-site services, such as Google Drive, OneDrive, Amazon S3, Rackspace, etc. The client itself is free and available on Windows and Linux.
Don’t be alarmed when you visit the site and see that the latest stable version was released in 2013. The 2.0 version is actively being developed and can be downloaded from the latest releases page.
As you’d expect, the first backup is a full backup and subsequent backups are based on file differentials. The interface is easy to use, though not exactly beautiful. Backups are protected using AES-256 encryption before uploading.
Duplicati has a few other advanced features, including selection filters, deletion rules, customizations on bandwidth when transferring files, and more. Visit the How To pages to learn how to take full advantage of Duplicati.
Rsnapshot is a command-line utility that’s built on top of the rsync command-line utility. It creates a “main” backup the first time you use it, and then only stores file differentials for every future backup, which ultimately saves on disk space.
These automated backups can be stored on local and external drives, USB drives, NFS mounted drives, or even on any other machine on your network using SSH.
The rsnapshot package is available on all systems that use Yum and Apt. To install using Yum:
yum install rsnapshot
And to install using APT:
apt-get install rsnapshot
To set up rsnapshot, you’ll need to edit the configuration file which is located at /etc/rsnapshot.conf, which is commented well enough that most Linux users should be able to follow.
The most important settings are
snapshot_root (which is where backups are stored), the section on backup intervals, and the sections where you indicate which directories you want to keep backed up.
What’s nice is that you can pretty much configure it to do whatever you want, such as storing your backups on Dropbox or Spideroak and letting those storage solutions handle synchronization.
Back in 2010, a backup utility called Attic was born. It offered a system of backups that were deduplicated, compressed, and encrypted without being overly difficult to set up or use. But by the time 2015 rolled around, development stopped — and so it was forked .
Thus, Borg was born. It may be a bit daunting at first for anyone who isn’t comfortable with the command line, but Borg is well-documented. The website holds your hand, so you’ll be able to get the hang of it in no time.
Borg is available in the repositories of the most popular distros, including Ubuntu, Debian, and Arch Linux. Look for the package called
borgbackup (except for Arch Linux, where it’s called
borg). For example, on Ubuntu:
apt-get install borgbackup
Once Borg is installed, there are only three steps you need to take. The first step is only needed for the very first backup, and the third step is only needed when you actually need to restore a backup.
The first step is designating a particular directory as the place where you’re going to store your backups:
borg init /path/to/backups
The second step is actually creating a backup of a particular directory. In this one, we’re going to back up three directories — named ~/one, ~/two, and ~/three — into an archive named after the current date, 2016-06-22:
borg create /path/to/backups::2016-06-22 ~/one ~/two ~/three
The next day, I could create another backup:
borg create /path/to/backups::2016-06-23 ~/one ~/two ~/three
And when you need to restore a backup:
borg extract /path/to/backups::2016-06-23
Easy, isn’t it? Visit the Borg Quickstart page to learn more, including how to see the contents of a given archive, deleting archives, automating backups, and more.
For One-Time Backups
Between automated and manual backups, we really recommend the automated route because it can be all too easy to become lazy or forget to make backups, which can put your data at risk. Nobody ever intends to develop bad security habits , but it happens.
But for bigger backups, such as copying an entire disk drive for redundancy, a one-time manual action is more practical. That’s when these options come in handy.
dd is a command-line utility that’s available on all Unix-based operating systems. There is no real reason behind why it’s called “dd”, but some have nicknamed it as “disk destroyer” because it can be incredibly risky to use.
Long story short, if you aren’t careful, you could end up wiping one of your disk drives . That’s not a fun situation to be in, especially if you were aiming to back up that drive. Ouch.
But when used properly, it’s completely safe and functional. The command only requires three parameters (four if you include
sudo, which you most likely need to):
sudo dd if=/path/to/first/drive of=/path/to/second/drive
For example, in practice, you might use:
sudo dd if=/dev/sda1 of=/dev/sdb1
In this hypothetical case, /dev/sda1 is the input drive (or source drive) and /dev/sdb1 is the output drive (or the destination drive). Whatever is in the input drive will be cloned on the output drive. Backups have never been easier than this.
The tricky part is finding the right paths to the right disk drives. Fortunately, most distros come with a disk management app that you can use to figure out what those paths are. Here’s how I found my disk drive’s path using the Disks app on Linux Mint:
Note that this will actually overwrite everything on the destination drive, so be very careful that you have the right drive AND that you don’t make any typos when using the command.
The other way to clone a disk drive in Linux is to use a nifty application called Clonezilla. It comes in two varieties: Clonezilla Live (for single machines) and Clonezilla SE (for dozens or hundreds of computers at a time). Unless you run a big business, you’ll want Clonezilla Live.
In order to use it, however, you’ll need to set up Clonezilla on a live CD, DVD, or USB drive. Not sure how to do that? Just follow the how to set up Clonezilla Live page and you’ll be good to go.
Once the live CD, DVD, or USB drive is ready, just stick it into the computer you want to back up and let it boot. If it doesn’t boot using the live media, consult our guide on changing the boot order of your PC .
If it boots up properly, you’ll be presented with a step-by-step wizard that guides you through the process. However, we recommend reading the Clonezilla Live usage guide beforehand so you can familiarize yourself and avoid any potential mistakes.
One more thing: some disk drives are better for backups than others. For best performance, check out our guide to picking a data drive for backups .
Using Copy & Paste
If dd and Clonezilla seem like overkill for you, then there is another option. If all you want is a one-time backup of a set of documents so that you can archive them indefinitely, and if those documents aren’t going to change at all, then…
…there’s nothing wrong with using copy & paste.
It’s all about using the right tool for the job. It doesn’t make sense to copy and paste an entire hard drive onto another, which is why apps like Clonezilla exist. But it’s equally unreasonable to use Clonezilla to copy a single file or directory.
Take those documents and copy them to an external drive, then copy them to a cloud storage service for extra protection. Sometimes it really is as easy as that. Don’t make it harder than it has to be.
What’s Your Backup Method?
Again I ask, would you be okay if your disk drive died right this moment? What if your house burned down or your cloud storage provider disappeared overnight? Are you keeping data backups, and are you keeping enough of them?
Now that you know these options exist, you have no excuse for not taking care of your data — especially because there are free options like CrashPlan and Duplicati that can handle everything without any effort on your part.
Don’t wait until it’s too late.
Do you keep regular backups? If so, what methods do you use and where exactly do you keep those backups? Have any tips for those who DON’T keep backups? Let us know in a comment below!