CLI magic: got backup?

62

Author: Joe Barr

You meet the nicest people at the command line: no posturing, no nonsense, just a “get the job done” mentality that seems to get lost when the focus moves away from real functionality to making pretty windows. Get too far away from computing’s core values and you could end up with a bug-ridden, security-free, viral infection magnet of an environment. Oh, wait. That’s already been done. This week we’ll meet one of those nice people you can meet at the CLI and take a look at a command line tool for the most fundamental — and the most overlooked — part of personal computing: making backups.

Quick. When is the last time you backed up your system? Unless you are a system administrator by trade, I bet 95% of you haven’t done so recently. If you suffer a hard drive crash, you stand to lose all your recent email, work, notes, photos, bookmarks, and whatever. One reason for that might be the paucity of a easy to use backup tools. Let’s bury that reason once and for all.

I found two CLI tools with the same name: Simple Backup. One was written as a shell script, the other was written in Perl. The GPLd shell script — written by Tim Wright in New Zealand — doesn’t seem to have been maintained the past year so I decided to focus on the Perl script, written by Miguel Angelo Martins Leite.

After downloading the tarball from the website and decompressing it, installation was as straightforward as one might hope. An example configuration file is included with the download. All that is required is that you modify the configuration to indicate what compression routine you want to use — if any –, point to the directory to be backed up, and to the directory where the resulting backup and log files should be placed.

Assuming that you have moved of copied “simplebackup.pl” to a directory in your path, you can run the program and backup a directory as specified in a configuration file by entering the following at the command line:

simplebackup.pl --conf /path/configuration.file

If you remember the first installment in this series, you might consider making an alias to reduce the command to something a little easier to type. Like “backup” for example. Or perhaps you just want to run it every Sunday morning at 2 AM. Review the column on cron in this series if you do.

I corresponded with Miguel by email while writing this story and took advantage of his friendliness to ask him a few questions. I asked if he had based his program on the shell script by Tim Wright mentioned at the top. He said no, it wasn’t until after he released his own that he discovered there were other backups of the same name. He also told me that a few hundred people had downloaded it.

When I asked him what inspired him to write it, he told me it was his own needs for a backup solution, both at work where Windows is used and at home on his Linux server. He continued:

So I started programming a cross-platform solution that works exactly the same
in Linux/Unix and in Windows. Perl is a real winner in this respect, and much
more simple that let’s say Java. Plus since i don’t want to spend all day doing backups, I wanted a program that just worked. Simplebackup might not be the cutest program on earth and of course it could be better, but it does the job working reliably and fully unattended.

Since I’m a strong believer in Open Source I wanted to share it will everyone,
this is a small thanks to all the Open Source community.

I really must say thanks to my friends and girlfriend, they had some help,
tips and support, and of course once again to the Open Source community that
has created so much good work.

I asked Miguel just one more question: would he encourage Linux noobies to venture out of the GUI and onto the CLI now and then. He said “I wouldn’t exactly like to encourage people to use the CLI, using a GUI is fine, but I would like people to remember that not all the (computer) problems in the world are solved by pressing buttons. What matters is solving problems, and in this respect the CLI works fine for many situations, it’s not old technology.

I have to agree. By the way, if this backup solution doesn’t meet your needs, there are any number of others out there, most of them available only on the command line.