Make the EXCLUDES/ALWAYS file optional
[wizbackup.git] / wizbackup-driver
index 1709284a3e8469869acae708f07709d0e41bba2a..6fbc2fdd2c257eb393d2668d1e99b104f7729638 100755 (executable)
@@ -17,9 +17,9 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-if [ $# -lt 1 ]
+if [ $# -lt 2 ]
 then
-       echo "Usage: $0 [MACHINE-TAB]"
+       echo "Usage: $0 [MACHINE-TAB] [DEST]"
        echo
        echo "The MACHINE-TAB file contains hostnames of machines to be backed up, one per line."
        echo "Empty lines and lines starting with '#' are ignored."
@@ -27,12 +27,12 @@ then
 fi
 
 HOSTS=`cat $1 | egrep -v '^#|^ *$'`
+DEST="$2"
 
 LOGGROUP=`basename $1`
 LOGDIR=/var/log/wizbackup
 LOCKDIR=/var/lock/wizbackup
-DEST=/backup
-EXCLUDES_DIR=$DEST/EXCLUDE
+EXCLUDES_DIR="$DEST/EXCLUDE"
 
 today=`date +"%Y%m%d"`
 mkdir -p $LOGDIR
@@ -45,10 +45,10 @@ else
 fi
 
 for host in $HOSTS; do
-       opts="--exclude-from $EXCLUDES_DIR/ALWAYS"
-       if [ -f "$EXCLUDES_DIR/$host" ]; then
-               opts="$opts --exclude-from $EXCLUDES_DIR/$host"
-       fi
+       opts=""
+       for file in "$EXCLUDES_DIR/ALWAYS" "$EXCLUDES_DIR/$host"; do
+               [ -f $file ] && opts="$opts --exclude-from $file"
+       done
 
        start_time=$(date +%s)
        flock $LOCKDIR/$host wizbackup "$host:/" "$DEST/$host/" $opts >>$LOGFILE 2>&1