
#!/bin/sh
# File	: copy_filer-files.sh
# By	: Maarten.deBoer@Atos.net, 140910
# Subject	: Script to copy filer-files (FW, etc) (from MSS02) to filers
# Copied from copy_software.sh
PGM="`basename $0|cut -d\. -f1`"
VER="0.1"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
SSH="/usr/bin/ssh -n"
FILES="${HOME}/etc/files.list"

SRCFILER="nlnaf26"
SRCDIR="/vol/bc_mss02_vol002/logfiles/filer/"

FILERS="nlnaf83 nlnaf84 nlnaf85 nlnaf86"

if [ ! -f ${FILES} ]; then
  echo "Files-file ${FILES} does NOT exist. Exiting ..."
  exit 2
fi

echo "`date` ${PGM} started "|tee -a ${LOG}
touch ${TMP}
# Get NDMP passwords
PWD_SRC=`${SSH} ${SRCFILER} ndmpd password ndmpd_user | awk '{print $2}'`

for FILER in $FILERS
do
  echo "  ${FILER} ..."|tee -a ${LOG}
  PWD_DST=`${SSH} ${FILER} ndmpd password ndmpd_user | awk '{print $2}'`
# Get the list of files. Because NDMP-copy can not cope with *
  cat ${FILES}|grep -v ^#|while read FILE
  do
    echo ${FILE}
    DESTDIR="`echo ${FILE}|cut -d\/ -f1`"
    ${SSH} ${FILER} ndmpcopy -sa ndmpd_user:${PWD_SRC} -da ndmpd_user:${PWD_DST} ${SRCFILER}-sm:${SRCDIR}/${FILE} ${FILER}-sm:/vol/vol0/etc/${DESTDIR}

  done  # cat ${FILES}
done

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

