source: trunk/DataCheck/Transfer/BackupRawToWue.sh@ 18613

Last change on this file since 18613 was 18435, checked in by Daniela Dorner, 9 years ago
added output for case of certaindate
  • Property svn:executable set to *
File size: 3.5 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 printprocesslog "INFO process only data of "$certaindate
16 echo "INFO process only data of "$certaindate
17 specialnight=`echo $certaindate | sed -e 's/\///g'`
18fi
19
20
21# checking that not more than $numrsyncwuelimit
22# instances of the script are running
23numrsyncwue=`/usr/sbin/lsof $0 | grep -o -c $0`
24if [ $numrsyncwue -gt $numrsyncwuelimit ]
25then
26 printprocesslog "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
27 finish
28fi
29
30logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
31date >> $logfile
32
33# get todo list
34gettodo
35
36
37for (( s=0 ; s < $num ; s++ ))
38do
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"
110done
111
112finish
113
Note: See TracBrowser for help on using the repository browser.