[olug] backup script

Jay Swackhamer Jay at RebootTheUser.com
Thu Jul 29 16:21:15 UTC 2010


If anyone needs a backup script for a limited connectivity  
environment, here's a script that takes a config file for dirs/options  
and tar/compress/encrypt/copy over ssh to a remote machine. You just  
need the target directory on the remote machine, and an ssh key setup.


--------------backup script-----------------
#!/bin/bash

DATE=`date +%w`
SYS=`uname -n`

if [ "${1}" != "" ]; then
    . ${1}
else
    echo "You need to specify a config file"
fi

BACKUP_DIR="${OUTPUT_DIR}${DATE}/"
BACKUP_FILE="${BACKUP_DIR}/${SYS}.tgz"
export PASS

#encrypt: tar -c directory | openssl des3 -salt -pass env:PASS >  
encrypted.tarfile
#decrypt: cat encrypted.tgz | openssl des3 -d -salt -pass env:PASS | tar -xzv

cd /
ssh root@${BACKUP_SVR} "mkdir -p ${BACKUP_DIR}"
tar cz - ${OPTS} ${EXCLUDE} ${DIRS} | openssl des3 -salt -pass  
env:PASS | ssh root@${BACKUP_SVR} "dd of=${BACKUP_FILE}"


----------config---------------
EXCLUDE="--exclude=sys/* --exclude=proc/* --exclude=u9*"
DIRS="/ /opt /var /arch /boot"
OPTS="--one-file-system"
PASS="EncryptPassword"
BACKUP_SVR="backupservername"
OUTPUT_DIR="/backup/"

-- 
Jay Swackhamer
Reboot The User
402-933-6449
http://www.reboottheuser.com
http://www.cafepress.com/rtu
http://stores.ebay.com/RebootTheUser
http://www.hotr.com








More information about the OLUG mailing list