#!/bin/bash cd /home/backup/server FOLDER1=$'/home/backup/server/data' FOLDER2=$'/home/backup/ch3snas/`date "+%d-%m-%y"`' du -a .time $FOLDER1 > /tmp/folder1 du -a .time $FOLDER2 > /tmp/folder2 Compare=$(diff /tmp/folder1 /tmp/folder2) if [ ! -n "$Compare" ]; then if [ -e data ] then cd /home/backup/server/data/ HOST='Server-IP' USER='username' PASSWD='password' ncftp -u $USER -p $PASSWD $HOST << EOT binary cd /Volume_1 mkdir `date "+%d-%m-%y"` cd `date "+%d-%m-%y"` mput * bye EOT echo "einde ftp sessie" # fi # must be replaced ?? # Compare=$(diff /home/backup/ch3snas/`date "+%d-%m-%y"` /home/backup/server/data) # if [ -n "$Compare" ]; then echo "Comparison finished" echo "There is difference between source folder and destination" SUBJECT="There is something wrong with the backup" # Email To ? EMAIL="e-mail@mail.com" # Email text/message EMAILMESSAGE="/tmp/emailmessage.txt" echo "We have found an error during the ftp of the backup to the CH3SNAS-1"> $EMAILMESSAGE echo "Please check it" >>$EMAILMESSAGE echo "Your Admin, Dennis" >>$EMAILMESSAGE # send an email using /bin/mail /bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE else if [ ! -e data ] then echo "data folder exist &" echo "no problems found removing source data sending e-mail" SUBJECT="The backup has succeeded!" # Email To ? EMAIL="e-mail@mail.com" # Email text/message EMAILMESSAGE="/tmp/emailmessage.txt" echo "No Errors have been found during the ftp of the backup to the CH3SNAS-1"> $EMAILMESSAGE date "+%d-%m-%y" >>$EMAILMESSAGE echo "Your Admin, Dennis" >>$EMAILMESSAGE # send an email using /bin/mail /bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE else echo "removing data folder 1" cd /home/backup/server rm -rf data fi echo "removing data folder 2" cd /home/backup/server rm -rf data fi echo "nothing to do 1" fi echo "nothing to do 2 cause there is no data folder" # fi # echo "end"