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

Last change on this file since 19272 was 18686, checked in by Daniela Dorner, 8 years ago
improved logging
  • Property svn:executable set to *
File size: 3.6 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 if [ "$specialnight" != "" ]
28 then
29 echo "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
30 fi
31 finish
32fi
33
34logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
35date >> $logfile
36
37# get todo list
38gettodo
39
40
41for (( s=0 ; s < $num ; s++ ))
42do
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"
114done
115
116finish
117
Note: See TracBrowser for help on using the repository browser.