March 21, 2019

Linux Backups For Real People, Part 2

Single-User Backups

  • November 8, 2007
  • By Carla Schroder

Last week we got our backup hardware in order, so today we're going into detail on backing up our data to a locally-attached backup device. We'll learn how to configure which files to backup, and create an easy one-word-command backup.

I like to divide backups into two categories: system and data. This little series is about data backups; check out MondoRescue for easy system cloning and disaster recovery.

We're not going to use any fancy, complicated specialized backup applications, but plain old reliable efficient rsync. rsync transfers only changes, so after your first run subsequent backups are very fast. It creates ordinary Linux directory and file structures, so restoring files is done via your usual favorite file copying method, rather than needing special backup software and weirdo commands.

Your backup drive should be a minimum of two times larger than the total of the files you want to backup. Graphical file managers will tell you how large your directories are, though I like the good old du (disk used) and df (disk free) commands because they're fast, and they work the same way on all Linuxes. Just fire up a terminal and run this command to see the used and free space on your local filesystems:

$ df -hlx tmpfs
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1              14G  2.4G   11G  18% /
/dev/sda1              31G  9.3G   21G  32% /home
/dev/hda2             4.5G  543M  3.8G  13% /var

You'll need du for individual files and directories, as this example for my finances directory shows:

$ du -hs finances
8.2M    finances

Leave off the -s to see the files in the directory displayed, and their sizes.

Most Popular LinuxPlanet Stories