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