We've been using an NFS share for cpbackups for a while, but sometimes we find that servers end up with multiple mounts of the same share being created. I can only assume this has something to do with the WHM » Backup »
Configure Backup » Remount/Unmount Backup Drive activity - possibly finding a dead NFS connection and then trying to create another.
The NFS share is mounted at boot, and is checked by us periodically anyway. So, anyway, I would prefer to just check the /backup mount point ourselves, and if anything looks wrong, just kill the cpbackup process. This script was a quick attempt, but it won't kill the cpbackup process when I test it. I've checked that CPPID does indeed get the correct pid of cpbackup, but it just fails to stop the backup from running. I thought a child process could kill a parent, but maybe I'm wrong. Any ideas?
Configure Backup » Remount/Unmount Backup Drive activity - possibly finding a dead NFS connection and then trying to create another.
The NFS share is mounted at boot, and is checked by us periodically anyway. So, anyway, I would prefer to just check the /backup mount point ourselves, and if anything looks wrong, just kill the cpbackup process. This script was a quick attempt, but it won't kill the cpbackup process when I test it. I've checked that CPPID does indeed get the correct pid of cpbackup, but it just fails to stop the backup from running. I thought a child process could kill a parent, but maybe I'm wrong. Any ideas?
Code:
#!/bin/bash
# Check for a single /backup mount - if it does not exist, kill the backup
# if more than one exists, kill the backup
MOUNTQTY="$(/bin/mount | grep 'on /backup' | wc -l)"
if [ ${MOUNTQTY} -ne 1 ]; then
# Kill the backup job
CPPID="$(/sbin/pidof cpbackup)"
kill $CPPID
echo -e "/backup was not mounted correctly or at all. Mount output: \n\n`/bin/mount`" | /bin/mail -s "cpbackup process ${CPPID} killed on `/bin/hostname`" [email protected]
fi