diff --git a/bash/cronbackup/backup.sh b/bash/cronbackup/backup.sh index a841a5f..1796c04 100644 --- a/bash/cronbackup/backup.sh +++ b/bash/cronbackup/backup.sh @@ -48,10 +48,16 @@ while read line; do # exclude file EXCLUDE="exclude/${ARGS[1]}" + CHDIR=$(dirname $FILE) + + if [ -d $FILE ]; then + CHDIR="$FILE/../" + fi + if [ -f $EXCLUDE ]; then - tar zcf "$BAKDIR/$BACKUPFILE" -C "$FILE/../" $FILENAME -X $EXCLUDE + tar zcf "$BAKDIR/$BACKUPFILE" -C $CHDIR $FILENAME -X $EXCLUDE else - tar zcf "$BAKDIR/$BACKUPFILE" -C "$FILE/../" $FILENAME + tar zcf "$BAKDIR/$BACKUPFILE" -C $CHDIR $FILENAME fi # count backup file