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 | # check if only a certain date should be processed
|
---|
12 | # (feature for manual speedup)
|
---|
13 | if [ "$certaindate" != "" ]
|
---|
14 | then
|
---|
15 | printprocesslog "INFO process only data of "$certaindate
|
---|
16 | echo "INFO process only data of "$certaindate
|
---|
17 | specialnight=`echo $certaindate | sed -e 's/\///g'`
|
---|
18 | fi
|
---|
19 |
|
---|
20 |
|
---|
21 | # checking that not more than $numrsyncwuelimit
|
---|
22 | # instances of the script are running
|
---|
23 | numrsyncwue=`/usr/sbin/lsof $0 | grep -o -c $0`
|
---|
24 | if [ $numrsyncwue -gt $numrsyncwuelimit ]
|
---|
25 | then
|
---|
26 | printprocesslog "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
|
---|
27 | finish
|
---|
28 | fi
|
---|
29 |
|
---|
30 | logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
|
---|
31 | date >> $logfile
|
---|
32 |
|
---|
33 | # get todo list
|
---|
34 | gettodo
|
---|
35 |
|
---|
36 |
|
---|
37 | for (( s=0 ; s < $num ; s++ ))
|
---|
38 | do
|
---|
39 | night=${primaries[$s+$s]}
|
---|
40 | runid=${primaries[$s+$s+1]}
|
---|
41 | nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
|
---|
42 | nightrun=$night"_"`printf %03d $runid`
|
---|
43 |
|
---|
44 | if [ "$specialnight" != "" ]
|
---|
45 | then
|
---|
46 | if [ $night -ne $specialnight ]
|
---|
47 | then
|
---|
48 | printprocesslog "INFO Treat only "$specialnight" -> continue for "$night
|
---|
49 | echo "INFO Treat only "$specialnight" -> continue for "$night
|
---|
50 | continue
|
---|
51 | fi
|
---|
52 | fi
|
---|
53 |
|
---|
54 | rawdirisdc="/scratch/from_lapalma/raw"
|
---|
55 | isdcfile=`find $rawdirisdc -type f -regex ".*$nightrun[.]fits[.][fg]z"`
|
---|
56 | if [ "$isdcfile" == "" ]
|
---|
57 | then
|
---|
58 | echo "ERROR Could not find raw file for "$nightrun" on isdc-dl00 - Something is really wrong."
|
---|
59 | printprocesslog "ERROR Could not find raw file for "$nightrun" on isdc-dl00 - Something is really wrong."
|
---|
60 | continue
|
---|
61 | else
|
---|
62 | filename=`basename $isdcfile`
|
---|
63 | fi
|
---|
64 |
|
---|
65 | rawfileisdc=$rawdirisdc"/./"$nightpath"/"$filename
|
---|
66 | rawdirwue="/fact/raw/"
|
---|
67 |
|
---|
68 | setstatus "start"
|
---|
69 | if [ $numchanged -eq 0 ]
|
---|
70 | then
|
---|
71 | printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
|
---|
72 | continue
|
---|
73 | fi
|
---|
74 |
|
---|
75 | printprocesslog "INFO rsync rawfile "$rawfileisdc" to Wue "$rawdirwue
|
---|
76 | #rsync -rltDvR --partial --stats --password-file=/home_nfs/isdc/fact_opr/rsync.pwd factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
|
---|
77 | #echo "rsync -avxR --no-p --stats -T $rsynctempdir $rawfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1"
|
---|
78 | rsync -avxR --no-p --stats -T $rsynctempdir $rawfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
---|
79 | check1=$?
|
---|
80 |
|
---|
81 | case $check1 in
|
---|
82 | 0) printprocesslog "INFO rawfile "$rawfileisdc" transferred successfully to Wue."
|
---|
83 | ;;
|
---|
84 | *) printprocesslog "CONNECTION "$rawfileisdc" could not be transferred to Wue."
|
---|
85 | check=$check1
|
---|
86 | ;;
|
---|
87 | esac
|
---|
88 |
|
---|
89 | query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
|
---|
90 | numdrs=`sendquery`
|
---|
91 | if [ $numdrs -gt 0 ]
|
---|
92 | then
|
---|
93 | drsfileisdc=$rawdirisdc"/./"$nightpath"/"$nightrun".drs.fits.gz"
|
---|
94 | printprocesslog "INFO rsync rawfile "$drsfileisdc" to Wue "$rawdirwue
|
---|
95 | rsync -avxR --no-p --stats $drsfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
---|
96 | check1=$?
|
---|
97 |
|
---|
98 | case $check1 in
|
---|
99 | 0) printprocesslog "INFO rawfile "$drsfileisdc" transferred successfully to Wue."
|
---|
100 | ;;
|
---|
101 | *) printprocesslog "CONNECTION "$drsfileisdc" could not be transferred to Wue."
|
---|
102 | check=$check1
|
---|
103 | ;;
|
---|
104 | esac
|
---|
105 | fi
|
---|
106 |
|
---|
107 | setstatus "stop"
|
---|
108 | done
|
---|
109 |
|
---|
110 | finish
|
---|
111 |
|
---|