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

Last change on this file since 17590 was 17574, checked in by Daniela Dorner, 11 years ago
added rsync of drs-file to avoid failing callistos
  • Property svn:executable set to *
File size: 5.1 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=RsyncRawToISDC
7step=RawFileRsyncedISDC
8pwfile=/home_nfs/isdc/fact_opr/rsync.pwd
9
10set -C
11
12logfile=$runlogpath"/RsyncRawToISDC-"$datetime".log"
13date >> $logfile 2>&1
14
15# check if script is already running
16lockfile=$lockpath/lock-$program.txt
17checklock
18
19# get todo list
20gettodo
21
22for (( s=0 ; s < $num ; s++ ))
23do
24 night=${primaries[$s+$s]}
25 runid=${primaries[$s+$s+1]}
26 nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
27 lppath="/loc_data/zipraw/"$nightpath
28 nightrun=$night"_"`printf %03d $runid`
29 lpfile=`ssh fact@161.72.93.131 "find $lppath -type f -regex '.*$nightrun[.]fits[.][fg]z'"`
30 if [ "$lpfile" == "" ]
31 then
32 #echo $nightrun" not yet available on data."
33 printprocesslog "INFO "$nightrun" not yet available on data."
34 continue
35 else
36 filename=`basename $lpfile`
37 fi
38
39 setstatus "start"
40
41 rawfilelp="/loc_data/zipraw/./"$nightpath"/"$filename
42 rawdirisdc="/scratch/from_lapalma/raw/"
43 rawfileisdc=$rawdirisdc$nightpath"/"$filename
44 ingestlinkpath="/scratch/ingest_links/raw/"$nightpath
45 makedir $ingestlinkpath >> $logfile 2>&1
46 ingestlink=$ingestlinkpath"/"$filename
47
48 if ! ssh fact@161.72.93.131 "ls $rawfilelp >/dev/null 2>&1"
49 then
50 #echo $rawfilelp" not yet available on data."
51 printprocesslog "INFO "$rawfilelp" not yet available on data."
52 check="no"
53 setstatus "stop"
54 continue
55 fi
56
57 # for new rsync
58 # remove / from dir
59 # change name of dir (else rsync-server doesn't accept it
60 # test if trick with file/dir is working
61 #echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
62 printprocesslog "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
63 #echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
64 #rsync -rltDvR --partial --stats --password-file=$pwfile factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
65 #echo "rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$rawfilelp $rawdirisdc >> $logfile 2>&1"
66 rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$rawfilelp $rawdirisdc >> $logfile 2>&1
67 check1=$?
68
69 case $check1 in
70 0) printprocesslog "INFO rawfile "$rawfilelp" transferred successfully to ISDC."
71 if ! [ -L $ingestlink ]
72 then
73 printprocesslog "INFO create link for "$rawfileisdc
74 ln -sv $rawfileisdc $ingestlink >> $logfile 2>&1
75 check2=$?
76 case $check2 in
77 0) printprocesslog "INFO link for "$rawfileisdc" created successfully."
78 ;;
79 *) printprocesslog "WARN link for "$rawfileisdc" could not be created (check2="$check2")."
80 check=$check2
81 ;;
82 esac
83 else
84 printprocesslog "INFO link "$ingestlink" already existing."
85 fi
86 ;;
87 *) printprocesslog "WARN "$rawfilelp" could not be transferred to ISDC (check1="$check1")."
88 check=$check1
89 ;;
90 esac
91
92 query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
93 numdrs=`sendquery`
94 if [ $numdrs -gt 0 ]
95 then
96 drsfilelp="/loc_data/zipraw/./"$nightpath"/"$nightrun".drs.fits.gz"
97 drsfileisdc=$rawdirisdc$nightpath"/"$nightrun".drs.fits.gz"
98 drsingestlink=$ingestlinkpath"/"$nightrun".drs.fits.gz"
99
100 if ! ssh fact@161.72.93.131 "ls $drsfilelp >/dev/null 2>&1"
101 then
102 #echo $drsfilelp" not yet available on data."
103 printprocesslog "INFO "$drsfilelp" not yet available on data."
104 check="no"
105 setstatus "stop"
106 continue
107 fi
108
109
110 printprocesslog "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc
111 echo "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
112 #rsync -rltDvR --partial --stats --password-file=$pwfile factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
113 rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$drsfilelp $rawdirisdc >> $logfile 2>&1
114 check3=$?
115
116 case $check3 in
117 0) printprocesslog "INFO drsfile "$drsfilelp" transferred successfully to ISDC."
118 if ! [ -L $drsingestlink ]
119 then
120 printprocesslog "INFO create link for "$drsfileisdc
121 ln -sv $drsfileisdc $drsingestlink >> $logfile 2>&1
122 check4=$?
123 case $check4 in
124 0) printprocesslog "INFO link for "$drsfileisdc" created successfully."
125 ;;
126 *) printprocesslog "WARN link for "$drsfileisdc" could not be created (check4="$check4")."
127 check=$check4
128 ;;
129 esac
130 else
131 printprocesslog "INFO link "$drsingestlink" already existing."
132 fi
133 ;;
134 *) printprocesslog "WARN "$drsfilelp" could not be transferred to ISDC (check3="$check3")."
135 check=$check3
136 ;;
137 esac
138 fi
139
140 setstatus "stop"
141done
142
143finish
144
Note: See TracBrowser for help on using the repository browser.