| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 |
|
|---|
| 4 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 5 | printprocesslog "INFO starting $0"
|
|---|
| 6 | program=RsyncRawToWue
|
|---|
| 7 | step=RawFileAvailWue
|
|---|
| 8 |
|
|---|
| 9 | set -C
|
|---|
| 10 |
|
|---|
| 11 | # checking that not more than $numrsyncwuelimit
|
|---|
| 12 | # instances of the script are running
|
|---|
| 13 | numrsyncwue=`/usr/sbin/lsof $0 | grep -o -c $0`
|
|---|
| 14 | if [ $numrsyncwue -gt $numrsyncwuelimit ]
|
|---|
| 15 | then
|
|---|
| 16 | printprocesslog "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
|
|---|
| 17 | finish
|
|---|
| 18 | fi
|
|---|
| 19 |
|
|---|
| 20 | logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
|
|---|
| 21 | date >> $logfile
|
|---|
| 22 |
|
|---|
| 23 | # get todo list
|
|---|
| 24 | gettodo
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | for (( s=0 ; s < $num ; s++ ))
|
|---|
| 28 | do
|
|---|
| 29 | night=${primaries[$s+$s]}
|
|---|
| 30 | runid=${primaries[$s+$s+1]}
|
|---|
| 31 | nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
|
|---|
| 32 |
|
|---|
| 33 | setstatus "start"
|
|---|
| 34 | if [ $numchanged -eq 0 ]
|
|---|
| 35 | then
|
|---|
| 36 | printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
|
|---|
| 37 | continue
|
|---|
| 38 | fi
|
|---|
| 39 |
|
|---|
| 40 | rawdirisdc="/scratch/from_lapalma/raw"
|
|---|
| 41 | rawfileisdc=$rawdirisdc"/./"$nightpath"/"$night"_"`printf %03d $runid`".fits.gz"
|
|---|
| 42 | rawdirwue="/fact/raw/"
|
|---|
| 43 |
|
|---|
| 44 | printprocesslog "INFO rsync rawfile "$rawfileisdc" to Wue "$rawdirwue
|
|---|
| 45 | #rsync -rltDvR --partial --stats --password-file=/home_nfs/isdc/fact_opr/rsync.pwd factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
|
|---|
| 46 | rsync -avxR --no-p --stats -T $rsynctempdir $rawfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
|---|
| 47 | check1=$?
|
|---|
| 48 |
|
|---|
| 49 | case $check1 in
|
|---|
| 50 | 0) printprocesslog "INFO rawfile "$rawfileisdc" transferred successfully to Wue."
|
|---|
| 51 | ;;
|
|---|
| 52 | *) printprocesslog "WARN "$rawfileisdc" could not be transferred to Wue."
|
|---|
| 53 | check=$check1
|
|---|
| 54 | ;;
|
|---|
| 55 | esac
|
|---|
| 56 |
|
|---|
| 57 | query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
|
|---|
| 58 | numdrs=`sendquery`
|
|---|
| 59 | if [ $numdrs -gt 0 ]
|
|---|
| 60 | then
|
|---|
| 61 | drsfileisdc=$rawdirisdc"/./"$nightpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
|
|---|
| 62 | printprocesslog "INFO rsync rawfile "$drsfileisdc" to Wue "$rawdirwue
|
|---|
| 63 | rsync -avxR --no-p --stats $drsfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
|---|
| 64 | check1=$?
|
|---|
| 65 |
|
|---|
| 66 | case $check1 in
|
|---|
| 67 | 0) printprocesslog "INFO rawfile "$drsfileisdc" transferred successfully to Wue."
|
|---|
| 68 | ;;
|
|---|
| 69 | *) printprocesslog "WARN "$drsfileisdc" could not be transferred to Wue."
|
|---|
| 70 | check=$check1
|
|---|
| 71 | ;;
|
|---|
| 72 | esac
|
|---|
| 73 | fi
|
|---|
| 74 |
|
|---|
| 75 | setstatus "stop"
|
|---|
| 76 | done
|
|---|
| 77 |
|
|---|
| 78 | finish
|
|---|
| 79 |
|
|---|