Code: Alles auswählen
#!/bin/bash
FULLBACKUPDAY="Sunday"
SOURCE="/var/log/mail"
TARGET="/tmp/backup"
FULLBACKUPNAME="`date +%A`"
INCBACKUPNAME="`date +%A`"
OPTIONS="-abP"
echo "BACKUP Programm"
echo "-----------------------------------------------"
test -e "$TARGET" || mkdir -p "$TARGET" && cd $TARGET
if [ `date +%A` = "$FULLBACKUPDAY" ]; then
echo "Fullbackup"
echo "$FULLBACKUPNAME" >"$TARGET"/lastfullbackup
mvdir="$TARGET"/`date +%V`
mkdir $mvdir
mv "$TARGET"/Monday "$mvdir"
mv "$TARGET"/Tuesday "$mvdir"
mv "$TARGET"/Wednesday "$mvdir"
mv "$TARGET"/Thursday "$mvdir"
mv "$TARGET"/Friday "$mvdir"
mv "$TARGET"/Saturday "$mvdir"
mv "$TARGET"/Sunday "$mvdir"
rsync "$OPTIONS" "$SOURCE" "$TARGET"/"$FULLBACKUPNAME"
elif [ ! -e "$TARGET"/* ]; then
echo "First Fullbackup"
echo "$FULLBACKUPNAME" >"$TARGET"/lastfullbackup
rsync "$OPTIONS" "$SOURCE" "$TARGET"/"$FULLBACKUPNAME"
else
echo "INC Backup"
lastfullbackup=`cat "$TARGET"/lastfullbackup`
rsync "$OPTIONS" --backup --backup-dir="$INCBACKUPNAME" "$SOURCE" "$TARGET"/"$lastfullbackup"
fi
ich möchte folgende backupstruktur:
Sonntag (fullbackup)
Montag (incbackup)
Dienstag (incbackup)
...
am nächsten sonntag soll er die backups der letzten woche in einen ortner mit der wochennummer verschieben.
34 --
---> Sonntag (fullbackup)
---> Montag (incbackup)
---> Dienstag (incbackup)
Sonntag (fullbackup)
Montag (incbackup)
Dienstag (incbackup)
leider klappts need, er macht das fullbackup ordentlich, jedoch macht er dann den Montag als unterortner von sonntag.
bin für alles dankbar.