#!/bin/bash # this script has been written to run on La Palma on the machine daq # i.e. paths are only working on this machine source `dirname $0`/../Sourcefile.sh printprocesslog "INFO starting "$0 logfile=$runlogpath"/RsyncAuxLP-"$datetime".log" date >> $logfile # check if /daq is mounted on data if ! mount | grep data >> $logfile 2>&1 then printprocesslog "ERROR /data is not mounted on daq => please mount it" echo `date`": /data is not mounted on daq => please mount it" finish fi # check if paths are available if ! ls /data/aux >/dev/null 2>&1 then printprocesslog "ERROR /data/aux is not available." finish fi if ! ls /loc_data/aux >/dev/null 2>&1 then printprocesslog "ERROR /loc_data/aux is not available." finish fi # do the rsync for the last 6 days dirs=( `ssh newdaq "find /loc_data/aux/ -mindepth 3 -type d | sort | tail -6"` ) # do rsync for auxfiles in these directories for dir in ${dirs[@]} do echo "" >> $logfile 2>&1 # directory on daq if ! [ -d $dir ] then mkdir -pv $dir >> $logfile 2>&1 fi # directory on data dirdata=`echo $dir | sed -e 's/loc_//'` if ! [ -d $dirdata ] then mkdir -pv $dirdata >> $logfile 2>&1 fi printprocesslog "INFO processing files in "$dir >> $logfile 2>&1 echo `date`": processing files in "$dir >> $logfile 2>&1 # get current hour hour=`date +%k` # define bwlimit for rsync depending on the time: from 19-7h reduced bwlimit for rsync if [ $hour -le 6 ] || [ $hour -ge 19 ] then # limit bw for rsync to 20 MB/s during night bwlimit="--bwlimit=20000" bwlimit="--bwlimit=5000" printprocesslog "INFO rsync files with "$bwlimit >> $logfile 2>&1 echo "rsync files with "$bwlimit >> $logfile 2>&1 else # no bw limit during day bwlimit="" printprocesslog "INFO rsync files without bwlimit" >> $logfile 2>&1 echo "rsync files without bwlimit" >> $logfile 2>&1 fi # rsync from newdaq to daq rsyncserverdir=`echo $dir | sed -e 's/^\//172.16.100.100::/' -e 's/loc_data/newdaq/'` # old #if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit newdaq:$dir/ $dir >> $logfile 2>&1 # new (temporary until pb on daq is solved) if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit $rsyncserverdir/ $dir >> $logfile 2>&1 then printprocesslog "CONNECTION problem rsyncing auxiliary files in "$dir" from newdaq to daq" echo `date`": problem rsyncing auxiliary files in "$dir" from newdaq to daq" >> $logfile 2>&1 fi # rsynctemp-dir -> use one on data!!! i.e. has to be /data/rsync_tmp # rsync from daq to data # old (rsynctempdirdata not tested) #rsynctempdirdata=`echo $rsynctempdir | sed -e 's/loc_//'` #if ! /usr/bin/rsync -avxHP -T $rsynctempdirdata $bwlimit $dir/ $dirdata >> $logfile 2>&1 # new rsyncserverdirdata=`echo $dir | sed -e 's/^\//data::/' -e 's/loc_//'` rsynctempdirdata=/rsync_tmp if ! /usr/bin/rsync -avxHP -T $rsynctempdirdata $bwlimit $dir/ $rsyncserverdirdata >> $logfile 2>&1 then printprocesslog "CONNECTION problem rsyncing auxiliary files in "$dir" from daq to data" echo `date`": problem rsyncing auxiliary files in "$dir" from daq to data" >> $logfile 2>&1 fi done