Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # full and incremental backup script
- # created 07 February 2000
- # Based on a script by Daniel O'Callaghan <[email protected]>
- # and modified by Gerhard Mourani <[email protected]>
- # and modified by Antonio Vanegas <[email protected]> @hpsaturn
- #Change the 5 variables below to fit your computer/backup
- COMPUTER=home # name of this computer
- ROOT=/mnt/samba/bkp
- DIRECTORIES=/home/xxx # directoris to backup
- BACKUPDIR=$ROOT/$COMPUTER # where to store the backups
- TIMEDIR=$ROOT/$COMPUTER/last-full # where to store time of full backup
- TAR=/bin/tar # name and locaction of tar
- IGNORE=$ROOT/$COMPUTER/ignorefiles # list ignore
- #You should not have to change anything below here
- PATH=/usr/local/bin:/usr/bin:/bin
- DOW=`date +%a` # Day of the week e.g. Mon
- DOM=`date +%d` # Date of the Month e.g. 27
- DM=`date +%d%b` # Date and Month e.g. 27Sep
- DATE=`date +%Y%m%d` # Date format AAAAMMDD
- # On the 1st of the month a permanet full backup is made
- # Every Sunday a full backup is made - overwriting last Sundays backup
- # The rest of the time an incremental backup is made. Each incremental
- # backup overwrites last weeks incremental backup of the same name.
- #
- # if NEWER = "", then tar backs up all files in the directories
- # otherwise it backs up files newer than the NEWER date. NEWER
- # gets it date from the file written every Sunday.
- # Monthly full backup
- if [ $DOM = "14" ]; then
- NEWER=""
- $TAR $NEWER -zcf $BACKUPDIR/bkp_$COMPUTER_$DATE.tar.gz --exclude-from=$IGNORE $DIRECTORIES
- fi
- # Weekly full backup
- if [ $DOW = "Fri" ]; then
- NEWER=""
- NOW=`date +%d-%b`
- # Update full backup date (/tmp for samba)
- echo $NOW > /tmp/$COMPUTER-full-date
- mv /tmp/$COMPUTER-full-date $TIMEDIR/
- # remove file if exist
- FILE=$BACKUPDIR/$COMPUTER-$DOW.tar.gz
- if [ -e $FILE ]; then
- rm $FILE
- fi
- $TAR $NEWER -zcf $FILE --exclude-from=$IGNORE $DIRECTORIES
- # Make incremental backup - overwrite last weeks
- else
- # Get date of last full backup
- NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
- # remove file if exist
- FILE=$BACKUPDIR/$COMPUTER-$DOW.tar.gz
- if [ -e $FILE ]; then
- rm $FILE
- fi
- $TAR $NEWER -zcf $FILE --exclude-from=$IGNORE $DIRECTORIES
- fi
Advertisement
Add Comment
Please, Sign In to add comment