#!/bin/bash # Cron Backup Skript # Verion 0.6 #Variablen DA=`date '+%d-%m-%Y'` MO=`date '+%m'` # Anagebe der Zierlverzeichnisses VERZ= # Monate M01=Januar; M02=Februar; M03=März; M04=April; M05=Mai; M06=Juni M07=Juli; M08=August; M09=September; M10=Oktober; M11=November; M12=Dezember # Erstelle ggf einen Ordner im Backupverzeichnis mit dem Monatsnamem des # Aktuellen Monates if [ $MO = 01 ]; then NOW=$M01; if [ ! -e $VERZ/$M01 ]; then mkdir $VERZ/$M01; fi; fi if [ $MO = 02 ]; then NOW=$M02; if [ ! -e $VERZ/$M02 ]; then mkdir $VERZ/$M02; fi; fi if [ $MO = 03 ]; then NOW=$M03; if [ ! -e $VERZ/$M03 ]; then mkdir $VERZ/$M03; fi; fi if [ $MO = 04 ]; then NOW=$M04; if [ ! -e $VERZ/$M04 ]; then mkdir $VERZ/$M04; fi; fi if [ $MO = 05 ]; then NOW=$M05; if [ ! -e $VERZ/$M05 ]; then mkdir $VERZ/$M05; fi; fi if [ $MO = 06 ]; then NOW=$M06; if [ ! -e $VERZ/$M06 ]; then mkdir $VERZ/$M06; fi; fi if [ $MO = 07 ]; then NOW=$M07; if [ ! -e $VERZ/$M07 ]; then mkdir $VERZ/$M07; fi; fi if [ $MO = 08 ]; then NOW=$M08; if [ ! -e $VERZ/$M08 ]; then mkdir $VERZ/$M08; fi; fi if [ $MO = 09 ]; then NOW=$M09; if [ ! -e $VERZ/$M09 ]; then mkdir $VERZ/$M09; fi; fi if [ $MO = 10 ]; then NOW=$M10; if [ ! -e $VERZ/$M10 ]; then mkdir $VERZ/$M10; fi; fi if [ $MO = 11 ]; then NOW=$M11; if [ ! -e $VERZ/$M11 ]; then mkdir $VERZ/$M11; fi; fi if [ $MO = 12 ]; then NOW=$M12; if [ ! -e $VERZ/$M12 ]; then mkdir $VERZ/$M12; fi; fi # Löschen veralteter Backups if [ $MO = 03 ]; then if [ -e $VERZ/$M01 ]; then rm -Rv $VERZ/$M01; fi; fi if [ $MO = 04 ]; then if [ -e $VERZ/$M02 ]; then rm -Rv $VERZ/$M02; fi; fi if [ $MO = 05 ]; then if [ -e $VERZ/$M03 ]; then rm -Rv $VERZ/$M03; fi; fi if [ $MO = 06 ]; then if [ -e $VERZ/$M04 ]; then rm -Rv $VERZ/$M04; fi; fi if [ $MO = 07 ]; then if [ -e $VERZ/$M05 ]; then rm -Rv $VERZ/$M05; fi; fi if [ $MO = 08 ]; then if [ -e $VERZ/$M06 ]; then rm -Rv $VERZ/$M06; fi; fi if [ $MO = 09 ]; then if [ -e $VERZ/$M07 ]; then rm -Rv $VERZ/$M07; fi; fi if [ $MO = 10 ]; then if [ -e $VERZ/$M08 ]; then rm -Rv $VERZ/$M08; fi; fi if [ $MO = 11 ]; then if [ -e $VERZ/$M09 ]; then rm -Rv $VERZ/$M09; fi; fi if [ $MO = 12 ]; then if [ -e $VERZ/$M10 ]; then rm -Rv $VERZ/$M10; fi; fi if [ $MO = 01 ]; then if [ -e $VERZ/$M11 ]; then rm -Rv $VERZ/$M11; fi; fi if [ $MO = 02 ]; then if [ -e $VERZ/$M12 ]; then rm -Rv $VERZ/$M12; fi; fi cd $VERZ/$NOW echo