|
Simple Full and Incremental Backups
In the event you cannot afford a high dollar backup solution,
or you just want to augment what you already have, this is a very
simplified script for doing full and incremental backups.
#!/bin/bash
## VARIABLES
HOST=`hostname`
FILE="/root/scripts/backups/backups.txt"
DEST="/backups"
ERRORS="/root/scripts/backups/backups.err"
DATETIME=`date`
DATENAME=`date +%a`
DATENUMB=`date +%d`
DATEFULL=`date +%Y%m%d`
## CHECK FOR MOUNT POINT
if [ ! -d $DEST ]
then
ERROR="$DATEFULL $DEST does not exist, creating"
echo $ERROR >> $ERRORS
mkdir -p $DEST
fi
## FULL DUMPS
if [ $DATENUMB == "01" ]
then
TYPE="Full"
NAME="home"
DATA="/home/*"
ARCH=$DEST/$DATEFULL-$NAME-$HOST-$TYPE.tgz
tar -cvz -f $ARCH $DATA
echo $DATETIME >> $FILE
fi
## INCR DUMPS
if [ $DATENUMB != "01" ]
then
TYPE="Incr"
LAST=`tail -1 $FILE`
NAME="home"
DATA="/home/*"
ARCH=$DEST/$DATEFULL-$NAME-$HOST-$TYPE.tgz
tar -N "$LAST" -cvz -f $ARCH $DATA
echo $DATETIME >> $FILE
fi
Obviously you can adjust the script to perform the full backups
whenever you desire (this one is monthly) and you can enter in
any number of paths to backup. It would be wise if your destination
mount path was from a remote server so its not stored locally.
- Scotech
|