User Tools

Site Tools


misc:backup

My personal backup script:

#!/bin/sh

usage () {
    echo "$0: [--level #]"
    echo ""
    echo "backup script using dump(8) to create a level n backup"
}

TEMP=`getopt -o l:v: --long level:,volume -n'$0' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"

LEVEL="0"
VOLUME=""
SUDO=""

while true; do
    case "$1" in
        -l|--level) LEVEL="$2"; shift 2;;
        -v|--volume) VOLUME="$2"; shift 2;;
        --) shift ; break ;;
        *) usage ; exit 1 ;;
    esac
done

if [ -z "$VOLUME" ] || [ ! -b $VOLUME ]; then 
    echo "you must enter a logical volume to backup"
    exit 1;
fi

BACKUPDIR=`dirname $0`
VOLUMENAME=`basename $VOLUME`
ARCHIVEFILE="${BACKUPDIR}/${VOLUMENAME}.level-${LEVEL}.archive"

echo "$0 starting, backing up $VOLUMENAME to $BACKUPDIR"

dump -${LEVEL} -A ${ARCHIVEFILE} -B $((1024 * 2000)) -j \
        -u -D ${BACKUPDIR}/dumpdates \
        -M -f ${BACKUPDIR}/${VOLUMENAME}.level-${LEVEL}.dump \
        ${VOLUME}
misc/backup.txt · Last modified: 2008/12/15 10:15 by siretart