diff --git a/inc_bash.sh b/inc_bash.sh index 23e8b582f4f007164337390c79434820491d8114..d076b059eb6c0e5cc4abf8094f7ac6d0fa0d012a 100755 --- a/inc_bash.sh +++ b/inc_bash.sh @@ -15,8 +15,13 @@ typeset -i rc=0 # It stores the last exitcode in myrc function fetchrc(){ myrc=$? - echo rc=$myrc rc=$rc+$myrc + + if [ $myrc -eq 0 ]; then + cecho ok "OK" + else + cecho error "FAILED (rc=$myrc)" + fi } diff --git a/localdump.sh b/localdump.sh index f3c0b18b963fa35be3885692103cd5cdde3106fd..3bb293ae694dc2026b0abfe00ea9d95c063e4200 100755 --- a/localdump.sh +++ b/localdump.sh @@ -89,12 +89,7 @@ if [ $myrc -eq 0 ]; then echo -n "gzip $1 ... " gzip -9 -f "${1}" - fetchrc >/dev/null - if [ $myrc -eq 0 ]; then - cecho ok "OK" - else - cecho error "FAILED" - fi + fetchrc else cecho error "ERROR occured while dumping - no gzip of $_outfile" fi diff --git a/plugins/localdump/couchdb2.sh b/plugins/localdump/couchdb2.sh index 7c0c6ff742a603deee0b5c688d04909a63f4f22a..bd6f70e75b83fc0e1f0efaeb38fd68d404e8d047 100755 --- a/plugins/localdump/couchdb2.sh +++ b/plugins/localdump/couchdb2.sh @@ -223,7 +223,7 @@ function _doBackupOfSingleInstance(){ fi done rm -f "$dblist" - echo "__DB__$SERVICENAME INFO: ${COUCHDB_INSTANCE} - backed up $iDbCount dbs of $iDbTotal total" + echo "__DB__$SERVICENAME backup INFO: ${COUCHDB_INSTANCE} - backed up $iDbCount dbs of $iDbTotal total" } diff --git a/plugins/localdump/ldap.sh b/plugins/localdump/ldap.sh index 6c3cb8d6ed59410241a1ba932c555f3359330ae9..1b5a7277002c078f508085a2924cfb1bbd00f6ac 100755 --- a/plugins/localdump/ldap.sh +++ b/plugins/localdump/ldap.sh @@ -16,8 +16,8 @@ # ================================================================================ -if [ -z $BACKUP_TARGETDIR ]; then - echo ERROR: you cannot start `basename $0` directly +if [ -z "$BACKUP_TARGETDIR" ]; then + echo ERROR: you cannot start $(basename $0) directly rc=$rc+1 exit 1 fi @@ -53,14 +53,14 @@ function dump_ldap(){ DN=$1 DUMPFILE=$2 - slapcat -F $LDAP_CONF_DIR_PATH -b $DN -l $DUMPFILE - fetchrc + echo -n "__DB__$SERVICENAME backup $LDAP_CONF_DIR_PATH .. DN $DN " + slapcat -F $LDAP_CONF_DIR_PATH -b "$DN" -l "$DUMPFILE" + fetchrc >/dev/null - if [ $rc -ne 0 ]; then - echo ERROR during backup $LDAP_CONF_DIR_PATH with DN $DN + if [ $myrc -ne 0 ]; then + echo "ERROR during backup" else - echo Dump OK - compress_file $DUMPFILE + db._compressDumpfile "$DUMPFILE" fi } @@ -73,30 +73,30 @@ function doLdapBackup(){ echo ----- LDAP BACKUP CONFIG # for cfgname in `ldapsearch -H ldap:// -x -s base -b "" -LLL "configContext" | grep "configContext" | cut -f 2 -d ":"` - for cfgname in `ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b '' -LLL configContext | grep "configContext" | cut -f 2 -d ":"` + for cfgname in $(ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b '' -LLL configContext | grep "configContext" | cut -f 2 -d ":") do echo DN $cfgname - cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"` - outfile=$(hostname)_ldap_olc_config__`get_outfile ${cfg2}`.ldif + cfg2=$(echo $cfgname | sed "s#[\ =,]#_#g") + outfile=$(hostname)_ldap_olc_config__$(get_outfile ${cfg2}).ldif - dump_ldap $cfgname $BACKUP_TARGETDIR/$outfile + dump_ldap "$cfgname" "$BACKUP_TARGETDIR/$outfile" done echo ----- LDAP DATA #for cfgname in `ldapsearch -H ldap:// -x -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":"` - for cfgname in `ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":"` + for cfgname in $(ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":") do echo DN $cfgname cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"` - outfile=$(hostname)_ldap_data__`get_outfile ${cfg2}`.ldif + outfile=$(hostname)_ldap_data__$(get_outfile ${cfg2}).ldif - dump_ldap $cfgname $BACKUP_TARGETDIR/$outfile + dump_ldap "$cfgname" "$BACKUP_TARGETDIR/$outfile" done echo echo ----- DUMPS - ls -l $BACKUP_TARGETDIR/*$BACKUP_DATE* + ls -l "$BACKUP_TARGETDIR/*$BACKUP_DATE*" }