#!/bin/bash # # bpcbackup # Version: __appVersion__ # # Copyright (C) 2008 by Titanium Mirror, Inc. # Author: R. Steve McKown # # A wrapper script for bpcdump, designed to be called from root's crontab # on the HNs. Only the HN hosting the BPC VE will do anything. VEID=1158 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:$PATH # Complain if this script is running on a server not configured with OpenVZ if [ ! -x /usr/sbin/vzctl ]; then echo "Host $(hostname) has bpcbackup installed, but is not an HN" >&2 exit 1 fi # Silently exit if this script is running on an HN but not currently hosting # the BPC VE. if vzctl status "$VEID" 2>/dev/null | grep -q deleted; then exit 0 fi # OK, we're an HN and we're hosting the VE. Run bpcbackup. When it returns, # we want to unmount the esata drive to reduce the chance of damage to the # backup data. Note, however, that esata must already be mounted or bpcdump # will error. This is correct, since we cannot auto-mount esata, since it # has to be physically connected first, and may require authentication on mount # if the volume is encrypted. /usr/local/bin/bpcdump ret=$? /usr/local/bin/esata umount ret2=$? [ "$ret" != "0" ] && exit $ret [ "$ret2" != "0" ] && exit $ret2 exit 0