/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/cvmfs/cvmfs-rsync-multi.sh
ViewVC logotype

Diff of /trunk/nl.nikhef.ndpf.tools/cvmfs/cvmfs-rsync-multi.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2757 by dennisvd, Tue Nov 18 08:23:31 2014 UTC revision 2758 by dennisvd, Fri Nov 28 14:25:22 2014 UTC
# Line 13  Line 13 
13  # users (or user groups), each with their own directory maintained  # users (or user groups), each with their own directory maintained
14  # independently of the others.  # independently of the others.
15    
16    logfile=
17    
18  die() {  die() {
19        err=${2:-1}
20        if [ -n "$logfile" ]; then
21            log "$1"
22        fi
23      echo -e "$1" >&2      echo -e "$1" >&2
24      exit 1      exit $2
25    }
26    
27    # prefix output with a timestamp
28    log() {
29        if [ -n "$logfile" ]; then
30            d=`LC_TIME=C date +'%b %d %H:%M:%S'`
31            echo $d "$@" >> "$logfile"
32        else
33            echo "$@"
34        fi
35  }  }
36    
37  # These parameters must be set on the command line  # These parameters must be set on the command line
# Line 34  excludeopts= Line 50  excludeopts=
50  rsyncdest=/cvmfs # the destination once a transaction started  rsyncdest=/cvmfs # the destination once a transaction started
51  rdonlylocation= # the compare-dest before transactions start  rdonlylocation= # the compare-dest before transactions start
52    
53  while getopts :r:s:d:S:R:i: OPT; do  while getopts :r:s:d:S:R:i:l: OPT; do
54      case $OPT in      case $OPT in
55          r|+r)          r|+r)
56              repo="$OPTARG"              repo="$OPTARG"
# Line 55  while getopts :r:s:d:S:R:i: OPT; do Line 71  while getopts :r:s:d:S:R:i: OPT; do
71              inclexclfile="$OPTARG"              inclexclfile="$OPTARG"
72              excludeopts="--exclude-from=$OPTARG"              excludeopts="--exclude-from=$OPTARG"
73              ;;              ;;
74            l|+l)
75                logfile="$OPTARG"
76          *)          *)
77              echo "usage: `basename $0` -r repository -s source [ -S secretsfile ] [ -i inclexclfile ]"              echo "usage: `basename $0` -r repository -s source [ -S secretsfile ] [ -i inclexclfile ]"
78              exit 2              exit 2
# Line 116  case $result in Line 134  case $result in
134      0)  ;;      0)  ;;
135      23) ;; # file missing, this is ok      23) ;; # file missing, this is ok
136      *) # other error      *) # other error
137          printf "%s\n" "$errstr"          log "$errstr"
138          echo "rsync failed. Aborting." >&2          die "rsync failed. Aborting." $result
         exit $result  
139          ;;          ;;
140  esac  esac
141    
# Line 130  esac Line 147  esac
147  find $tmp -name cvmfs.modified | sed 's,.*/\([^/]*\)/cvmfs\.modified$,\1,' | while read p  find $tmp -name cvmfs.modified | sed 's,.*/\([^/]*\)/cvmfs\.modified$,\1,' | while read p
148  do  do
149      # Start a transaction, do the rsync and if anything goes wrong abort.      # Start a transaction, do the rsync and if anything goes wrong abort.
150      echo "Update requested of $p; starting transaction of cvmfs repository $repo"      log "Update requested of $p; starting transaction of cvmfs repository $repo"
151      cvmfs_server transaction $repo || die "failed cvmfs transaction on $repo"      cvmfs_server transaction $repo || die "failed cvmfs transaction on $repo"
152            
153      rsync $rsyncopts --filter 'include /cvmfs.modified' \      rsync $rsyncopts --filter 'include /cvmfs.modified' \
# Line 140  do Line 157  do
157          -r -q -l -t --delete $rsyncsrc/$p/ "$rsyncdest/$repo/$p/"          -r -q -l -t --delete $rsyncsrc/$p/ "$rsyncdest/$repo/$p/"
158    
159      if [ $? -ne 0 ] ; then      if [ $? -ne 0 ] ; then
160          echo "Rsync from $rsyncsrc/$p failed, aborting transaction."          log "Rsync from $rsyncsrc/$p failed, aborting transaction."
161          cvmfs_server abort -f $repo || die "failed to abort the transaction, exiting"          cvmfs_server abort -f $repo || die "failed to abort the transaction, exiting"
162      else      else
163          # The rsync succeeded          # The rsync succeeded
164          cvmfs_server publish $repo || die "failed to publish the new CVMFS repo $repo, exiting"          cvmfs_server publish $repo || die "failed to publish the new CVMFS repo $repo, exiting"
165          echo "cvmfs publishing done for $repo, tree $p"          log "cvmfs publishing done for $repo, tree $p"
166      fi      fi
167  done  done
168    

Legend:
Removed from v.2757  
changed lines
  Added in v.2758

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28