Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Plain Text by KEVIN ( 12 years ago )
#!/bin/bash

if [ $# != 4 ] ; then
    echo "Please re-enter correctly"
    echo "backup.sh file backupdir interval-secs max-backups"

else
    #create a file to test diff
    ls -lR $1 > ls-lR.last

    FILE=$1
    BACKUPDIR=$2
    INTSECS=$3
    MAXBACK=$4
    #keep track of backup amount
    COUNT=0
    DATE=$(date +"%Y-%m-%d-%H-%M-%S")

    #sleep with given interval sec
    sleep $INTSECS

    #verify file with new file
    ls -lR $COPIED > ls-lR.new

    #check for diff
    CHANGE=$(diff ls-lR.new ls-lR.last)
    #if there is a diff
    if [ $CHANGE != "" ] ; then
        mkdir $BACKUPDIR/$DATE
        cp -R $COPIED $BACKUPDIR/$DATE
        #add one count
        let COUNT=COUNT+1
        mv ls-lR.new ls-lR.last
        #send a mail
        echo "$COPIED backup allocated at $BACKUPDIR/$DATE/" > tmp-message
        /usr/bin.malix -s "mail-Backup" $USER < tmp-message
    fi
fi

 

Revise this Paste

Your Name: Code Language: