From 4ecaae94054c4eb919ddbd45904d834383a09558 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 22 May 2009 14:50:52 +0200 Subject: Make all indentation consistent. Previously, there were many indentation styles in use: Real tabs, 2, 3 or 4 spaces, mixing these within the same file, function or even within a single line. This commit changes all bash scripts in the handlers, src and lib dirs to use consistent indentation: three spaces are now used everywhere. Other files (e.g. Makefiles) are left untouched. Additionally, this commit removes all trailing whitespace. --- src/backupninja.in | 592 ++++++++++++++++++++++++++--------------------------- 1 file changed, 296 insertions(+), 296 deletions(-) (limited to 'src/backupninja.in') diff --git a/src/backupninja.in b/src/backupninja.in index 2a1b76e..ca5074c 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -22,31 +22,31 @@ ## FUNCTIONS function setupcolors () { - BLUE="\033[34;01m" - GREEN="\033[32;01m" - YELLOW="\033[33;01m" - PURPLE="\033[35;01m" - RED="\033[31;01m" - OFF="\033[0m" - CYAN="\033[36;01m" - COLORS=($BLUE $GREEN $YELLOW $RED $PURPLE $CYAN) + BLUE="\033[34;01m" + GREEN="\033[32;01m" + YELLOW="\033[33;01m" + PURPLE="\033[35;01m" + RED="\033[31;01m" + OFF="\033[0m" + CYAN="\033[36;01m" + COLORS=($BLUE $GREEN $YELLOW $RED $PURPLE $CYAN) } function colorize () { - if [ "$usecolors" == "yes" ]; then - local typestr=`echo "$@" | @SED@ 's/\(^[^:]*\).*$/\1/'` - [ "$typestr" == "Debug" ] && type=0 - [ "$typestr" == "Info" ] && type=1 - [ "$typestr" == "Warning" ] && type=2 - [ "$typestr" == "Error" ] && type=3 - [ "$typestr" == "Fatal" ] && type=4 - [ "$typestr" == "Halt" ] && type=5 - color=${COLORS[$type]} - endcolor=$OFF - echo -e "$color$@$endcolor" - else - echo -e "$@" - fi + if [ "$usecolors" == "yes" ]; then + local typestr=`echo "$@" | @SED@ 's/\(^[^:]*\).*$/\1/'` + [ "$typestr" == "Debug" ] && type=0 + [ "$typestr" == "Info" ] && type=1 + [ "$typestr" == "Warning" ] && type=2 + [ "$typestr" == "Error" ] && type=3 + [ "$typestr" == "Fatal" ] && type=4 + [ "$typestr" == "Halt" ] && type=5 + color=${COLORS[$type]} + endcolor=$OFF + echo -e "$color$@$endcolor" + else + echo -e "$@" + fi } # We have the following message levels: @@ -65,71 +65,71 @@ echo_debug_msg=0 usecolors=yes function printmsg() { - [ ${#@} -gt 1 ] || return - - type=$1 - shift - if [ $type == 100 ]; then - typestr=`echo "$@" | @SED@ 's/\(^[^:]*\).*$/\1/'` - [ "$typestr" == "Debug" ] && type=0 - [ "$typestr" == "Info" ] && type=1 - [ "$typestr" == "Warning" ] && type=2 - [ "$typestr" == "Error" ] && type=3 - [ "$typestr" == "Fatal" ] && type=4 - [ "$typestr" == "Halt" ] && type=5 - typestr="" - else - types=(Debug Info Warning Error Fatal Halt) - typestr="${types[$type]}: " - fi - - print=$[4-type] - - if [ $echo_debug_msg == 1 ]; then - echo -e "$typestr$@" >&2 - elif [ $debug ]; then - colorize "$typestr$@" >&2 - fi - - if [ $print -lt $loglevel ]; then - logmsg "$typestr$@" - fi + [ ${#@} -gt 1 ] || return + + type=$1 + shift + if [ $type == 100 ]; then + typestr=`echo "$@" | @SED@ 's/\(^[^:]*\).*$/\1/'` + [ "$typestr" == "Debug" ] && type=0 + [ "$typestr" == "Info" ] && type=1 + [ "$typestr" == "Warning" ] && type=2 + [ "$typestr" == "Error" ] && type=3 + [ "$typestr" == "Fatal" ] && type=4 + [ "$typestr" == "Halt" ] && type=5 + typestr="" + else + types=(Debug Info Warning Error Fatal Halt) + typestr="${types[$type]}: " + fi + + print=$[4-type] + + if [ $echo_debug_msg == 1 ]; then + echo -e "$typestr$@" >&2 + elif [ $debug ]; then + colorize "$typestr$@" >&2 + fi + + if [ $print -lt $loglevel ]; then + logmsg "$typestr$@" + fi } function logmsg() { - if [ -w "$logfile" ]; then - echo -e `LC_ALL=C date "+%h %d %H:%M:%S"` "$@" >> $logfile - fi + if [ -w "$logfile" ]; then + echo -e `LC_ALL=C date "+%h %d %H:%M:%S"` "$@" >> $logfile + fi } function passthru() { - printmsg 100 "$@" + printmsg 100 "$@" } function debug() { - printmsg 0 "$@" + printmsg 0 "$@" } function info() { - printmsg 1 "$@" + printmsg 1 "$@" } function warning() { - printmsg 2 "$@" + printmsg 2 "$@" } function error() { - printmsg 3 "$@" + printmsg 3 "$@" } function fatal() { - printmsg 4 "$@" - exit 2 + printmsg 4 "$@" + exit 2 } function halt() { - printmsg 5 "$@" - exit 2 + printmsg 5 "$@" + exit 2 } msgcount=0 function msg { - messages[$msgcount]=$1 - let "msgcount += 1" + messages[$msgcount]=$1 + let "msgcount += 1" } # @@ -158,7 +158,7 @@ function check_perms() { echo "Configuration files must be owned by root! Dying on file $file" fatal "Configuration files must be owned by root! Dying on file $file" fi - + if [ "$wperm" != '---' ]; then echo "Configuration files must not be world writable/readable! Dying on file $file" fatal "Configuration files must not be world writable/readable! Dying on file $file" @@ -180,12 +180,12 @@ function check_perms() { # simple lowercase function function tolower() { - echo "$1" | tr '[:upper:]' '[:lower:]' + echo "$1" | tr '[:upper:]' '[:lower:]' } # simple to integer function function toint() { - echo "$1" | tr -d '[:alpha:]' + echo "$1" | tr -d '[:alpha:]' } # @@ -206,39 +206,39 @@ nowdayofweek=`LC_ALL=C date +%A` nowdayofweek=`tolower "$nowdayofweek"` function isnow() { - local when="$1" - set -- $when - - [ "$when" == "manual" ] && return 0 - - whendayofweek=$1; at=$2; whentime=$3; - whenday=`toint "$whendayofweek"` - whendayofweek=`tolower "$whendayofweek"` - whentime=`echo "$whentime" | @SED@ 's/:[0-9][0-9]$//' | @SED@ -r 's/^([0-9])$/0\1/'` - - if [ "$whendayofweek" == "everyday" -o "$whendayofweek" == "daily" ]; then - whendayofweek=$nowdayofweek - fi - - if [ "$whenday" == "" ]; then - if [ "$whendayofweek" != "$nowdayofweek" ]; then - whendayofweek=${whendayofweek%s} - if [ "$whendayofweek" != "$nowdayofweek" ]; then - return 0 - fi - fi - elif [ "$whenday" != "$nowday" ]; then - return 0 - fi - - [ "$at" == "at" ] || return 0 - [ "$whentime" == "$nowtime" ] || return 0 - - return 1 + local when="$1" + set -- $when + + [ "$when" == "manual" ] && return 0 + + whendayofweek=$1; at=$2; whentime=$3; + whenday=`toint "$whendayofweek"` + whendayofweek=`tolower "$whendayofweek"` + whentime=`echo "$whentime" | @SED@ 's/:[0-9][0-9]$//' | @SED@ -r 's/^([0-9])$/0\1/'` + + if [ "$whendayofweek" == "everyday" -o "$whendayofweek" == "daily" ]; then + whendayofweek=$nowdayofweek + fi + + if [ "$whenday" == "" ]; then + if [ "$whendayofweek" != "$nowdayofweek" ]; then + whendayofweek=${whendayofweek%s} + if [ "$whendayofweek" != "$nowdayofweek" ]; then + return 0 + fi + fi + elif [ "$whenday" != "$nowday" ]; then + return 0 + fi + + [ "$at" == "at" ] || return 0 + [ "$whentime" == "$nowtime" ] || return 0 + + return 1 } function usage() { - cat << EOF + cat << EOF $0 usage: This script allows you to coordinate system backup by dropping a few simple configuration files into @CFGDIR@/backup.d/. Typically, this @@ -257,18 +257,18 @@ The following options are available: -n, --now Perform actions now, instead of when they might be scheduled. No output will be created unless also run with -d. - --run FILE Execute the specified action file and then exit. + --run FILE Execute the specified action file and then exit. Also puts backupninja in debug mode. - + When in debug mode, output to the console will be colored: EOF - usecolors=yes - colorize "Debug: Debugging info (when run with -d)" - colorize "Info: Informational messages (verbosity level 4)" - colorize "Warning: Warnings (verbosity level 3 and up)" - colorize "Error: Errors (verbosity level 2 and up)" - colorize "Fatal: Errors which halt a given backup action (always shown)" - colorize "Halt: Errors which halt the whole backupninja run (always shown)" + usecolors=yes + colorize "Debug: Debugging info (when run with -d)" + colorize "Info: Informational messages (verbosity level 4)" + colorize "Warning: Warnings (verbosity level 3 and up)" + colorize "Error: Errors (verbosity level 2 and up)" + colorize "Fatal: Errors which halt a given backup action (always shown)" + colorize "Halt: Errors which halt the whole backupninja run (always shown)" } ## @@ -279,89 +279,89 @@ EOF ## function process_action() { - local file="$1" - local suffix="$2" - local run="no" - setfile $file - - # skip over this config if "when" option - # is not set to the current time. - getconf when "$defaultwhen" - if [ "$processnow" == 1 ]; then - info ">>>> starting action $file (because of --now)" - run="yes" - elif [ "$when" == "hourly" ]; then - info ">>>> starting action $file (because 'when = hourly')" - run="yes" - else - IFS=$'\t\n' - for w in $when; do - IFS=$' \t\n' - isnow "$w" - ret=$? - IFS=$'\t\n' - if [ $ret == 0 ]; then - debug "skipping $file because current time does not match $w" - else - info ">>>> starting action $file (because current time matches $w)" - run="yes" - fi - done - IFS=$' \t\n' - fi - debug $run - [ "$run" == "no" ] && return - - let "actions_run += 1" - - # call the handler: - local bufferfile=`maketemp backupninja.buffer` - echo "" > $bufferfile - echo_debug_msg=1 - ( - . $scriptdirectory/$suffix $file - ) 2>&1 | ( - while read a; do - echo $a >> $bufferfile - [ $debug ] && colorize "$a" - done - ) - retcode=$? - # ^^^^^^^^ we have a problem! we can't grab the return code "$?". grrr. - echo_debug_msg=0 - - _warnings=`cat $bufferfile | grep "^Warning: " | wc -l` - _errors=`cat $bufferfile | grep "^Error: " | wc -l` - _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l` - _halts=`cat $bufferfile | grep "^Halt: " | wc -l` - - ret=`grep "\(^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile` - rm $bufferfile - if [ $_halts != 0 ]; then - msg "*halt* -- $file" - errormsg="$errormsg\n== halt request from $file==\n\n$ret\n" - passthru "Halt: <<<< finished action $file: FAILED" - elif [ $_fatals != 0 ]; then - msg "*failed* -- $file" - errormsg="$errormsg\n== fatal errors from $file ==\n\n$ret\n" - passthru "Fatal: <<<< finished action $file: FAILED" - elif [ $_errors != 0 ]; then - msg "*error* -- $file" - errormsg="$errormsg\n== errors from $file ==\n\n$ret\n" - error "<<<< finished action $file: ERROR" - elif [ $_warnings != 0 ]; then - msg "*warning* -- $file" - errormsg="$errormsg\n== warnings from $file ==\n\n$ret\n" - warning "<<<< finished action $file: WARNING" - else - msg "success -- $file" - info "<<<< finished action $file: SUCCESS" - fi - - let "halts += _halts" - let "fatals += _fatals" - let "errors += _errors" - let "warnings += _warnings" + local file="$1" + local suffix="$2" + local run="no" + setfile $file + + # skip over this config if "when" option + # is not set to the current time. + getconf when "$defaultwhen" + if [ "$processnow" == 1 ]; then + info ">>>> starting action $file (because of --now)" + run="yes" + elif [ "$when" == "hourly" ]; then + info ">>>> starting action $file (because 'when = hourly')" + run="yes" + else + IFS=$'\t\n' + for w in $when; do + IFS=$' \t\n' + isnow "$w" + ret=$? + IFS=$'\t\n' + if [ $ret == 0 ]; then + debug "skipping $file because current time does not match $w" + else + info ">>>> starting action $file (because current time matches $w)" + run="yes" + fi + done + IFS=$' \t\n' + fi + debug $run + [ "$run" == "no" ] && return + + let "actions_run += 1" + + # call the handler: + local bufferfile=`maketemp backupninja.buffer` + echo "" > $bufferfile + echo_debug_msg=1 + ( + . $scriptdirectory/$suffix $file + ) 2>&1 | ( + while read a; do + echo $a >> $bufferfile + [ $debug ] && colorize "$a" + done + ) + retcode=$? + # ^^^^^^^^ we have a problem! we can't grab the return code "$?". grrr. + echo_debug_msg=0 + + _warnings=`cat $bufferfile | grep "^Warning: " | wc -l` + _errors=`cat $bufferfile | grep "^Error: " | wc -l` + _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l` + _halts=`cat $bufferfile | grep "^Halt: " | wc -l` + + ret=`grep "\(^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile` + rm $bufferfile + if [ $_halts != 0 ]; then + msg "*halt* -- $file" + errormsg="$errormsg\n== halt request from $file==\n\n$ret\n" + passthru "Halt: <<<< finished action $file: FAILED" + elif [ $_fatals != 0 ]; then + msg "*failed* -- $file" + errormsg="$errormsg\n== fatal errors from $file ==\n\n$ret\n" + passthru "Fatal: <<<< finished action $file: FAILED" + elif [ $_errors != 0 ]; then + msg "*error* -- $file" + errormsg="$errormsg\n== errors from $file ==\n\n$ret\n" + error "<<<< finished action $file: ERROR" + elif [ $_warnings != 0 ]; then + msg "*warning* -- $file" + errormsg="$errormsg\n== warnings from $file ==\n\n$ret\n" + warning "<<<< finished action $file: WARNING" + else + msg "success -- $file" + info "<<<< finished action $file: SUCCESS" + fi + + let "halts += _halts" + let "fatals += _fatals" + let "errors += _errors" + let "warnings += _warnings" } ##################################################### @@ -374,71 +374,71 @@ loglevel=3 ## process command line options while [ $# -ge 1 ]; do - case $1 in - -h|--help) usage;; - -d|--debug) debug=1;; - -t|--test) test=1;debug=1;; - -n|--now) processnow=1;; - -f|--conffile) - if [ -f $2 ]; then - conffile=$2 - else - echo "-f|--conffile option must be followed by an existing filename" - fatal "-f|--conffile option must be followed by an existing filename" - usage - fi - # we shift here to avoid processing the file path - shift - ;; - --run) - debug=1 - if [ -f $2 ]; then - singlerun=$2 - processnow=1 - else - echo "--run option must be followed by a backupninja action file" - fatal "--run option must be followed by a backupninja action file" - usage - fi - shift - ;; - *) - debug=1 - echo "Unknown option $1" - fatal "Unknown option $1" - usage - exit - ;; - esac - shift -done + case $1 in + -h|--help) usage;; + -d|--debug) debug=1;; + -t|--test) test=1;debug=1;; + -n|--now) processnow=1;; + -f|--conffile) + if [ -f $2 ]; then + conffile=$2 + else + echo "-f|--conffile option must be followed by an existing filename" + fatal "-f|--conffile option must be followed by an existing filename" + usage + fi + # we shift here to avoid processing the file path + shift + ;; + --run) + debug=1 + if [ -f $2 ]; then + singlerun=$2 + processnow=1 + else + echo "--run option must be followed by a backupninja action file" + fatal "--run option must be followed by a backupninja action file" + usage + fi + shift + ;; + *) + debug=1 + echo "Unknown option $1" + fatal "Unknown option $1" + usage + exit + ;; + esac + shift +done #if [ $debug ]; then -# usercolors=yes +# usercolors=yes #fi ## Load and confirm basic configuration values # bootstrap if [ ! -r "$conffile" ]; then - echo "Configuration file $conffile not found." - fatal "Configuration file $conffile not found." + echo "Configuration file $conffile not found." + fatal "Configuration file $conffile not found." fi # find $libdirectory libdirectory=`grep '^libdirectory' $conffile | @AWK@ '{print $3}'` if [ -z "$libdirectory" ]; then - if [ -d "@libdir@" ]; then - libdirectory="@libdir@" - else - echo "Could not find entry 'libdirectory' in $conffile." - fatal "Could not find entry 'libdirectory' in $conffile." - fi + if [ -d "@libdir@" ]; then + libdirectory="@libdir@" + else + echo "Could not find entry 'libdirectory' in $conffile." + fatal "Could not find entry 'libdirectory' in $conffile." + fi else - if [ ! -d "$libdirectory" ]; then - echo "Lib directory $libdirectory not found." - fatal "Lib directory $libdirectory not found." - fi + if [ ! -d "$libdirectory" ]; then + echo "Lib directory $libdirectory not found." + fatal "Lib directory $libdirectory not found." + fi fi # include shared functions @@ -482,15 +482,15 @@ getconf admingroup root init_vservers nodialog if [ ! -d "$configdirectory" ]; then - echo "Configuration directory '$configdirectory' not found." - fatal "Configuration directory '$configdirectory' not found." + echo "Configuration directory '$configdirectory' not found." + fatal "Configuration directory '$configdirectory' not found." fi [ -f "$logfile" ] || touch $logfile if [ "$UID" != "0" ]; then - echo "`basename $0` can only be run as root" - exit 1 + echo "`basename $0` can only be run as root" + exit 1 fi ## Process each configuration file @@ -507,34 +507,34 @@ actions_run=0 errormsg="" if [ "$singlerun" ]; then - files=$singlerun + files=$singlerun else - files=`find $configdirectory -follow -mindepth 1 -maxdepth 1 -type f ! -name '.*.swp' | sort -n` + files=`find $configdirectory -follow -mindepth 1 -maxdepth 1 -type f ! -name '.*.swp' | sort -n` - if [ -z "$files" ]; then - fatal "No backup actions configured in '$configdirectory', run ninjahelper!" - fi + if [ -z "$files" ]; then + fatal "No backup actions configured in '$configdirectory', run ninjahelper!" + fi fi for file in $files; do - [ -f "$file" ] || continue - [ "$halts" = "0" ] || continue - - check_perms ${file%/*} # check containing dir - check_perms $file - suffix="${file##*.}" - base=`basename $file` - if [ "${base:0:1}" == "0" -o "$suffix" == "disabled" ]; then - info "Skipping $file" - continue - fi - - if [ -e "$scriptdirectory/$suffix" ]; then - process_action $file $suffix - else - error "Can't process file '$file': no handler script for suffix '$suffix'" - msg "*missing handler* -- $file" - fi + [ -f "$file" ] || continue + [ "$halts" = "0" ] || continue + + check_perms ${file%/*} # check containing dir + check_perms $file + suffix="${file##*.}" + base=`basename $file` + if [ "${base:0:1}" == "0" -o "$suffix" == "disabled" ]; then + info "Skipping $file" + continue + fi + + if [ -e "$scriptdirectory/$suffix" ]; then + process_action $file $suffix + else + error "Can't process file '$file': no handler script for suffix '$suffix'" + msg "*missing handler* -- $file" + fi done ## mail the messages to the report address @@ -549,38 +549,38 @@ else doit=0 fi if [ $doit == 1 ]; then - debug "send report to $reportemail" - hostname=`hostname` - [ $warnings == 0 ] || subject="WARNING" - [ $errors == 0 ] || subject="ERROR" - [ $fatals == 0 ] || subject="FAILED" - - { - for ((i=0; i < ${#messages[@]} ; i++)); do - echo ${messages[$i]} - done - echo -e "$errormsg" - if [ "$reportspace" == "yes" ]; then - previous="" - for i in $(ls "$configdirectory"); do - backuploc=$(grep ^directory "$configdirectory"/"$i" | @AWK@ '{print $3}') - if [ "$backuploc" != "$previous" -a -n "$backuploc" ]; then - df -h "$backuploc" - previous="$backuploc" - fi - done - fi - } | mail -s "backupninja: $hostname $subject" $reportemail + debug "send report to $reportemail" + hostname=`hostname` + [ $warnings == 0 ] || subject="WARNING" + [ $errors == 0 ] || subject="ERROR" + [ $fatals == 0 ] || subject="FAILED" + + { + for ((i=0; i < ${#messages[@]} ; i++)); do + echo ${messages[$i]} + done + echo -e "$errormsg" + if [ "$reportspace" == "yes" ]; then + previous="" + for i in $(ls "$configdirectory"); do + backuploc=$(grep ^directory "$configdirectory"/"$i" | @AWK@ '{print $3}') + if [ "$backuploc" != "$previous" -a -n "$backuploc" ]; then + df -h "$backuploc" + previous="$backuploc" + fi + done + fi + } | mail -s "backupninja: $hostname $subject" $reportemail fi if [ $actions_run != 0 ]; then - info "FINISHED: $actions_run actions run. $fatals fatal. $errors error. $warnings warning." - if [ "$halts" != "0" ]; then - info "Backup was halted prematurely. Some actions may not have run." - fi + info "FINISHED: $actions_run actions run. $fatals fatal. $errors error. $warnings warning." + if [ "$halts" != "0" ]; then + info "Backup was halted prematurely. Some actions may not have run." + fi fi if [ -n "$reporthost" ]; then - debug "send $logfile to $reportuser@$reporthost:$reportdirectory" - rsync -qt $logfile $reportuser@$reporthost:$reportdirectory + debug "send $logfile to $reportuser@$reporthost:$reportdirectory" + rsync -qt $logfile $reportuser@$reporthost:$reportdirectory fi -- cgit v1.2.3 From 78884142e7cdaaf3e1f5571b1f28d2ea5a520b30 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 22 May 2009 15:27:09 +0200 Subject: Add a vim modeline with indentation settings. The modelines added match the emacs lines already present and also set the filetype to sh (just like the emacs lines). --- handlers/dup.helper.in | 1 + handlers/dup.in | 1 + handlers/ldap.helper.in | 1 + handlers/ldap.in | 1 + handlers/maildir.in | 1 + handlers/makecd.helper.in | 1 + handlers/makecd.in | 1 + handlers/mysql.helper.in | 1 + handlers/mysql.in | 1 + handlers/pgsql.helper.in | 1 + handlers/pgsql.in | 1 + handlers/rdiff.helper.in | 1 + handlers/rdiff.in | 1 + handlers/rsync.in | 2 ++ handlers/sh.in | 1 + handlers/svn.in | 1 + handlers/sys.helper.in | 1 + handlers/sys.in | 1 + handlers/tar.helper.in | 1 + handlers/tar.in | 1 + handlers/trac.in | 1 + handlers/wget | 2 ++ lib/easydialog.in | 1 + lib/tools.in | 1 + lib/vserver.in | 1 + src/backupninja.in | 1 + src/ninjahelper.in | 1 + src/ninjareport.in | 1 + 28 files changed, 30 insertions(+) (limited to 'src/backupninja.in') diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 86745c8..3c08a2f 100644 --- a/handlers/dup.helper.in +++ b/handlers/dup.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS dup:incremental_encrypted_remote_filesystem_backup" diff --git a/handlers/dup.in b/handlers/dup.in index 60a4ce9..aed6030 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # duplicity script for backupninja # requires duplicity diff --git a/handlers/ldap.helper.in b/handlers/ldap.helper.in index 4870ae4..4154cc6 100644 --- a/handlers/ldap.helper.in +++ b/handlers/ldap.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS ldap:ldap_database_backup" diff --git a/handlers/ldap.in b/handlers/ldap.in index 0b0166e..5f402c7 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # openldap backup handler script for backupninja # diff --git a/handlers/maildir.in b/handlers/maildir.in index e88619d..ab72ce1 100644 --- a/handlers/maildir.in +++ b/handlers/maildir.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: ############################################################### # diff --git a/handlers/makecd.helper.in b/handlers/makecd.helper.in index c8a6762..ad0c4aa 100644 --- a/handlers/makecd.helper.in +++ b/handlers/makecd.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS makecd:makecd_backup" wizardname="makecd action wizard" diff --git a/handlers/makecd.in b/handlers/makecd.in index 78e5454..d44bba3 100644 --- a/handlers/makecd.in +++ b/handlers/makecd.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # burncd handler script for backupninja # diff --git a/handlers/mysql.helper.in b/handlers/mysql.helper.in index fb9f11d..997f73c 100644 --- a/handlers/mysql.helper.in +++ b/handlers/mysql.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS mysql:mysql_database_backup" diff --git a/handlers/mysql.in b/handlers/mysql.in index a4a3667..88ffb1a 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # mysql handler script for backupninja # diff --git a/handlers/pgsql.helper.in b/handlers/pgsql.helper.in index 48bf047..ff1cfd4 100644 --- a/handlers/pgsql.helper.in +++ b/handlers/pgsql.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS pgsql:postgresql_database_backup" diff --git a/handlers/pgsql.in b/handlers/pgsql.in index b7e4262..ff5f7ba 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # PostgreSQL handler script for backupninja # diff --git a/handlers/rdiff.helper.in b/handlers/rdiff.helper.in index c673723..83f2fb5 100644 --- a/handlers/rdiff.helper.in +++ b/handlers/rdiff.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup" diff --git a/handlers/rdiff.in b/handlers/rdiff.in index 51da1cc..f59d56a 100644 --- a/handlers/rdiff.in +++ b/handlers/rdiff.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # rdiff-backup handler script for backupninja # requires rdiff-backup diff --git a/handlers/rsync.in b/handlers/rsync.in index 9e5e4f9..072f2a6 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -1,3 +1,5 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # backupninja handler to do incremental backups using # rsync and hardlinks, based on diff --git a/handlers/sh.in b/handlers/sh.in index 4edfd9a..b070f3b 100644 --- a/handlers/sh.in +++ b/handlers/sh.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # shell script handler for backupninja # runs the file /etc/backup.d/scriptname.sh diff --git a/handlers/svn.in b/handlers/svn.in index 97d1701..5e5531a 100644 --- a/handlers/svn.in +++ b/handlers/svn.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will backup subversion repostitories. # diff --git a/handlers/sys.helper.in b/handlers/sys.helper.in index c823712..8a2fb07 100644 --- a/handlers/sys.helper.in +++ b/handlers/sys.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS sys:general_hardware_and_system_info" diff --git a/handlers/sys.in b/handlers/sys.in index 2ab5871..69751ed 100755 --- a/handlers/sys.in +++ b/handlers/sys.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will save various reports of vital system information. # by default, all the reports are saved in /var/backups. diff --git a/handlers/tar.helper.in b/handlers/tar.helper.in index 2665382..cdbe03a 100644 --- a/handlers/tar.helper.in +++ b/handlers/tar.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS tar:tar_backup" diff --git a/handlers/tar.in b/handlers/tar.in index 0a762ce..b4f8c58 100644 --- a/handlers/tar.in +++ b/handlers/tar.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # tar handler script for backupninja diff --git a/handlers/trac.in b/handlers/trac.in index f387d42..018bffd 100644 --- a/handlers/trac.in +++ b/handlers/trac.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will backup trac environments (based on the svn handler) # diff --git a/handlers/wget b/handlers/wget index 0c363eb..ebb391e 100644 --- a/handlers/wget +++ b/handlers/wget @@ -1,3 +1,5 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # backupninja handler to do incremental backups using # wget and hardlinks, based on rsync handler diff --git a/lib/easydialog.in b/lib/easydialog.in index a0495a7..c41e6f7 100644 --- a/lib/easydialog.in +++ b/lib/easydialog.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # copyright 2002 lmoore@tump.com under the terms of the GNU LGPL. # additions 2005 collective@riseup.net diff --git a/lib/tools.in b/lib/tools.in index 0d368b8..929826b 100644 --- a/lib/tools.in +++ b/lib/tools.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # This file contains functions shared between ninjahelper and backupninja. diff --git a/lib/vserver.in b/lib/vserver.in index cc96a71..b356b2b 100644 --- a/lib/vserver.in +++ b/lib/vserver.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: ##################################################### ## VSERVERS RELATED FUNCTIONS FOR NINJAHELPER diff --git a/src/backupninja.in b/src/backupninja.in index ca5074c..a158715 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # |\_ # B A C K U P N I N J A /()/ diff --git a/src/ninjahelper.in b/src/ninjahelper.in index 7bbef1f..2a7faa9 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: #################################################### ## Functions diff --git a/src/ninjareport.in b/src/ninjareport.in index 56a7209..4bc244e 100755 --- a/src/ninjareport.in +++ b/src/ninjareport.in @@ -1,5 +1,6 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # # Ninjareport - generate a single simple report for a lot of hosts -- cgit v1.2.3 From 4996d8deb7fcf366f5c012ae919b1245db3d7b6a Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 25 Dec 2009 04:09:29 +0100 Subject: autotools: added the stat command to the automagically replaced ones ... hoping it will help supporting *BSD some day. --- ChangeLog | 3 +++ configure.in | 7 +++++++ src/Makefile.am | 1 + src/backupninja.in | 4 ++-- 4 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/backupninja.in') diff --git a/ChangeLog b/ChangeLog index 97d4353..d0f7011 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,9 @@ version 0.9.7 -- UNRELEASED dup: . Fixed bandwidthlimit syntax error. Thanks to Ian Beckwith for the patch. + autotools + . Added the stat command to the automagically replaced ones, hoping it + will help supporting *BSD some day. version 0.9.6 -- July 21, 2008 backupninja changes diff --git a/configure.in b/configure.in index 26e95be..174399d 100644 --- a/configure.in +++ b/configure.in @@ -36,6 +36,13 @@ if test x$MKTEMPT = "xno"; then AC_MSG_ERROR([mktemp is required]) fi +AC_PATH_PROGS(STAT, stat, "no") +if test x$STAT = "xno"; then + AC_MSG_ERROR([stat is required]) +else + export STAT +fi + AC_CHECK_PROG(ac_cv_have_rpm, rpm, "yes", "no") if test "x$ac_cv_have_rpm" = "xyes"; then rpm --define '_topdir /tmp' > /dev/null 2>&1 diff --git a/src/Makefile.am b/src/Makefile.am index 3d5bdb8..5694e9a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ edit = sed \ -e "s,@BASH\@,$(BASH),g" \ -e "s,@AWK\@,$(AWK),g" \ -e "s,@SED\@,$(SED),g" \ + -e "s,@STAT\@,$(STAT),g" \ -e 's,@datadir\@,$(pkgdatadir),g' \ -e "s,@libdir\@,$(pkglibdir),g" \ -e 's,@localstatedir\@,$(localstatedir),g' \ diff --git a/src/backupninja.in b/src/backupninja.in index a158715..a991f58 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -143,14 +143,14 @@ function check_perms() { local perms local owners - perms=($(stat -L --format='%A' $file)) + perms=($(@STAT@ -L --format='%A' $file)) debug "perms: $perms" local gperm=${perms:4:3} debug "gperm: $gperm" local wperm=${perms:7:3} debug "wperm: $wperm" - owners=($(stat -L --format='%g %G %u %U' $file)) + owners=($(@STAT@ -L --format='%g %G %u %U' $file)) local gid=${owners[0]} local group=${owners[1]} local owner=${owners[2]} -- cgit v1.2.3 From 8fb9415609b3181d8522f42115508dd7a3643345 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 5 Jan 2010 13:39:32 +0100 Subject: Adding optional report of infos sent by handlers in the email (closes #563734) Cherry-picked and re-indented patch 76792c8f45afa1fdaeb81c2af77499ca0b83ce64 from Olivier Berger. Conflicts: src/backupninja.in --- AUTHORS | 2 +- ChangeLog | 2 ++ etc/backupninja.conf.in | 4 ++++ src/backupninja.in | 7 ++++++- 4 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/backupninja.in') diff --git a/AUTHORS b/AUTHORS index 6309a1c..89b505f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -30,4 +30,4 @@ Matthew Palmer -- halt loglevel feature dan@garthwaite.org -- reportspace bugfix Tuomas Jormola -- "when = manual" option Ian Beckwith -- dup bandwidthlimit fix -Olivier Berger -- dup debug output bugfix \ No newline at end of file +Olivier Berger -- dup debug output bugfix, reportinfo option \ No newline at end of file diff --git a/ChangeLog b/ChangeLog index b6e05d0..b71a9be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ version 0.9.7 -- UNRELEASED . add 'when = manual' option, that can be used in the global config file or in a given backup action file. Thanks Tuomas Jormola for the preliminary patch (Closes: #511299) + . new reportinfo option: when set, messages sent by handlers with + "info" are included in the report e-mail (closes #563734) lib changes easydialog: . Allow form fields input to grow up to 100 chars (Closes: #562249) diff --git a/etc/backupninja.conf.in b/etc/backupninja.conf.in index f7668a5..de1fbf3 100644 --- a/etc/backupninja.conf.in +++ b/etc/backupninja.conf.in @@ -21,6 +21,10 @@ reportemail = root # even if all modules reported success. (default = yes) reportsuccess = yes +# if set to 'yes', info messages from handlers will be +# sent into the email (default = no) +reportinfo = no + # if set to 'yes', a report email will be generated # even if there was no error. (default = yes) reportwarning = yes diff --git a/src/backupninja.in b/src/backupninja.in index a991f58..f871e0c 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -335,8 +335,9 @@ function process_action() { _errors=`cat $bufferfile | grep "^Error: " | wc -l` _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l` _halts=`cat $bufferfile | grep "^Halt: " | wc -l` + _infos=`cat $bufferfile | grep "^Info: " | wc -l` - ret=`grep "\(^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile` + ret=`grep "\(^Info: \|^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile` rm $bufferfile if [ $_halts != 0 ]; then msg "*halt* -- $file" @@ -356,6 +357,9 @@ function process_action() { warning "<<<< finished action $file: WARNING" else msg "success -- $file" + if [ $_infos != 0 -a "$reportinfo" == "yes" ]; then + errormsg="$errormsg\n== infos from $file ==\n\n$ret\n" + fi info "<<<< finished action $file: SUCCESS" fi @@ -456,6 +460,7 @@ getconf reportemail getconf reporthost getconf reportspace getconf reportsuccess yes +getconf reportinfo no getconf reportuser getconf reportwarning yes getconf loglevel 3 -- cgit v1.2.3 From 172b0e3341cb60ffed14eea306373d696dacc600 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 5 Jan 2010 14:31:57 +0100 Subject: Fixed indentation --- src/backupninja.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/backupninja.in') diff --git a/src/backupninja.in b/src/backupninja.in index f871e0c..34021b5 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -569,11 +569,11 @@ if [ $doit == 1 ]; then if [ "$reportspace" == "yes" ]; then previous="" for i in $(ls "$configdirectory"); do - backuploc=$(grep ^directory "$configdirectory"/"$i" | @AWK@ '{print $3}') - if [ "$backuploc" != "$previous" -a -n "$backuploc" ]; then - df -h "$backuploc" - previous="$backuploc" - fi + backuploc=$(grep ^directory "$configdirectory"/"$i" | @AWK@ '{print $3}') + if [ "$backuploc" != "$previous" -a -n "$backuploc" ]; then + df -h "$backuploc" + previous="$backuploc" + fi done fi } | mail -s "backupninja: $hostname $subject" $reportemail -- cgit v1.2.3 From 49bfd02bd3ee6eccc2eaa0a7c668c46b4a15af0a Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 5 Jan 2010 14:34:30 +0100 Subject: reportspace: skip non-directories and places that don't exist on the local filesystem (Closes: #536049) --- ChangeLog | 2 ++ src/backupninja.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/backupninja.in') diff --git a/ChangeLog b/ChangeLog index 586e3fd..130a544 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ version 0.9.7 -- UNRELEASED preliminary patch (Closes: #511299) . new reportinfo option: when set, messages sent by handlers with "info" are included in the report e-mail (closes #563734) + . reportspace: skip non-directories and places that don't exist on the + local filesystem (Closes: #536049) lib changes easydialog: . Allow form fields input to grow up to 100 chars (Closes: #562249) diff --git a/src/backupninja.in b/src/backupninja.in index 34021b5..c3ec7ed 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -570,7 +570,7 @@ if [ $doit == 1 ]; then previous="" for i in $(ls "$configdirectory"); do backuploc=$(grep ^directory "$configdirectory"/"$i" | @AWK@ '{print $3}') - if [ "$backuploc" != "$previous" -a -n "$backuploc" ]; then + if [ "$backuploc" != "$previous" -a -n "$backuploc" -a -d "$backuploc" ]; then df -h "$backuploc" previous="$backuploc" fi -- cgit v1.2.3 From 0fbd8744f5c10649b7239c3199dae229a30e10a9 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sat, 9 Jan 2010 01:19:21 +0100 Subject: set BACKUPNINJA_DEBUG when invoked with -d (Closes: #537266) --- ChangeLog | 1 + src/backupninja.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/backupninja.in') diff --git a/ChangeLog b/ChangeLog index fb6b622..12c1436 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ version 0.9.7 -- UNRELEASED "info" are included in the report e-mail (closes #563734) . reportspace: skip non-directories and places that don't exist on the local filesystem (Closes: #536049) + . set BACKUPNINJA_DEBUG when invoked with -d (Closes: #537266) lib changes easydialog: . Allow form fields input to grow up to 100 chars (Closes: #562249) diff --git a/src/backupninja.in b/src/backupninja.in index c3ec7ed..e8a820f 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -381,7 +381,7 @@ loglevel=3 while [ $# -ge 1 ]; do case $1 in -h|--help) usage;; - -d|--debug) debug=1;; + -d|--debug) debug=1; export BACKUPNINJA_DEBUG=yes;; -t|--test) test=1;debug=1;; -n|--now) processnow=1;; -f|--conffile) -- cgit v1.2.3