Previous |
Home | Next |
Versions: | - tar 1.15.90 - mutt 1.4.2 |
[bash]# vi /etc/fstab |
/dev/hdd /media/revdrive udf pamconsole,exec,noauto,user 0 0 |
[bash]# vi /bin/backup-script |
#!/bin/sh # # Test if Iomega Rev Drive has a cartridge inserted and is already mounted, otherwise mount it. # TESTMOUNT1=`grep /dev/hdd /etc/mtab` if [ -z "$TESTMOUNT1" ] ; then mount /media/revdrive fi TESTMOUNT2=`grep /dev/hdd /etc/mtab` if [ -z "$TESTMOUNT2" ] ; then echo -e The backup script on the server failed because the cartridge in the Iomega REV Drive could not be mounted... \\n\\n \ Please ensure a cartridge is inserted securely into the REV Drive. | mail -s \ "Please Insert Cartridge into Iomega REV Drive..." -c sysadmin exit fi # # Start 'tar' command. # Full backup excluding none required contents. # echo Backup script initiated at `date '+%H:%M:%S'`. > /tmp/tempmailfile rm -Rf /media/revdrive/* /bin/tar -cpjvf /tmp/Backup_for_`date '+%Y_%B_%d'`.tar.bz2 --totals --directory / \ --exclude=dev \ --exclude=lost+found \ --exclude=misc \ --exclude=media \ --exclude=mnt/cdrom \ --exclude=mnt/floppy \ --exclude=opt \ --exclude=proc \ --exclude=samba \ --exclude=selinux \ --exclude=sys \ --exclude=tmp \ --exclude=usr/bin \ --exclude=usr/lib \ --exclude=usr/share \ --exclude=usr/src \ --exclude=usr/X11R6 \ --exclude=var/cache/yum \ --exclude=var/lib \ --exclude=var/spool/squid \ --exclude=RESTORE \ /* \ | tee "/tmp/Backup set created on `date '+%Y %B %d'`.doc" ALLFILES=`du -h \ --exclude=dev \ --exclude=lost+found \ --exclude=misc \ --exclude=media \ --exclude=mnt/cdrom \ --exclude=mnt/floppy \ --exclude=opt \ --exclude=proc \ --exclude=samba \ --exclude=selinux \ --exclude=sys \ --exclude=tmp \ --exclude=usr/bin \ --exclude=usr/lib \ --exclude=usr/share \ --exclude=usr/src \ --exclude=usr/X11R6 \ --exclude=var/cache/yum \ --exclude=var/lib \ --exclude=var/spool/squid \ --exclude=RESTORE \ / | grep /$ | cut -f1` mv -f "/tmp/Backup set created on `date '+%Y %B %d'`.doc" /samba/backups/Filelists/ mv -f "/tmp/Backup_for_`date '+%Y_%B_%d'`.tar.bz2" /media/revdrive echo Backup script finished at `date '+%H:%M:%S'`. >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo Total size of ALL files in the archive: >> /tmp/tempmailfile echo $ALLFILES >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo Total size of the compressed archive: >> /tmp/tempmailfile du -h /media/revdrive/Backup_for_`date '+%Y_%B_%d'`.tar.bz2 >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo Backup file list may be located at '\\Galaxy\Backups' >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo >> /tmp/tempmailfile echo Remember: "/samba" directory is not backed up...... >> /tmp/tempmailfile cat /tmp/tempmailfile | mail -s "Backup Script (`date '+%d %B %Y'`)" root rm -f /tmp/tempmailfile cat /bin/backup-script.done | mail -s "System Back Has Occurred..!!!" -c sysadmin # # Finish up and eject cartridge. # cd / umount /media/revdrive sleep 60 eject /dev/hdd # EOF |
[bash]# vi /bin/backup-script.done |
The system backup has occurred ..... Remember to change Cartridges and store the 'ejected' one in a safe place. DON'T FORGET TO CHANGE THE TAPE... !! |
[bash]# chmod +x /bin/backup-script |
[bash]# crontab -e |
# ------------------------------------------------------------------------------ # Crontab file looks something like this. # # First digits indicate time in MINUTES. # Second digits indicate time in HOURS. # Third digits indicate DAY OF MONTH. # Fourth digits indicate MONTH OF YEAR. # Fifth digits indicate DAY OF WEEK. # # 15:00 every day would be indicated like: # 00 15 * * * /runthisprogram. # # 04:30 every Saturday would be indicated like; # 30 04 * * 06 /runthisprogram. # # 12:45 Monday 23 July, would be indicated like; # 45 12 23 07 01 /runthisprogram. # (This could be a problem if 23 July was not a Monday!) # # ------------------------------------------------------------------------------ 30 04 * * 02 /bin/backup-script |
Previous |
Home | Next |