Saturday 2 July 2011

Updated NFS backup script

We had a problem that when the NFS where all the backups on our network go is offline, a huge TAR is made in the root of the Linux file server. Not good!

After some searching and playing with SH (beware! different from BASH) scripts, I came up with this solution:

#!/bin/sh

/usr/bin/MountSaturnBackup
sleep 2

DT=`stat -f -L -c %T /mnt/backup`
if [ "$DT" = "nfs" ]; then
 tar cpf /mnt/backup/FullBackup.tar --same-owner --exclude=/network/backups/Jupiter --exclude=/var/cache/zoneminder/events/* --exclude=/proc/* --exclude=/media/* --exclude=/d$
fi


The correct thing to do would be to add an else statement and have the script send me an email. I'll look at that later....

No comments: