Linux Backup with Back In Time

Here I will describe how to do scheduled automatic backups to an external hard drive on a Debian/Ubuntu Linux computer with the Back In Time system.

First install the package:

sudo aptitude install backintime-gnome

Preparing the Hard Drive

Plug in your USB/ESATA/FireWire hard drive into your linux computer, then do a:

dmesg | tail

to note the block device, such as /dev/sdd.

Next you will want to partition it. Use cfdisk or gparted.

Make one primary partition of type Linux (83) that is the size of the drive.

Next format it with your favorite file system.

Use a command such as:

sudo mkfs.ext4 /dev/sdd1

Now let's mount it. We are going to mount it under /media so that the updatedb cron job does not index it and clutter your locate db with your backup files. We are also going to mount it by UUID so that the order you plug in your devices, the presence of hubs, etc. does not affect mounting.

First make the mount point:

sudo mkdir /media/backup

Then get the UUID of the new partition:

sudo blkid /dev/sdd1

Now add the mount point to /etc/fstab using the UUID from the previous step:

UUID=e3b623e7-2049-46cf-89aa-1152c38e08e8 /media/backup ext4 defaults,nofail

Now mount it!

sudo mount /media/backup

Remember to mount it when you plug your hard drive in.

If you know of a way to automount an fstab entry, please email me so I can add it here...

We are going to make the backup directory one level below the mount point so that having the drive disconnected tells Back In Time to not run the backup job, otherwise it would run the backup job on the root file system!

sudo mkdir /media/backup/snapshots

Setting up Back In Time

Now you're ready to run the Back In Time configuration program. Run:

ssh -X root@localhost backintime-gnome

Click the Settings button.

For "Where to save snapshots" select /media/backup/snapshots.

For "Schedule" I use "Every Day" at 03:00. Choose a time your machine is likely to be idle and the hard drive is likely to be plugged in.

Click the Include tab. Add folders such as /home and /etc and any others you want to back up.

Press "Ok" and close the program.

Press Ctrl-C to close the ssh session.

And you're done!

I also highly recommend installing anacron:

sudo aptitude install anacron

especially on a laptop, because Back In Time runs from cron. This way if your laptop is off or asleep when the job is supposed to run, your backup will still run at some future time.

Final Thoughts

Backups can seriously save your arse. Hard drives and SSDs fail. Alot.

Now Mac OS X and Windows have attractive built-in backup options, Time Machine and Windows Backup, respectively. Time Machine is unmatched in power and simplicity. Windows Backup is not as shiny, but still does the job admirably.

With Back In Time, we now have a nice backup solution for Linux as well.

Enjoy the comfort of knowing that your data is safe.

Last modified: 2017-1-8 (日) at 9:14 pm