| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 | # This script does a backup of the QLA results
|
|---|
| 4 | # It can be used in different location
|
|---|
| 5 | #
|
|---|
| 6 | # Be careful: do NOT use --delete as on daq callisto files are deleted
|
|---|
| 7 | #
|
|---|
| 8 |
|
|---|
| 9 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 10 | printprocesslog "INFO starting $0"
|
|---|
| 11 |
|
|---|
| 12 | set -C
|
|---|
| 13 |
|
|---|
| 14 | logfile=$runlogpath"/BackupQLA-"$datetime".log"
|
|---|
| 15 | date > $logfile
|
|---|
| 16 |
|
|---|
| 17 | if [ "$1" = "short" ]
|
|---|
| 18 | then
|
|---|
| 19 | dirs=( "/star" "/callisto" "/ganymed_run" )
|
|---|
| 20 | printprocesslog "INFO run only short version of rsyncs for the directories "${dirs[@]}
|
|---|
| 21 | echo "INFO run only short version of rsyncs for the directories "${dirs[@]} >> $logfile
|
|---|
| 22 | fi
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | # get paths depending on host
|
|---|
| 27 | case $HOSTNAME in
|
|---|
| 28 | daq) from=( "/loc_data/analysis" )
|
|---|
| 29 | to=( "/newdaq/analysis_bu" )
|
|---|
| 30 | ;;
|
|---|
| 31 | newdata) from=( "/data1/analysis" )
|
|---|
| 32 | to=( "newdaq:/loc_data/analysis_bu" )
|
|---|
| 33 | ;;
|
|---|
| 34 | isdc-dl00) from=( "fact@161.72.93.138:/data1/analysis" "/gpfs0/fact/processing/qla" )
|
|---|
| 35 | #to="/gpfs/scratch/fact/qla"
|
|---|
| 36 | to=( "/gpfs0/fact/processing/qla" "operator@coma.astro.uni-wuerzburg.de:/fact/data/qla")
|
|---|
| 37 | # for new rsync: update variables
|
|---|
| 38 | ;;
|
|---|
| 39 | *) echo "no valid host "$HOSTNAME
|
|---|
| 40 | exit
|
|---|
| 41 | ;;
|
|---|
| 42 | esac
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | for (( i=0 ; i < ${#from[@]} ; i++ ))
|
|---|
| 47 | do
|
|---|
| 48 | if [ ${#dirs[@]} -gt 0 ]
|
|---|
| 49 | then
|
|---|
| 50 | for dir in ${dirs[@]}
|
|---|
| 51 | do
|
|---|
| 52 | printprocesslog "INFO rsync "${from[$i]}$dir"/ to "${to[$i]}$dir
|
|---|
| 53 | echo "rsync from "${from[$i]}$dir"/ to "${to[$i]}$dir >> $logfile 2>&1
|
|---|
| 54 | if ! rsync -auv ${from[$i]}$dir"/" ${to[$i]}$dir >> $logfile 2>&1
|
|---|
| 55 | then
|
|---|
| 56 | printprocesslog "CONNECTION problem rsyncing QLA from "${from[$i]}$dir"/ to "${to[$i]}$dir
|
|---|
| 57 | echo `date`": problem rsyncing QLA from "${from[$i]}$dir"/ to "${to[$i]}$dir >> $logfile 2>&1
|
|---|
| 58 | fi
|
|---|
| 59 | done
|
|---|
| 60 | else
|
|---|
| 61 | printprocesslog "INFO rsync "${from[$i]}"/ to "${to[$i]}
|
|---|
| 62 | echo "rsync from "${from[$i]}"/ to "${to[$i]} >> $logfile 2>&1
|
|---|
| 63 | if ! rsync -auv ${from[$i]}"/" ${to[$i]} >> $logfile 2>&1
|
|---|
| 64 | then
|
|---|
| 65 | printprocesslog "CONNECTION problem rsyncing QLA from "${from[$i]}"/ to "${to[$i]}
|
|---|
| 66 | echo `date`": problem rsyncing QLA from "${from[$i]}"/ to "${to[$i]} >> $logfile 2>&1
|
|---|
| 67 | fi
|
|---|
| 68 | fi
|
|---|
| 69 | done
|
|---|
| 70 |
|
|---|
| 71 | finish >> $logfile 2>&1
|
|---|
| 72 |
|
|---|