#!/bin/bash # now that we have vast amounts of storage online, we can # blindly copy /home /etc, et al to the WD backup # first, we need to ensure that the BackupDev is online direct_mail() { TARGET_MAILSERVER=mail.mycompany.com (sleep 20; cat $1) | /usr/bin/nc $TARGET_MAILSERVER 25 } WD_ONLINE=$(df -h | grep sdc | wc -l) BACKUPCOMM="cp -a --parents" BACKUPDEV="/mnt/backup" if [[ $WD_ONLINE -gt 0 ]]; then logger "WD Backup detected. Beginning backup" for DIR in /home /etc /root /usr/local/bin /var; do #for DIR in /usr/local/bin; do $BACKUPCOMM $DIR $BACKUPDEV done umount $BACKUPDEV logger "backup completed. $BACKUPDEV umounted" else logger "COULD NOT FIND WD BACKUP. ABORTING BACKUP" ERRFILE=/root/errors/socket_missing.txt direct_mail $ERRFILE fi