Friday 8 August 2014

Backup Script

Daily Backup Script

#!/bin/bash
#
# Daily Backup Script
#

USER=Ajay
IP=192.168.30.5
MONTH=July
YEAR=2011

set $(date)

#### Backup Directory Path ####
BDP=/devbackups/$USER/Daily_Backup/$MONTH-$YEAR/Daily-$3-$2-$6
mkdir -p $BDP

#### Deleting temporary massage file ####
/bin/rm -f /tmp/$USER.txt

#### Desktop Directory Backup ####
if scp -r $IP:/Local_Backup/Daily-$3-$2-$6/Desktop-$3-$2-$6.tar.bz2     /$BDP  >&/dev/null ;

then
        echo "DESKTOP Backup file is found and Backup send to the Fileserver.  Its size is $(du -sh $BDP/D* | cut -d "/" -f 1) " >> /tmp/$USER.txt

else
        echo "DESKTOP Backup file is NOT found and Backup has not done. " >> /tmp/$USER.txt

fi


#### Work Directory Backup ####
if scp -r $IP:/Local_Backup/Daily-$3-$2-$6/WORK_AJAY-$3-$2-$6.tar.bz2   /$BDP  >&/dev/null ;

then
        echo "WORK Directory Bakup file is found and Send to the fileserver . Its size is $(du -sh $BDP/W* | cut -d "/" -f 1)" >> /tmp/$USER.txt

else
        echo "WORK Directory Backup file is NOT found that's Backup has not done" >> /tmp/$USER.txt

fi


#### Mailing Backup Report ####
/bin/mail -s "$USER's Backup Status" sysadmin@dev.tbmtechnologies.com < /tmp/$USER.txt ;


#### Shutting Down the System ####

ssh $IP '/sbin/shutdown -h 2'

No comments:

Post a Comment

Boot to UEFI Mode or legacy BIOS mode

Boot to UEFI Mode or legacy BIOS mode Choose UEFI or legacy BIOS modes while installing Windows. After Windows is installed, if you nee...