Example 2: Backup of multiple directories

For historical reasons, storeBackup.pl can only handle one source directory. But this drawback transforms to a feature when using option followLinks, because everything then becomes very easy and flexible.

You can also use the well known mechanism of includeDirs and exceptDirs well-established from other programs. But that is by way of comparison uncomfortable and nasty to handle.

To use lateLinks, execute the following steps (I assume, you will backup /home/greg/important, /home/jim and /etc to /backup/stbu. You can change this later very easy.): First of all, make a special directory, e.g., /opt/stbu. Let's also assume that you stored storeBackup at /opt/storeBackup:

# mkdir /opt/stbu
# cd /opt/stbu
# ln -s /opt/storeBackup storeBackup
# ln -s /home/jim home_jim
# ln -s /etc etc
# ln -s /home/greg/important home_greg_important
# ln -s . backup

With the first symbolic link we make sure, that storeBackup itself is part of the backup. So it is possible to restore it later with cp and then use storeBackupRecover.pl for the rest.
The last symbolic link is a trick to get an exact copy of /opt/stbu in the backup.
Now, write a short script to start storeBackup.pl. Store it at /opt/stbu/backup.sh:

/opt/storeBackup/bin/storeBackup.pl -s /opt/stbu -b /backup/stbu \
    -S . -l /tmp/storeBackup.log --followLinks 1

Option --followsLinks 1 tells storeBackup to use the first level of symbolic links exactly like directories. Therefore, you will find home_jim as a directory entry in your backup.

Finally, set the permissions of the script:

chmod 700 /opt/backup/backup.sh

Whenever you start this script, you will backup the wanted directories and your short script. You need to be root to have the required permissions to read the directories in this example. And naturally you need write permissions in /backup/stbu.

Now, you can simply change the directories to save or not to save by deleting or creating symbolic links in this directory.

Heinz-Josef Claes 2014-04-20