source: branches/trigger_burst_research/Transfer/BackupRawToWue.sh@ 18298

Last change on this file since 18298 was 17905, checked in by Daniela Dorner, 11 years ago
included and/or improved check of variable certaindate
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=RsyncRawToWue
7step=RawFileAvailWue
8
9set -C
10
11# check if only a certain date should be processed
12# (feature for manual speedup)
13if [ "$certaindate" != "" ]
14then
15 checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'`
16 if [ "$checkstring" = "" ]
17 then
18 echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)"
19 finish
20 fi
21 printprocesslog "INFO process only data of "$certaindate
22 echo "INFO process only data of "$certaindate
23 specialnight=`echo $certaindate | sed -e 's/\///g'`
24fi
25
26
27# checking that not more than $numrsyncwuelimit
28# instances of the script are running
29numrsyncwue=`/usr/sbin/lsof $0 | grep -o -c $0`
30if [ $numrsyncwue -gt $numrsyncwuelimit ]
31then
32 printprocesslog "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
33 finish
34fi
35
36logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
37date >> $logfile
38
39# get todo list
40gettodo
41
42
43for (( s=0 ; s < $num ; s++ ))
44do
45 night=${primaries[$s+$s]}
46 runid=${primaries[$s+$s+1]}
47 nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
48 nightrun=$night"_"`printf %03d $runid`
49
50 if [ "$specialnight" != "" ]
51 then
52 if [ $night -ne $specialnight ]
53 then
54 printprocesslog "INFO Treat only "$specialnight" -> continue for "$night
55 echo "INFO Treat only "$specialnight" -> continue for "$night
56 continue
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"
114done
115
116finish
117
Note: See TracBrowser for help on using the repository browser.