1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # this script has been written to run on La Palma on the machine daq
|
---|
4 | # i.e. paths are only working on this machine
|
---|
5 |
|
---|
6 | source `dirname $0`/../Sourcefile.sh
|
---|
7 | printprocesslog "INFO starting "$0
|
---|
8 |
|
---|
9 | logfile=$runlogpath"/RsyncAuxLP-"$datetime".log"
|
---|
10 | date >> $logfile
|
---|
11 |
|
---|
12 | # check if /daq is mounted on data
|
---|
13 | if ! mount | grep data >> $logfile 2>&1
|
---|
14 | then
|
---|
15 | printprocesslog "ERROR /data is not mounted on daq => please mount it"
|
---|
16 | echo `date`": /data is not mounted on daq => please mount it"
|
---|
17 | finish
|
---|
18 | fi
|
---|
19 |
|
---|
20 | # check if paths are available
|
---|
21 | if ! ls /data/aux >/dev/null 2>&1
|
---|
22 | then
|
---|
23 | printprocesslog "ERROR /data/aux is not available."
|
---|
24 | finish
|
---|
25 | fi
|
---|
26 | if ! ls /loc_data/aux >/dev/null 2>&1
|
---|
27 | then
|
---|
28 | printprocesslog "ERROR /loc_data/aux is not available."
|
---|
29 | finish
|
---|
30 | fi
|
---|
31 |
|
---|
32 | # do the rsync for the last 6 days
|
---|
33 | dirs=( `ssh newdaq "find /loc_data/aux/ -mindepth 3 -type d | sort | tail -6"` )
|
---|
34 |
|
---|
35 | # do rsync for auxfiles in these directories
|
---|
36 | for dir in ${dirs[@]}
|
---|
37 | do
|
---|
38 | echo "" >> $logfile 2>&1
|
---|
39 | # directory on daq
|
---|
40 | if ! [ -d $dir ]
|
---|
41 | then
|
---|
42 | mkdir -pv $dir >> $logfile 2>&1
|
---|
43 | fi
|
---|
44 | # directory on data
|
---|
45 | dirdata=`echo $dir | sed -e 's/loc_//'`
|
---|
46 | if ! [ -d $dirdata ]
|
---|
47 | then
|
---|
48 | mkdir -pv $dirdata >> $logfile 2>&1
|
---|
49 | fi
|
---|
50 | printprocesslog "INFO processing files in "$dir >> $logfile 2>&1
|
---|
51 | echo `date`": processing files in "$dir >> $logfile 2>&1
|
---|
52 |
|
---|
53 | # get current hour
|
---|
54 | hour=`date +%k`
|
---|
55 | # define bwlimit for rsync depending on the time: from 19-7h reduced bwlimit for rsync
|
---|
56 | if [ $hour -le 6 ] || [ $hour -ge 19 ]
|
---|
57 | then
|
---|
58 | # limit bw for rsync to 20 MB/s during night
|
---|
59 | bwlimit="--bwlimit=20000"
|
---|
60 | printprocesslog "INFO rsync files with "$bwlimit >> $logfile 2>&1
|
---|
61 | echo "rsync files with "$bwlimit >> $logfile 2>&1
|
---|
62 | else
|
---|
63 | # no bw limit during day
|
---|
64 | printprocesslog "INFO rsync files without bwlimit" >> $logfile 2>&1
|
---|
65 | echo "rsync files without bwlimit" >> $logfile 2>&1
|
---|
66 | fi
|
---|
67 |
|
---|
68 | # rsync from newdaq to daq
|
---|
69 | if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit newdaq:$dir/ $dir >> $logfile 2>&1
|
---|
70 | then
|
---|
71 | printprocesslog "WARN problem rsyncing auxiliary files in "$dir" from newdaq to daq"
|
---|
72 | echo `date`": problem rsyncing auxiliary files in "$dir" from newdaq to daq"
|
---|
73 | fi
|
---|
74 |
|
---|
75 | #rsync from daq to data
|
---|
76 | if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit $dir/ $dirdata >> $logfile 2>&1
|
---|
77 | then
|
---|
78 | printprocesslog "WARN problem rsyncing auxiliary files in "$dir" from daq to data"
|
---|
79 | echo `date`": problem rsyncing auxiliary files in "$dir" from daq to data"
|
---|
80 | fi
|
---|
81 | done
|
---|
82 |
|
---|