Management of pre-action Scripts

This page provides some tips on managing pre-action scripts. The information on this page may be modified for post action scripts. It is not the only or the best approach. It is simply hear as a starting point. If you have come up with better approach, then feel free to contribute to the LBackup project by improving this page.

Install pre-action script into multiple LBackup configuration directories

If you have a number of backup configuration directories. You may want to install a copy of a pre-action script into multiple backup configuration directories. Below one possible approach is outlined.

Assumptions

If want to achieve is slightly different to the assumptions made above that is fine; simply modify the commands provided to meet your needs. If you get stuck then let us know on the mailing list. You may need to alter some commands to make them work with different shell environments.

Step 1
Make a quick backup your configuration directory (never a bad idea anyway), so it is able to be restored should something go wrong.

tar -czvf /tmp/lbackup-config-backup-`date "+%Y-%m-%d_%H-%M-%S"`.tar.gz /etc/lbackup

The command above generates a file /tmp/lbackup-config-backup-dateandtime.tar.gz, which you should check and then move to somewhere else preferably offsite. If you would prefer to use a differnt utility to perform the backup go ahead; rsync, lbackup, cp are all possibilities. Do whatever works for you. Just check that what ever method you seattle on is preserving the meta-data you require.


Step 2
Check the places you are coping to are what you expect.

ls -1d /etc/lbackup/*/resources/pre-actions/ | grep -v /etc/lbackup/example_backup_config

If the list generated is the correct list of where you want to copy the pre-action script then proceed. If not then work out why it the list is not correct. Do not proceed to the next step until that list is correct. If your backup configuration directories are located some where else in the file system then simply modify this command as required (eg. ls -ld /backup_configuations/*/resources/pre-actions/).

Step 3
Lets copy that script.

ls -1d /etc/lbackup/*/resources/pre-actions/ | grep -v /etc/lbackup/example_backup_config | xargs -n 1 cp -i -v /etc/lbackup/example_backup_config/resources/exmaple-scripts/pre-actions/BACKUP-200-ReportBackupDiskUsagePercentage.bash 

This should report all the files which are copied across. Note that the space at the end of that command may be important. If you want to copy a different pre-action script then change the command appropriately. If you need assistance then post to the mailing list.

If you have nested (grouped) backup configurations directories within directories in an effort to make management easier then adding some additional wild card characters should allow the approach outlined above to work. Also, if you have placed your configuration directories somewhere other than /etc/lbackup then you will probably be able to leave out the grep command and alter the ls command so that the destination directory list generated in step 2 works for you (eg. ls -ld /etc/lbackup/*/*/resources/pre-actions/).

In essence all we are doing is coping a file into multiple directories. There are many ways to achieve the same result. If you have any tips or would like to improve the LBackup documentation then your contribution is most welcomed.

Finally, if you want to overwrite existing pre-actions with the same name then you should remove the -i argument from the cp command.