Instructables

How easily to backup your linux box using rdiff-backup

Step 5: Write a function

Picture of Write a function
Next we will write a function to actually do the backup.

function backup {
DEST=$1$2
SOURCE=$2
echo "Src : $SOURCE"
if [-d $DEST]
then
echo "Dest: $DEST"
else
mkdir -p $DEST
echo "Dest: $DEST -created"
OPTS="--force"
fi

#Perform backup
rdiff-backup -v2 --exclude-special-files $OPTS $SOURCE $DEST
#Cleanup version files older than 4weeks
rdiff-backup -v2 --remove-older-than 4W --force $DEST
#Print a report of what we backed up and cleaned up
rdiff-backup --list-changed-since 0D23h00m $DEST
}

 
Remove these adsRemove these ads by Signing Up
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!