| 1 | #!/bin/bash
|
|---|
| 2 |
|
|---|
| 3 | # this script has been written to run on La Palma on the machine data
|
|---|
| 4 | # i.e. paths are only working on this machine
|
|---|
| 5 |
|
|---|
| 6 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 7 | printprocesslog "INFO starting "$0
|
|---|
| 8 |
|
|---|
| 9 | logfile=$runlogpath"/RsyncRawLP-"$datetime".log"
|
|---|
| 10 | date >> $logfile
|
|---|
| 11 |
|
|---|
| 12 | # check if /daq is mounted on data
|
|---|
| 13 | if ! mount | grep daq >> $logfile 2>&1
|
|---|
| 14 | then
|
|---|
| 15 | printprocesslog "ERROR /daq is not mounted on data => please mount it"
|
|---|
| 16 | echo `date`": /daq is not mounted on data => please mount it"
|
|---|
| 17 | finish
|
|---|
| 18 | fi
|
|---|
| 19 |
|
|---|
| 20 | # check if paths are available
|
|---|
| 21 | if ! ls /daq/raw >/dev/null 2>&1
|
|---|
| 22 | then
|
|---|
| 23 | printprocesslog "ERROR /daq/raw is not available."
|
|---|
| 24 | finish
|
|---|
| 25 | fi
|
|---|
| 26 | if ! ls /loc_data/raw >/dev/null 2>&1
|
|---|
| 27 | then
|
|---|
| 28 | printprocesslog "ERROR /loc_data/raw is not available."
|
|---|
| 29 | finish
|
|---|
| 30 | fi
|
|---|
| 31 |
|
|---|
| 32 | # get last 3, 6 or 9 nights
|
|---|
| 33 | #dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
|
|---|
| 34 | # `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
|
|---|
| 35 | # `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
|
|---|
| 36 | # )
|
|---|
| 37 |
|
|---|
| 38 | dates=(
|
|---|
| 39 | `date +%Y/%m/%d --date="-204hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-156hour"` \
|
|---|
| 40 | `date +%Y/%m/%d --date="-132hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-84hour"` \
|
|---|
| 41 | `date +%Y/%m/%d --date="-60hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-12hour"` \
|
|---|
| 42 | )
|
|---|
| 43 |
|
|---|
| 44 | # do rsync for rawfiles of these dates
|
|---|
| 45 | for date in ${dates[@]}
|
|---|
| 46 | do
|
|---|
| 47 | echo "" >> $logfile 2>&1
|
|---|
| 48 | # raw data directories on data
|
|---|
| 49 | rawdirdaq=/daq/raw/$date/ # /loc_data from daq via nfs on data
|
|---|
| 50 | rawdirdata=/loc_data/raw/$date
|
|---|
| 51 | if ! [ -d $rawdirdaq ]
|
|---|
| 52 | then
|
|---|
| 53 | echo `date`": "$rawdirdaq" not found. No data available on daq." >> $logfile 2>&1
|
|---|
| 54 | if [ -d $rawdirdata ]
|
|---|
| 55 | then
|
|---|
| 56 | printprocesslog "WARN "$rawdirdaq" not found, but "$rawdirdata". Data probably taken on data." >> $logfile 2>&1
|
|---|
| 57 | else
|
|---|
| 58 | printprocesslog "INFO "$rawdirdaq" not found. No data available on daq." >> $logfile 2>&1
|
|---|
| 59 | fi
|
|---|
| 60 | continue
|
|---|
| 61 | fi
|
|---|
| 62 | if ! [ -d $rawdirdata ]
|
|---|
| 63 | then
|
|---|
| 64 | mkdir -pv $rawdirdata >> $logfile 2>&1
|
|---|
| 65 | fi
|
|---|
| 66 | printprocesslog "INFO processing files in "$rawdirdaq >> $logfile 2>&1
|
|---|
| 67 | echo `date`": processing files in "$rawdirdaq >> $logfile 2>&1
|
|---|
| 68 |
|
|---|
| 69 | # get current hour
|
|---|
| 70 | hour=`date +%k`
|
|---|
| 71 | # define bwlimit for rsync depending on the time: from 19-7h reduced bwlimit for rsync
|
|---|
| 72 | if [ $hour -le 6 ] || [ $hour -ge 19 ]
|
|---|
| 73 | then
|
|---|
| 74 | # limit bw for rsync to 20 MB/s during night
|
|---|
| 75 | bwlimit="--bwlimit=20000"
|
|---|
| 76 | printprocesslog "INFO rsync data with "$bwlimit >> $logfile 2>&1
|
|---|
| 77 | echo "rsync data with "$bwlimit >> $logfile 2>&1
|
|---|
| 78 | else
|
|---|
| 79 | # no bw limit during day
|
|---|
| 80 | printprocesslog "INFO rsync data without bwlimit" >> $logfile 2>&1
|
|---|
| 81 | echo "rsync data without bwlimit" >> $logfile 2>&1
|
|---|
| 82 | fi
|
|---|
| 83 |
|
|---|
| 84 | #rsync from daq to data
|
|---|
| 85 | #if ! /usr/bin/rsync -avxHPu $bwlimit $rawdirdaq $rawdirdata >> $logfile 2>&1 # in case of adding checksum, only update files with rsync
|
|---|
| 86 | if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit $rawdirdaq $rawdirdata >> $logfile 2>&1
|
|---|
| 87 | then
|
|---|
| 88 | printprocesslog "WARN problem rsyncing rawdata for "$date" from daq to data"
|
|---|
| 89 | echo `date`": problem rsyncing rawdata for "$date" from daq to data"
|
|---|
| 90 | fi
|
|---|
| 91 | done
|
|---|
| 92 |
|
|---|
| 93 | finish
|
|---|
| 94 |
|
|---|