Current time: 11-26-2024, 04:36 AM Hello There, Guest! (LoginRegister)


Post Reply 
backup server support and incremental backups
Author Message
koffu Offline
Junior Member
*

Posts: 80
Joined: Jan 2010
Reputation: 1
Post: #6
RE: backup server support and incremental backups
(02-15-2010 07:55 PM)Boter Wrote:  Anything new on this?

As example cron script:

Code:
#!/bin/sh
COMPUTER=$1   #pc name as script param
DIRECTORIES="/var/www"  # dirs to backup
BACKUPDIR=/backups                              # where to store
#TIMEDIR=$BACKUPDIR/last-full                   # where to store time of full backup
FULLFN=$BACKUPDIR/$COMPUTER-last_full_date              # last full filename
TAR=/bin/tar                                            # name and locaction of.tar.gz

PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a`
DOM=`date +%d`
DM=`date +%d-%b`

if [ ! -d $BACKUPDIR ]; then
echo "BACKUPDIR $BACKUPDIR does not exist!"
exit 1
fi
if [ ! -d $DIRECTORIES ]; then
echo "DIRECTORIES $DIRECTORIES does not exist!"
exit 1
fi

# Monthly full backup
if [ $DOM = "01" ]; then
        NEWER=""
        $TAR $NEWER -czf $BACKUPDIR/$COMPUTER-$DM.tar.gz $DIRECTORIES
fi

# Weekly full backup
if [ $DOW = "Sun" ]; then
        NEWER=""
#        NOW=`date +%d-%b`

        # Update full backup date
#        echo $NOW > $TIMEDIR/$COMPUTER-full-date
        echo $DM > $FULLFN
        $TAR $NEWER -czf $BACKUPDIR/$COMPUTER-$DOW.tar.gz $DIRECTORIES

# Make incremental backup - overwrite last weeks
else
        #if we will .tar.gzt in the middle of week, hangle cycle correctly
        if [ ! -s $FULLFN ]; then
        NEWER=""
        echo $DM > $FULLFN
        $TAR $NEWER -czf $BACKUPDIR/$COMPUTER-$DOW.tar.gz $DIRECTORIES
        exit 0
        fi

        # Get date of last full backup
        NEWER="--newer `cat $FULLFN`"
        $TAR $NEWER -czf $BACKUPDIR/$COMPUTER-$DOW.tar.gz $DIRECTORIES
fi
02-15-2010 08:24 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
RE: backup server support and incremental backups - koffu - 02-15-2010 08:24 PM

Forum Jump:


User(s) browsing this thread: 4 Guest(s)