1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # this script has been written to run on La Palma on the machine data
|
---|
4 | # i.e. paths are only working on this machine
|
---|
5 |
|
---|
6 | echo `dirname $0`" is not to be used anymore."
|
---|
7 | exit
|
---|
8 |
|
---|
9 | source `dirname $0`/../Sourcefile.sh
|
---|
10 | printprocesslog "INFO starting "$0
|
---|
11 |
|
---|
12 | logfile=$runlogpath"/RsyncRawLP-"$datetime".log"
|
---|
13 | date >> $logfile
|
---|
14 |
|
---|
15 | # check if /daq is mounted on data
|
---|
16 | if ! mount | grep daq >> $logfile 2>&1
|
---|
17 | then
|
---|
18 | printprocesslog "ERROR /daq is not mounted on data => please mount it"
|
---|
19 | echo `date`": /daq is not mounted on data => please mount it"
|
---|
20 | finish
|
---|
21 | fi
|
---|
22 |
|
---|
23 | # check if paths are available
|
---|
24 | if ! ls /daq/raw >/dev/null 2>&1
|
---|
25 | then
|
---|
26 | printprocesslog "ERROR /daq/raw is not available."
|
---|
27 | finish
|
---|
28 | fi
|
---|
29 | if ! ls /loc_data/raw >/dev/null 2>&1
|
---|
30 | then
|
---|
31 | printprocesslog "ERROR /loc_data/raw is not available."
|
---|
32 | finish
|
---|
33 | fi
|
---|
34 |
|
---|
35 | # get last 3, 6 or 9 nights
|
---|
36 | #dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
|
---|
37 | # `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
|
---|
38 | # `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
|
---|
39 | # )
|
---|
40 |
|
---|
41 | dates=(
|
---|
42 | `date +%Y/%m/%d --date="-204hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-156hour"` \
|
---|
43 | `date +%Y/%m/%d --date="-132hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-84hour"` \
|
---|
44 | `date +%Y/%m/%d --date="-60hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-12hour"` \
|
---|
45 | )
|
---|
46 |
|
---|
47 | # do rsync for rawfiles of these dates
|
---|
48 | for date in ${dates[@]}
|
---|
49 | do
|
---|
50 | echo "" >> $logfile 2>&1
|
---|
51 | # raw data directories on data
|
---|
52 | rawdirdaq=/daq/raw/$date/ # /loc_data from daq via nfs on data
|
---|
53 | rawdirdata=/loc_data/raw/$date
|
---|
54 | if ! [ -d $rawdirdaq ]
|
---|
55 | then
|
---|
56 | echo `date`": "$rawdirdaq" not found. No data available on daq." >> $logfile 2>&1
|
---|
57 | if [ -d $rawdirdata ]
|
---|
58 | then
|
---|
59 | printprocesslog "WARN "$rawdirdaq" not found, but "$rawdirdata". Data probably taken on data." >> $logfile 2>&1
|
---|
60 | else
|
---|
61 | printprocesslog "INFO "$rawdirdaq" not found. No data available on daq." >> $logfile 2>&1
|
---|
62 | fi
|
---|
63 | continue
|
---|
64 | fi
|
---|
65 | if ! [ -d $rawdirdata ]
|
---|
66 | then
|
---|
67 | mkdir -pv $rawdirdata >> $logfile 2>&1
|
---|
68 | fi
|
---|
69 | printprocesslog "INFO processing files in "$rawdirdaq >> $logfile 2>&1
|
---|
70 | echo `date`": processing files in "$rawdirdaq >> $logfile 2>&1
|
---|
71 |
|
---|
72 | # get current hour
|
---|
73 | hour=`date +%k`
|
---|
74 | # define bwlimit for rsync depending on the time: from 19-7h reduced bwlimit for rsync
|
---|
75 | if [ $hour -le 6 ] || [ $hour -ge 19 ]
|
---|
76 | then
|
---|
77 | # limit bw for rsync to 20 MB/s during night
|
---|
78 | bwlimit="--bwlimit=20000"
|
---|
79 | printprocesslog "INFO rsync data with "$bwlimit >> $logfile 2>&1
|
---|
80 | echo "rsync data with "$bwlimit >> $logfile 2>&1
|
---|
81 | else
|
---|
82 | # no bw limit during day
|
---|
83 | bwlimit=""
|
---|
84 | printprocesslog "INFO rsync data without bwlimit" >> $logfile 2>&1
|
---|
85 | echo "rsync data without bwlimit" >> $logfile 2>&1
|
---|
86 | fi
|
---|
87 |
|
---|
88 | #rsync from daq to data
|
---|
89 | #if ! /usr/bin/rsync -avxHPu $bwlimit $rawdirdaq $rawdirdata >> $logfile 2>&1 # in case of adding checksum, only update files with rsync
|
---|
90 | if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit $rawdirdaq $rawdirdata >> $logfile 2>&1
|
---|
91 | then
|
---|
92 | printprocesslog "WARN problem rsyncing rawdata for "$date" from daq to data"
|
---|
93 | echo `date`": problem rsyncing rawdata for "$date" from daq to data"
|
---|
94 | fi
|
---|
95 | done
|
---|
96 |
|
---|
97 | finish
|
---|
98 |
|
---|