Software: Apache/2.2.16 (Debian). PHP/5.3.3-7+squeeze19 uname -a: Linux mail.tri-specialutilitydistrict.com 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /root/scripts/ drwxr-xr-x |
Viewing file: Select action/file-type: #!/bin/bash function errorCheck { error=$? if [ $error -ne 0 ]; then echo "!ERROR IN ABOVE COMMAND!" >>$logfile errors=$((errors+1)) errorstring+="--Code: "$error" : Command "$command fi } function runcommand { echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile command=$((command+1)) echo Command $command: $1 2>&1 >>$logfile # echo $1 eval "$1" 2>&1 >>$logfile errorCheck $1 } function prepareUsbdisk { echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo Create directories on usbdisk if missing. >>$logfile if [ ! -d "$backupdestdrive/daily" ] then mkdir $backupdestdrive/daily 2>&1 >>$logfile fi if [ ! -d "$backupdestdrive/weekly" ] then mkdir "$backupdestdrive/weekly" 2>&1 >>$logfile fi if [ ! -d "$backupdestdrive/daily/winserver" ] then mkdir $backupdestdrive/daily/winserver 2>&1 >>$logfile fi if [ ! -d "$backupdestdrive/weekly/winserver" ] then mkdir $backupdestdrive/weekly/winserver 2>&1 >>$logfile fi } function performMailBackup { runcommand "mysqldump -E -uroot -pjsb@75494 --all-databases >$backupdest/databases.mysql" runcommand "rsync -av --exclude '/home/shared' --delete /home/* $backupdest/home/" runcommand "rsync -av --delete /var/www/* $backupdest/www/" runcommand "rsync -av --delete /var/secure/* $backupdest/secure/" runcommand "tar -czfv $backupdest/etc.tgz /etc" } function performWinServerBackup { if [ -e "$winbackupsrc/PD0" ] then echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo Backup from Windows server mounted to $winbackupsrc. >>$logfile runcommand "rsync -av --delete $winbackupsrc/Harris/* $backupdest/winserver/harris" runcommand "rsync -av --delete $winbackupsrc/Shares/* $backupdest/winserver/shares" # runcommand "rsync -a --delete $winbackupsrc/mcss/* $backupdest/winserver/mcss" runcommand "find $backupdest/winserver/SQL_Backup -type f -mtime +30 -exec rm {} \;" runcommand "rsync -av $winbackupsrc/SQL_Backup/* $backupdest/winserver/SQL_Backup" # runcommand "rsync -a --delete $winbackupsrc/Software/* $backupdest/winserver/Software" # runcommand "rsync -a --delete $winbackupsrc/users/* $backupdest/winserver/users" else echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo There was a problem with the SMB mount from the main server! Sending Steve a message about this. >>$logfile mutt -s "TriSUD !ERROR! Backup Log Report - Main server mount failed!" -c jbye@net-techs.com logs@net-techs.com <$logfile fi } function sendBackupComplete { echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo Backup complete $(date +"%Y-%m-%d--%H-%M"). Sending confirmation e-mail. >>$logfile mutt -s "TriSUD Normal Backup Log Report." logs@net-techs.com <$logfile } function performBackups { prepareUsbdisk performWinServerBackup performMailBackup #Check if number of errors is more than 0 if [ $errors -eq 0 ] then #No errors during backup. echo No Errors Found >>$logfile sendBackupComplete else #Errors found during backup. Warning admin. echo $errors Errors during backup! $errorstring >>$logfile mutt -s "!WARNING! TRI-SUD Errors during backup. Please check log for details." -c jbye@net-techs.com logs@net-techs.com <$logfile fi } #Define variables errors=0 logfile=/root/scripts/logs/backup.log backupdestdrive=/root/usbdisk winbackupsrc=/root/e old pd1uid=2cedb02b-3349-4005-83b1-3e2128e6ecf7 old pd2uid=bb42327f-9274-48e6-80d6-ea203e6c831c pd1uid=c0c00150-f188-4d6e-b355-01ba039d8b86 pd2uid=73c99d1e-d6ed-4cbe-9a36-bfc28b887512 if [ $(date +%w) = "0" ] then backupdest=/root/usbdisk/weekly else backupdest=/root/usbdisk/daily fi echo Start: --$(date +"%Y/%m/%d-%H:%M")-- >$logfile # Unmount /root/usbdisk/ echo . >>$logfile echo unmount /root/usbdisk >>$logfile umount /root/usbdisk/ 2>&1 >>$logfile # Unmount /root/e echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo unmount /root/e 2>&1 >>$logfile umount /root/e 2>&1 >>$logfile #Mount All echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo mount -a >>$logfile mount -a 2>&1 >>$logfile #Mount WinServer E Drive echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo /sbin/mount.cifs "//trisud-2008/c$" /root/e -o credentials=/root/scripts/smbcred >>$logfile /sbin/mount.cifs "//trisud-2008/c$" /root/e -o credentials=/root/scripts/smbcred >>$logfile 2>&1 #Mount PD1 echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo mount -U $pd1uid $backupdestdrive This is PD1 >>$logfile mount -U $pd1uid $backupdestdrive 2>&1 >>$logfile #Check if PD1 is mounted if [ -e "$backupdestdrive/PD1" ] then echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo Pocketdrive 1 is mounted. Performing Backup. >>$logfile performBackups else #Mount PD2 echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo mount -U $pd2uid $backupdestdrive This is PD2 >>$logfile mount -U $pd2uid $backupdestdrive 2>&1 >>$logfile #Check if PD2 is mounted if [ -e "$backupdestdrive/PD2" ] then echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo Pocketdrive 2 is mounted. Performing Backup. >>$logfile performBackups else echo . >>$logfile echo --$(date +"%Y/%m/%d-%H:%M")-- >>$logfile echo There was a problem finding the usb drive! Sending Steve a message about this. >>$logfile mutt -s "TriSUD !ERROR! Backup Log Report - USB disk mount failed!" -c jbye@net-techs.com logs@net-techs.com <$logfile fi fi umount /root/e 2>&1 >>$logfile umount /root/usbdisk 2>&1 >>$logfile |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0084 ]-- |