fix: minor fixes

This commit is contained in:
Shannon Sterz 2017-08-06 22:31:16 +02:00
parent b94d4e72e4
commit 8ac35ab002

View file

@ -50,23 +50,23 @@ function formatLog ()
# directory provided by the first parameter ($1) # directory provided by the first parameter ($1)
function backup () function backup ()
{ {
$ECHO "Creating backup in \"$TOSSH:$TARGET$1\"..." | formatLog >> $LOG $ECHO "Creating backup in \"$TOSSH:$TARGET$1\"..." 2>&1 | formatLog >> $LOG
if [ -n "$LISTPACKAGES" ] && [ -z "$FROMSSH" ]; then if [ -n "$LISTPACKAGES" ] && [ -z "$FROMSSH" ]; then
$ECHO "$DPKG --get-selections | $AWK '!/deinstall|purge|hold/'|$CUT -f1 | $TR '\n' ' '" | formatLog >> $LOG $ECHO "$DPKG --get-selections | $AWK '!/deinstall|purge|hold/'|$CUT -f1 | $TR '\n' ' '" 2>&1 | formatLog >> $LOG
$DPKG --get-selections | $AWK '!/deinstall|purge|hold/'|$CUT -f1 |$TR '\n' ' ' | formatLog >> $LOG 2>&1 $DPKG --get-selections | $AWK '!/deinstall|purge|hold/'|$CUT -f1 |$TR '\n' ' ' 2>&1 | formatLog >> $LOG 2>&1
fi fi
# Create folders that don't exist # Create folders that don't exist
if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then
$ECHO "$S $TOSSH $MKDIR -p $TARGET$1" | formatLog >> $LOG $ECHO "$S $TOSSH $MKDIR -p $TARGET$1" 2>&1 | formatLog >> $LOG
$S $TOSSH "$MKDIR -p \"$TARGET\"$1" | formatLog >> $LOG 2>&1 $S $TOSSH "$MKDIR -p \"$TARGET\"$1" 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
elif ( [ -n "$S" ] && [ -n "$FROMSSH" ] && [ -z "$TOSSH" ] ) || ( [ -z "$S" ] ); then elif ( [ -n "$S" ] && [ -n "$FROMSSH" ] && [ -z "$TOSSH" ] ) || ( [ -z "$S" ] ); then
$ECHO "$MKDIR -p $TARGET$1" | formatLog >> $LOG $ECHO "$MKDIR -p $TARGET$1" 2>&1 | formatLog >> $LOG
$MKDIR -p "$TARGET"$1 | formatLog >> $LOG 2>&1 $MKDIR -p "$TARGET"$1 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
@ -76,20 +76,20 @@ function backup ()
for SOURCE in "${SOURCES[@]}" for SOURCE in "${SOURCES[@]}"
do do
if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then
$ECHO "$RSYNC -e \"$S\" -avR \"$SOURCE\" ${RSYNCCONF[@]} \"$TOSSH:$TARGET$1\" $INC " | formatLog >> $LOG $ECHO "$RSYNC -e \"$S\" -avR \"$SOURCE\" ${RSYNCCONF[@]} \"$TOSSH:$TARGET$1\" $INC --exclude-from=\"$EXCLUDEFROM\"" 2>&1 | formatLog >> $LOG
$RSYNC -e "$S" -avR "$SOURCE" "${RSYNCCONF[@]}" "$TOSSH:\"$TARGET\"$1" $INC --exclude-from=$EXCLUDEFROM | formatLog >> $LOG 2>&1 $RSYNC -e "$S" -avR "$SOURCE" "${RSYNCCONF[@]}" "$TOSSH:\"$TARGET\"$1" $INC --exclude-from="$EXCLUDEFROM" 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
elif [ -n "$S" ] && [ -z "$TOSSH" ] && [ -n "$FROMSSH" ]; then elif [ -n "$S" ] && [ -z "$TOSSH" ] && [ -n "$FROMSSH" ]; then
$ECHO "$RSYNC -e \"$S\" -avR \"$FROMSSH:$SOURCE\" ${RSYNCCONF[@]} $TARGET$1 $INC" | formatLog >> $LOG $ECHO "$RSYNC -e \"$S\" -avR \"$FROMSSH:$SOURCE\" ${RSYNCCONF[@]} $TARGET$1 $INC --exclude-from=\"$EXCLUDEFROM\"" 2>&1 | formatLog >> $LOG
$RSYNC -e "$S" -avR "$FROMSSH:\"$SOURCE\"" "${RSYNCCONF[@]}" "$TARGET"$1 $INC --exclude-from=$EXCLUDEFROM | formatLog >> $LOG 2>&1 $RSYNC -e "$S" -avR "$FROMSSH:\"$SOURCE\"" "${RSYNCCONF[@]}" "$TARGET"$1 $INC --exclude-from="$EXCLUDEFROM" 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
elif [-z "$S"] && [ -z "$TOSSH" ] && [ -z "$FROMSSh" ]; then elif [-z "$S"] && [ -z "$TOSSH" ] && [ -z "$FROMSSh" ]; then
$ECHO "$RSYNC -avR \"$SOURCE\" ${RSYNCCONF[@]} $TARGET$1 $INC" | formatLog >> $LOG $ECHO "$RSYNC -avR \"$SOURCE\" ${RSYNCCONF[@]} $TARGET$1 $INC --exclude-from=\"$EXCLUDEFROM\"" 2>&1 | formatLog >> $LOG
$RSYNC -avR "$SOURCE" "${RSYNCCONF[@]}" "$TARGET"$1 $INC --exclude-from=$EXCLUDEFROM | formatLog >> $LOG 2>&1 $RSYNC -avR "$SOURCE" "${RSYNCCONF[@]}" "$TARGET"$1 $INC --exclude-from="$EXCLUDEFROM" 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
@ -98,20 +98,20 @@ function backup ()
# Create a link to the latest backup # Create a link to the latest backup
if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then
$ECHO "$S $TOSSH $LN -nsf $TARGET$1 $TARGET$LAST" | formatLog >> $LOG $ECHO "$S $TOSSH $LN -nsf $TARGET$1 $TARGET$LAST" 2>&1 | formatLog >> $LOG
$S $TOSSH "$LN -nsf \"$TARGET\"$1 \"$TARGET\"$LAST" | formatLog >> $LOG 2>&1 $S $TOSSH "$LN -nsf \"$TARGET\"$1 \"$TARGET\"$LAST" 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
elif ( [ -n "$S" ] && [ -n "$FROMSSH" ] && [ -z "$TOSSH" ] ) || ( [ -z "$S" ] ); then elif ( [ -n "$S" ] && [ -n "$FROMSSH" ] && [ -z "$TOSSH" ] ) || ( [ -z "$S" ] ); then
$ECHO "$LN -nsf $TARGET$1 $TARGET$LAST" | formatLog >> $LOG $ECHO "$LN -nsf $TARGET$1 $TARGET$LAST" 2>&1 | formatLog >> $LOG
$LN -nsf "$TARGET"$1 "$TARGET"$LAST | formatLog >> $LOG 2>&1 $LN -nsf "$TARGET"$1 "$TARGET"$LAST 2>&1 | formatLog >> $LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR=1 ERROR=1
fi fi
fi fi
$ECHO "Done creating backup in \"$TOSSH:$TARGET$1\"" | formatLog >> $LOG $ECHO "Done creating backup in \"$TOSSH:$TARGET$1\"" 2>&1 | formatLog >> $LOG
} }
# Clear log # Clear log
@ -129,8 +129,8 @@ elif [ -z "$TOSSH" ] && [ -n "$FROMSSH" ]; then
S="$SSH -p $FROMSSHPORT -l $FROMSSHUSER" S="$SSH -p $FROMSSHPORT -l $FROMSSHUSER"
elif [ -n "$TOSSH" ] && [ -n "$FROMSSH" ]; then elif [ -n "$TOSSH" ] && [ -n "$FROMSSH" ]; then
ERROR=1 ERROR=1
$ECHO "Plese don't provide to and from ssh information!" | formatLog >> $LOG $ECHO "Plese don't provide to and from ssh information!" 2>&1 | formatLog >> $LOG
$ECHO "No backup performed!" | formatLog >> $LOG $ECHO "No backup performed!" 2>&1 | formatLog >> $LOG
exit 1 exit 1
fi fi