#!/bin/sh FTP_SERVER=backup.serverkompetenz.de DIRNAME=`date +%Y-%m` FILEDATE=`date +%Y-%m-%d` BACKUPPATH="backup/full/${DIRNAME}" # Check that the .dumppartitions file is available if [ ! -e ${HOME}/.dumppartitions ]; then echo "$0: The config file .dumppartitions not found in \$HOME" exit 4 fi # Get the paths to the used commands that are not in base NCFTPPUT=`whereis ncftpput` if [ -z ${NCFTPPUT} ]; then echo "$0: Unable to find command ncftpput" exit 3 fi ARGS=`getopt l: $*` if [ $? -ne 0 ]; then echo "Usage: $0 -ln" echo "\t-l n\tWhere n is the dumplevel" exit 2 fi # Set 0 as the default dump level LEVEL=0 set -- ${ARGS} while [ $# -ge 0 ]; do case "$1" in -l) LEVEL="$2"; shift; shift ;; --) shift; break ;; esac done LEVEL=$((LEVEL + 0)) #echo $LEVEL # Create the dump directory on the ftp server # TODO: Create the directory recursivly /usr/bin/ftp <<-EOF open ${FTP_SERVER} epsv binary verbose mkdir "${BACKUPPATH}" EOF while read PARTITION ; do FILENAME="backup-full-${PARTITION}-${FILEDATE}-${LEVEL}" echo "Backup from /dev/${PARTITION} to ${FILENAME}" dump -${LEVEL} -a -u -f - /dev/${PARTITION} \ | ${NCFTPPUT} -f/root/.ncftplogin \ -c ${FTP_SERVER} \ "${BACKUPPATH}/${FILENAME}" done < ${HOME}/.dumppartitions