#! /bin/sh
HOST='Ulefr01Cloud'
USER='franz'
# echt password is gemaakt met `echo xxxxxxxx | openssl enc -bf-cbc >lftp.dat` 
PASSWD=`openssl enc -bf-cbc -d <lftp.dat`
ARGS=1
E_BADARGS=65
if [ $# -ne "$ARGS" ]
then
   echo "Usage: `basename $0` Folder"
   exit $E_BADARGS
fi
folder=$1
LOCAL_FILES='/data/'$folder
CLOUD_FILES='franz/'$folder
LOG1=/data/log2.log
echo "starting download $CLOUD_FILES from $HOST to $LOCAL_FILES"
date
# also hidden files : 'ftp:list-options -a' is required
# also exclude mostly unchanged big folders
lftp -u "$USER","$PASSWD" ftp://$HOST -e "set ftp:list-options -a"<<EOF
mirror -nc -v -a \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2016.sbd/ \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-01* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-02* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-03* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-04* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-05* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-06* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-07* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-08* \
 --exclude .thunderbird/q8aginh6.default/Mail/Local\ Folders/2017.sbd/2017-09* \
 --log=$LOG1 $CLOUD_FILES $LOCAL_FILES
exit
EOF
echo 'ftpcloud done for /data/' $folder  
cat /data/log2.log
exit 0
