source: trunk/DataCheck/Transfer/RsyncRawToISDC.sh @ 19487

Last change on this file since 19487 was 19487, checked in by dorner, 7 weeks ago
print only warning if the missing file is older than a few days
  • Property svn:executable set to *
File size: 6.6 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=RsyncRawToISDC
7step=RawFileRsyncedISDC
8rsyncpwfile=/home_nfs/isdc/fact_opr/rsync.pwd
9
10set -C
11
12logfile=$runlogpath"/RsyncRawToISDC-"$datetime".log"
13date >> $logfile 2>&1
14
15
16# check if only a certain date should be processed
17#  (feature for manual speedup)
18if [ "$certaindate" != "" ]
19then
20   printprocesslog "INFO process only data of "$certaindate
21   echo "INFO process only data of "$certaindate
22   specialnight=`echo $certaindate | sed -e 's/\///g'`
23fi
24
25
26# stop transfer when less than 100 GB are left
27function check_scratch()
28{
29   diskusage2=( `df -P /scratch | grep scratch ` )
30   # check if more than X GB are left on /scratch
31   if [ ${diskusage2[3]} -lt 100000 ] 
32   then
33      printprocesslog "DISK less than 100 GB left on /scratch ("${diskusage2[3]}")"
34      echo "WARN less than 100 GB left on /scratch ("${diskusage2[3]}")" 
35      finish
36   fi
37}
38
39check_scratch
40
41# get todo list
42gettodo
43
44for (( s=0 ; s < $num ; s++ ))
45do
46   check_scratch
47   night=${primaries[$s+$s]}
48   runid=${primaries[$s+$s+1]}
49   nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
50   lppath="/data2/zipraw/"$nightpath
51   nightrun=$night"_"`printf %03d $runid`
52
53   # continue if only special night should be processed for manual speedup
54   if [ "$specialnight" != "" ]
55   then
56      if [ $night -ne $specialnight ]
57      then
58         printprocesslog "INFO Treat only "$specialnight" -> continue for "$night
59         echo "INFO Treat only "$specialnight" -> continue for "$night
60         continue
61      else
62         echo "INFO Transfer "$nightrun
63      fi
64   fi
65
66   lpfile=`ssh fact@161.72.93.138 "find $lppath -type f -regex '.*$nightrun[.]fits[.][fg]z'"`
67   if [ "$lpfile" == "" ]
68   then
69      #echo $nightrun" not yet available on data."
70      #printprocesslog "INFO "$nightrun" not yet available on data."
71      if [ $night -le $checknight ] 
72      then 
73         printprocesslog "WARN "$nightrun" not yet available on data."
74      else
75         printprocesslog "INFO "$nightrun" not yet available on data."
76      fi
77      continue
78   else
79      filename=`basename $lpfile`
80   fi
81
82   setstatus "start" 
83
84   rawfilelp="/data2/zipraw/./"$nightpath"/"$filename
85   rawdirisdc="/scratch/from_lapalma/raw/"
86   rawfileisdc=$rawdirisdc$nightpath"/"$filename
87   ingestlinkpath="/scratch/ingest_links/raw/"$nightpath
88   makedir $ingestlinkpath >> $logfile 2>&1
89   ingestlink=$ingestlinkpath"/"$filename
90
91   if ! ssh fact@161.72.93.138 "ls $rawfilelp >/dev/null 2>&1"
92   then
93      #echo $rawfilelp" not yet available on data."
94      #printprocesslog "INFO "$rawfilelp" not yet available on data."
95      if [ $night -le $checknight ] 
96      then 
97         printprocesslog "WARN "$rawfilelp" not yet available on data."
98      else
99         printprocesslog "INFO "$rawfilelp" not yet available on data."
100      fi
101      check="no"
102      setstatus "stop"
103      continue
104   fi
105
106   # for new rsync
107   #   remove / from dir
108   #   change name of dir (else rsync-server doesn't accept it
109   #   test if trick with file/dir is working
110   #echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
111   printprocesslog "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
112   #echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
113   #rsync -rltDvR --partial --stats --password-file=$rsyncpwfile factdata@161.72.93.138::$rawfilelp $rawdirisdc >> $logfile 2>&1
114   #echo "rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.138:$rawfilelp $rawdirisdc >> $logfile 2>&1"
115   rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.138:$rawfilelp $rawdirisdc >> $logfile 2>&1
116   check1=$?
117
118   case $check1 in
119      0)   printprocesslog "INFO rawfile "$rawfilelp" transferred successfully to ISDC."
120           if ! [ -L $ingestlink ]
121           then 
122              printprocesslog "INFO create link for "$rawfileisdc
123              ln -sv $rawfileisdc $ingestlink >> $logfile 2>&1
124              check2=$?
125              case $check2 in
126                 0)   printprocesslog "INFO link for  "$rawfileisdc" created successfully."
127                      ;;
128                 *)   printprocesslog "WARN link for "$rawfileisdc" could not be created (check2="$check2")."
129                      check=$check2
130                      ;;
131              esac
132           else
133              printprocesslog "INFO link "$ingestlink" already existing."
134           fi
135           ;;
136      *)   printprocesslog "CONNECTION "$rawfilelp" could not be transferred to ISDC (check1="$check1")."
137           check=$check1
138           ;;
139   esac
140   
141   query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
142   numdrs=`sendquery`
143   if [ $numdrs -gt 0 ]
144   then 
145      drsfilelp="/data2/zipraw/./"$nightpath"/"$nightrun".drs.fits.gz"
146      drsfileisdc=$rawdirisdc$nightpath"/"$nightrun".drs.fits.gz"
147      drsingestlink=$ingestlinkpath"/"$nightrun".drs.fits.gz"
148
149      if ! ssh fact@161.72.93.138 "ls $drsfilelp >/dev/null 2>&1"
150      then
151         #echo $drsfilelp" not yet available on data."
152         printprocesslog "INFO "$drsfilelp" not yet available on data."
153         check="no"
154         setstatus "stop"
155         continue
156      fi
157
158
159      printprocesslog "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc
160      echo "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
161      #rsync -rltDvR --partial --stats --password-file=$rsyncpwfile factdata@161.72.93.138::$rawfilelp $rawdirisdc >> $logfile 2>&1
162      rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.138:$drsfilelp $rawdirisdc >> $logfile 2>&1
163      check3=$?
164
165      case $check3 in
166         0)   printprocesslog "INFO drsfile "$drsfilelp" transferred successfully to ISDC."
167              if ! [ -L $drsingestlink ]
168              then 
169                 printprocesslog "INFO create link for "$drsfileisdc
170                 ln -sv $drsfileisdc $drsingestlink >> $logfile 2>&1
171                 check4=$?
172                 case $check4 in
173                    0)   printprocesslog "INFO link for  "$drsfileisdc" created successfully."
174                         ;;
175                    *)   printprocesslog "WARN link for "$drsfileisdc" could not be created (check4="$check4")."
176                         check=$check4
177                         ;;
178                 esac
179              else
180                 printprocesslog "INFO link "$drsingestlink" already existing."
181              fi
182              ;;
183         *)   printprocesslog "CONNECTION "$drsfilelp" could not be transferred to ISDC (check3="$check3")."
184              check=$check3
185              ;;
186      esac
187   fi
188
189   setstatus "stop" 
190done
191
192finish
193
Note: See TracBrowser for help on using the repository browser.