Everyone knows they should make regular backups of their data. But hardly anyone is as diligent with backups as they should be. Part 1 of this two-part series covers external backup media, and bending udev so that backup devices will have persistent names.
Everyone knows they should make regular backups of their data. But hardly anyone is as diligent with backups as they should be. So in this two-part series we're going to learn some nice simple methods for making regular backups on single PCs or small networks. Part 1 covers external backup media, and bending
to your will so that your backup devices will have persistent names. Part 2 will reveal fast, easy, reliable ways to run your backups, both automated and on-demand by clicking a button.
The type of backups we're going to make are also easy to restore files from, which is the whole point of having backups in the first place. The backups we're going to make are for short-term archiving, which means the useful life of your backup media. Making data archives for the ages is a separate problem; our goal here is to be able to make easy, fast backups, and to quickly recover from a hardware failure, theft, and other immediate problems.
To follow my excellent backup scheme you're going to need a few things:
- A reasonably modern PC that supports USB 2.0
- GParted, the excellent graphical partition editor
- An external USB storage device: SATA or PATA hard drive, USB pen drive, or Compact Flash
- Rootly powers for the initial setup
You can purchase external hard drive enclosures that will hold any SATA or PATA hard drive, or you might prefer all-in-one external drives. The all-in-ones often come with Windows- and Mac-only backup software, which is not a problem because we do not need their silly software. You may need to reformat them, as some of them are formatted in NTFS or some other filesystem you don't want. This is where GParted earns its keep: it's the best graphical partitioning and formatting tool there is on any platform. Just plug in your external storage drive, make sure it's unmounted, and then partition and format it as you like.
The easiest way is to format it as FAT16 or FAT32, because using FAT saves you from having to set up user permissions. FAT filesystems don't support any kind of access controls, ownership, or permissions. This means you'll be able to easily access your backup media from any computer. FAT16 shouldn't be used on media larger than 512 megabytes because it wastes a lot of space.
Next: Creating a Filesystem With GParted »
Use the upper-right dropdown menu in GParted to select the correct physical drive. If you see a little padlock icon that means the filesystem is mounted. You can try unmounting it in GParted with the right-click menu, but sometimes this doesn't work. Your particular desktop environment or window manager may have its own graphical tools for mounting/unmounting filesystems. The safe and sure way is the command-line commando way:
# umount /dev/sdc1
GParted tells you the correct device name to use. Then click GParted -> Refresh Devices, and then you can partition and format.
Depending on how your particular flavor of Linux has customized
, it is possible that removable USB devices won't always be assigned the same names when you plug them in. You need them to always be the same when you run backup programs. The correct way is to configure
to handle this. Ubuntu, Fedora, Red Hat, Mandriva, PCLinuxOS, and doubtless many more have an easy way to control this: simply add a unique device label to your backup partition. For example, suppose you're using a Compact Flash card for your backups. You'll need the tools specific to your filesystem to do this, so for FAT16/32 fetch the
package. First add an entry like this to
to map a Windows-style drive letter to your filesystem. You may use any letter:
# Lexar compact flash
drive u: file="/dev/sdc1"
Then create your new device label:
# mlabel u:
Volume has no label
Enter the new volume label : backup1
Verify it this way:
$ mlabel -s u:
Volume label is BACKUP1
Now when you plug in your Compact Flash card it will automatically be mounted at
/media/BACKUP1. (Sorry, I don't know how to make MS-DOS disklabels not shout at you; you're stuck with uppercase.)
What if your particular flavor of Linux does not do this? Writing good
udev rules is something we'll cover in detail soon, so in the meanwhile you can resort to good old
/etc/fstab. First create the
/media/backup1 directory, then make an entry in
/etc/fstab like this:
# Lexar 2G compact flash, backup1
LABEL=BACKUP1 /media/backup1 vfat user,noatime,noauto,rw,dev,exec,suid 0 0
You'll have to mount it manually. Any user should be able to mount and unmount the device like this:
$ mount /media/backup1
$ umount /media/backup1
Don't worry, our ace backup scheme can handle this with ease. Come back next week to find out how.
This article was first published on LinuxPlanet.com.