
#!/bin/sh
# File	: bck-appl.sh
# By	: MaartenDeBoer.nl, 150103
# Subject	: Backup application & SSH-copy it to remote/destination host
#(0.2)	: Added crontab -l
#(0.3)	: Added; cd {HOME}
#(0.4)	: Added PORT, USER, ls -l
#(0.5),171127	: Changed name to bck-appl.sh
#(0.6),180731	: Mod exclude; exclude ALL *tgz
#(0.7),201104	: Mod. dir/appl
#set -x
PGM="`basename $0|cut -d\. -f1`"
VER="0.7"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
USER=`whoami`
HOSTNAME=`hostname|cut -d\. -f1`
TARFILE="appl-bck_${HOSTNAME}-${USER}.tgz"

APPLNAME="decarbon"
APPLDIR="/appl/netapp/decarbon"
TARFILE="appl-bck_${HOSTNAME}-${APPLNAME}.tgz"
DESTHOST="nlxnetapp02"
DESTPORT="22"
DESTUSER="nl19471"

echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}
touch ${TMP}

cd ${APPLDIR}
crontab -l > crontab.asc

tar cvzf ${TARFILE} --exclude=*tgz .

scp -P ${DESTPORT} ${APPLDIR}/${TARFILE} ${DESTUSER}@${DESTHOST}: 1>> ${LOG} 2>&1
ssh -p ${DESTPORT} ${DESTUSER}@${DESTHOST} "ls -l ${TARFILE}" | tee -a ${LOG}

echo "`date` ${PGM} finished."|tee -a ${LOG}
rm ${TMP}
exit 0

