Zionetrix::Git
Repositories
Help
Report an Issue
backuppc-run-backup
Code
Commits
Branches
Tags
Search
Tree:
1ce7484
Branches
Tags
master
backuppc-run-backup
run-all-backup
add -h/--help parameter on all scripts
Benjamin Renard
commited
1ce7484
at 2012-03-22 16:56:43
run-all-backup
Blame
History
Raw
#!/bin/bash BCKP_BIN=/usr/local/sbin/run-backup BCKP_DIR=/var/lib/backuppc/pc TYPE=$1 DEBUG=0 [ "$2" == "-d" ] && DEBUG=1 function usage() { [ -n "$1" ] && echo "[ERROR] $1" > /dev/stderr && echo echo "usage : $0 [-h|--help] [incr|FULL] [-d]" [ -n "$1" ] && exit 1 || exit 0 } [ ! -n "$TYPE" -o "$TYPE" == "-h" -o "$TYPE" == "--help" ] && TYPE=full if [ "$TYPE" == "incr" -o "$TYPE" == "INCR" ] then ttype="incr" elif [ "$TYPE" == "full" -o "$TYPE" == "FULL" ] then ttype="full" else usage "backup type not recognized (valid value : incr or full)" fi verb="" [ $DEBUG -eq 1 ] && verb="-d" && echo "$( date ) - [DEBUG] Run $ttype backup of all machines" ERROR=no for path in /var/lib/backuppc/pc/* do [ ! -d "$path" ] && continue machine=$( basename $path ) [ $DEBUG -eq 1 ] && echo "$( date ) - [DEBUG] Run $ttype backup of $machine" $BCKP_BIN $machine $ttype $verb res=$? [ $DEBUG -eq 1 ] && echo "$( date ) - [DEBUG] End of $ttype backup of $machine. Return code : $res" if [ $res -ne 0 ] then echo "[ERROR] Error during $ttype backup of $machine (Return code : $res)" > /dev/stderr ERROR=YES fi done [ $DEBUG -eq 1 ] && echo "$( date ) - [DEBUG] End of $ttype backup of all machines. Error : $ERROR" if [ "$ERROR" != "no" ] then echo "[ERROR] Error during $ttype backup of all machines" exit 2 fi