fix: minor fixes
This commit is contained in:
parent
b94d4e72e4
commit
8ac35ab002
1 changed files with 20 additions and 20 deletions
40
backup.sh
40
backup.sh
|
@ -50,23 +50,23 @@ function formatLog ()
|
|||
# directory provided by the first parameter ($1)
|
||||
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
|
||||
$ECHO "$DPKG --get-selections | $AWK '!/deinstall|purge|hold/'|$CUT -f1 | $TR '\n' ' '" | formatLog >> $LOG
|
||||
$DPKG --get-selections | $AWK '!/deinstall|purge|hold/'|$CUT -f1 |$TR '\n' ' ' | formatLog >> $LOG 2>&1
|
||||
$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' ' ' 2>&1 | formatLog >> $LOG 2>&1
|
||||
fi
|
||||
|
||||
# Create folders that don't exist
|
||||
if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then
|
||||
$ECHO "$S $TOSSH $MKDIR -p $TARGET$1" | formatLog >> $LOG
|
||||
$S $TOSSH "$MKDIR -p \"$TARGET\"$1" | formatLog >> $LOG 2>&1
|
||||
$ECHO "$S $TOSSH $MKDIR -p $TARGET$1" 2>&1 | formatLog >> $LOG
|
||||
$S $TOSSH "$MKDIR -p \"$TARGET\"$1" 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
fi
|
||||
elif ( [ -n "$S" ] && [ -n "$FROMSSH" ] && [ -z "$TOSSH" ] ) || ( [ -z "$S" ] ); then
|
||||
$ECHO "$MKDIR -p $TARGET$1" | formatLog >> $LOG
|
||||
$MKDIR -p "$TARGET"$1 | formatLog >> $LOG 2>&1
|
||||
$ECHO "$MKDIR -p $TARGET$1" 2>&1 | formatLog >> $LOG
|
||||
$MKDIR -p "$TARGET"$1 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
fi
|
||||
|
@ -76,20 +76,20 @@ function backup ()
|
|||
for SOURCE in "${SOURCES[@]}"
|
||||
do
|
||||
if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then
|
||||
$ECHO "$RSYNC -e \"$S\" -avR \"$SOURCE\" ${RSYNCCONF[@]} \"$TOSSH:$TARGET$1\" $INC " | formatLog >> $LOG
|
||||
$RSYNC -e "$S" -avR "$SOURCE" "${RSYNCCONF[@]}" "$TOSSH:\"$TARGET\"$1" $INC --exclude-from=$EXCLUDEFROM | formatLog >> $LOG 2>&1
|
||||
$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" 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
fi
|
||||
elif [ -n "$S" ] && [ -z "$TOSSH" ] && [ -n "$FROMSSH" ]; then
|
||||
$ECHO "$RSYNC -e \"$S\" -avR \"$FROMSSH:$SOURCE\" ${RSYNCCONF[@]} $TARGET$1 $INC" | formatLog >> $LOG
|
||||
$RSYNC -e "$S" -avR "$FROMSSH:\"$SOURCE\"" "${RSYNCCONF[@]}" "$TARGET"$1 $INC --exclude-from=$EXCLUDEFROM | formatLog >> $LOG 2>&1
|
||||
$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" 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
fi
|
||||
elif [-z "$S"] && [ -z "$TOSSH" ] && [ -z "$FROMSSh" ]; then
|
||||
$ECHO "$RSYNC -avR \"$SOURCE\" ${RSYNCCONF[@]} $TARGET$1 $INC" | formatLog >> $LOG
|
||||
$RSYNC -avR "$SOURCE" "${RSYNCCONF[@]}" "$TARGET"$1 $INC --exclude-from=$EXCLUDEFROM | formatLog >> $LOG 2>&1
|
||||
$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" 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
fi
|
||||
|
@ -98,20 +98,20 @@ function backup ()
|
|||
|
||||
# Create a link to the latest backup
|
||||
if [ -n "$S" ] && [ -n "$TOSSH" ] && [ -z "$FROMSSH" ]; then
|
||||
$ECHO "$S $TOSSH $LN -nsf $TARGET$1 $TARGET$LAST" | formatLog >> $LOG
|
||||
$S $TOSSH "$LN -nsf \"$TARGET\"$1 \"$TARGET\"$LAST" | formatLog >> $LOG 2>&1
|
||||
$ECHO "$S $TOSSH $LN -nsf $TARGET$1 $TARGET$LAST" 2>&1 | formatLog >> $LOG
|
||||
$S $TOSSH "$LN -nsf \"$TARGET\"$1 \"$TARGET\"$LAST" 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
fi
|
||||
elif ( [ -n "$S" ] && [ -n "$FROMSSH" ] && [ -z "$TOSSH" ] ) || ( [ -z "$S" ] ); then
|
||||
$ECHO "$LN -nsf $TARGET$1 $TARGET$LAST" | formatLog >> $LOG
|
||||
$LN -nsf "$TARGET"$1 "$TARGET"$LAST | formatLog >> $LOG 2>&1
|
||||
$ECHO "$LN -nsf $TARGET$1 $TARGET$LAST" 2>&1 | formatLog >> $LOG
|
||||
$LN -nsf "$TARGET"$1 "$TARGET"$LAST 2>&1 | formatLog >> $LOG 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
ERROR=1
|
||||
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
|
||||
|
@ -129,8 +129,8 @@ elif [ -z "$TOSSH" ] && [ -n "$FROMSSH" ]; then
|
|||
S="$SSH -p $FROMSSHPORT -l $FROMSSHUSER"
|
||||
elif [ -n "$TOSSH" ] && [ -n "$FROMSSH" ]; then
|
||||
ERROR=1
|
||||
$ECHO "Plese don't provide to and from ssh information!" | formatLog >> $LOG
|
||||
$ECHO "No backup performed!" | formatLog >> $LOG
|
||||
$ECHO "Plese don't provide to and from ssh information!" 2>&1 | formatLog >> $LOG
|
||||
$ECHO "No backup performed!" 2>&1 | formatLog >> $LOG
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue