
#!/bin/sh
# File	: graphite_data_r-copy.sh
# By	: Maarten.deBoer@Atos.net, 260202
# Subject	: Script to copy data from "old" Graphite- to net-server
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
LOG="${HOME}/log/${PGM}.log"
SUBDIR=""
DIR="/appl/data/graphite/storage/whisper/"

if [ "${1}" != "${SUBDIR}" ]; then
  SUBDIR="${1}"
  DIR="/appl/data/graphite/storage/whisper/${SUBDIR}/"
fi  # ${1}

echo "`date` ${PGM} v${VER} started."|tee ${LOG}
echo "  SUBDIR=${SUBDIR}"|tee -a ${LOG}
echo "  DIR=${DIR}"|tee -a ${LOG}
sleep 1

# Using tar & scp
#cd /appl/data/graphite/storage/
#tar -czf - whisper | ssh nlxfsd16 'sudo tar -xvzf - -C /appl/data/graphite/storage

# now with rsync
# Skiped --progress
if [ -d ${DIR} ]; then
  rsync -av --rsync-path="sudo /usr/bin/rsync" ${DIR} nlxfsd16:${DIR} | tee -a ${LOG}
else
  echo "  DIR: ${DIR} NOT found. Exiting ..."|tee -a ${LOG}
  exit 4
fi  

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

