source: trunk/DataCheck/Transfer/RsyncAuxLP.sh@ 18863

Last change on this file since 18863 was 18854, checked in by Daniela Dorner, 8 years ago
updated to run on newdata and create a second copy
  • Property svn:executable set to *
File size: 3.3 KB
Line 
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
6source `dirname $0`/../Sourcefile.sh
7printprocesslog "INFO starting "$0
8
9logfile=$runlogpath"/RsyncAuxLP-"$datetime".log"
10date >> $logfile
11
12# check if /daq is mounted on data
13if ! mount | grep data >> $logfile 2>&1
14then
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
18fi
19
20# check if paths are available
21paths="/newdaq/aux /data1/aux /data2/aux /scratch/aux"
22for path in ${paths[@]}
23do
24 if ! ls $path >/dev/null 2>&1
25 then
26 printprocesslog "ERROR "$path" is not available."
27 finish
28 fi
29done
30
31# first get some settings
32# get current hour
33hour=`date +%k`
34# define bwlimit for rsync depending on the time: from 19-7h reduced bwlimit for rsync
35if [ $hour -le 6 ] || [ $hour -ge 19 ]
36then
37 # limit bw for rsync to 20 MB/s during night
38 bwlimit="--bwlimit=20000"
39 bwlimit="--bwlimit=5000"
40 printprocesslog "INFO rsync files with "$bwlimit
41 echo "rsync files with "$bwlimit >> $logfile 2>&1
42 searchwindow="-cmin -840"
43 printprocesslog "INFO treat the last 14 hours."
44 echo "INFO treat the last 14 hours." >> $logfile 2>&1
45else
46 # no bw limit during day
47 bwlimit=""
48 printprocesslog "INFO rsync files without bwlimit"
49 echo "rsync files without bwlimit" >> $logfile 2>&1
50 searchwindow="-ctime -6"
51 printprocesslog "INFO treat the last 14 hours."
52 echo "INFO treat the last 14 hours." >> $logfile 2>&1
53fi
54
55# find directories to be rsynced
56dirs=( `ssh newdaq "find /loc_data/aux/ -mindepth 3 $searchwindow -type d | sort "` )
57
58# do rsync for auxfiles in these directories
59for dir in ${dirs[@]}
60do
61 echo "" >> $logfile 2>&1
62 printprocesslog "INFO processing files in "$dir
63 echo `date`": processing files in "$dir >> $logfile 2>&1
64 #echo `date`": processing files in "$dir
65
66 # first take care of SSD /scratch
67 scratch=`echo $dir | sed -e 's/loc_data/scratch/'`
68 if ! [ -d $scratch ]
69 then
70 mkdir -pv $scratch >> $logfile 2>&1
71 fi
72 # rsync from newdaq to newdata
73 if ! /usr/bin/rsync -avu -T $rsynctempdir $bwlimit newdaq:$dir/ $scratch >> $logfile 2>&1
74 then
75 printprocesslog "CONNECTION problem rsyncing auxiliary files in "$dir" from newdaq to newdata"
76 echo `date`": problem rsyncing auxiliary files in "$dir" from newdaq to newdata" >> $logfile 2>&1
77 fi
78
79 # now make copies on newdata
80 data1=`echo $dir | sed -e 's/loc_data/data1/'`
81 if ! [ -d $data1 ]
82 then
83 mkdir -pv $data1 >> $logfile 2>&1
84 fi
85 data2=`echo $dir | sed -e 's/loc_data/data2/'`
86 if ! [ -d $data2 ]
87 then
88 mkdir -pv $data2 >> $logfile 2>&1
89 fi
90 # distribute to several disk on newdata
91 if ! /usr/bin/rsync -avu -T $rsynctempdir $bwlimit $scratch/ $data1 >> $logfile 2>&1
92 then
93 printprocesslog "WARN problem rsyncing auxiliary files in "$dir" from scratch to data1"
94 echo `date`": problem rsyncing auxiliary files in "$dir" from scratch to data1" >> $logfile 2>&1
95 fi
96 if ! /usr/bin/rsync -avu -T $rsynctempdir $bwlimit $scratch/ $data2 >> $logfile 2>&1
97 then
98 printprocesslog "WARN problem rsyncing auxiliary files in "$dir" from scratch to data2"
99 echo `date`": problem rsyncing auxiliary files in "$dir" from scratch to data2" >> $logfile 2>&1
100 fi
101done
102
103finish
Note: See TracBrowser for help on using the repository browser.