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 | else
|
---|
52 | echo "INFO Transfer "$nightrun
|
---|
53 | fi
|
---|
54 | fi
|
---|
55 |
|
---|
56 | rawdirisdc="/scratch/from_lapalma/raw"
|
---|
57 | isdcfile=`find $rawdirisdc -type f -regex ".*$nightrun[.]fits[.][fg]z"`
|
---|
58 | if [ "$isdcfile" == "" ]
|
---|
59 | then
|
---|
60 | echo "ERROR Could not find raw file for "$nightrun" on isdc-dl00 - Something is really wrong."
|
---|
61 | printprocesslog "ERROR Could not find raw file for "$nightrun" on isdc-dl00 - Something is really wrong."
|
---|
62 | continue
|
---|
63 | else
|
---|
64 | filename=`basename $isdcfile`
|
---|
65 | fi
|
---|
66 |
|
---|
67 | rawfileisdc=$rawdirisdc"/./"$nightpath"/"$filename
|
---|
68 | rawdirwue="/fact/raw/"
|
---|
69 |
|
---|
70 | setstatus "start"
|
---|
71 | if [ $numchanged -eq 0 ]
|
---|
72 | then
|
---|
73 | printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
|
---|
74 | continue
|
---|
75 | fi
|
---|
76 |
|
---|
77 | printprocesslog "INFO rsync rawfile "$rawfileisdc" to Wue "$rawdirwue
|
---|
78 | #rsync -rltDvR --partial --stats --password-file=/home_nfs/isdc/fact_opr/rsync.pwd factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
|
---|
79 | #echo "rsync -avxR --no-p --stats -T $rsynctempdir $rawfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1"
|
---|
80 | rsync -avxR --no-p --stats -T $rsynctempdir $rawfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
---|
81 | check1=$?
|
---|
82 |
|
---|
83 | case $check1 in
|
---|
84 | 0) printprocesslog "INFO rawfile "$rawfileisdc" transferred successfully to Wue."
|
---|
85 | ;;
|
---|
86 | *) printprocesslog "CONNECTION "$rawfileisdc" could not be transferred to Wue."
|
---|
87 | check=$check1
|
---|
88 | ;;
|
---|
89 | esac
|
---|
90 |
|
---|
91 | query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
|
---|
92 | numdrs=`sendquery`
|
---|
93 | if [ $numdrs -gt 0 ]
|
---|
94 | then
|
---|
95 | drsfileisdc=$rawdirisdc"/./"$nightpath"/"$nightrun".drs.fits.gz"
|
---|
96 | printprocesslog "INFO rsync rawfile "$drsfileisdc" to Wue "$rawdirwue
|
---|
97 | rsync -avxR --no-p --stats $drsfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
---|
98 | check1=$?
|
---|
99 |
|
---|
100 | case $check1 in
|
---|
101 | 0) printprocesslog "INFO rawfile "$drsfileisdc" transferred successfully to Wue."
|
---|
102 | ;;
|
---|
103 | *) printprocesslog "CONNECTION "$drsfileisdc" could not be transferred to Wue."
|
---|
104 | check=$check1
|
---|
105 | ;;
|
---|
106 | esac
|
---|
107 | fi
|
---|
108 |
|
---|
109 | setstatus "stop"
|
---|
110 | done
|
---|
111 |
|
---|
112 | finish
|
---|
113 |
|
---|