mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

svnsync-myrepos (833B)


      1 #!/bin/bash
      2 
      3 # synchronizes a local backup of all my svn repositories
      4 # $1 is the destination of the backup
      5 # ASSUMPTION: all the svn repositories live in ~/svn/*
      6 
      7 set -e
      8 
      9 DEST=$(realpath "$1")
     10 BLACKLIST="$HOME/config/private/svnrepos_excluded"
     11 touch "$BLACKLIST"
     12 
     13 ls ~/svn | while read repos
     14 do
     15   # exclude repositories in $BLACKLIST
     16   if ! grep "^$repos\$" "$BLACKLIST" > /dev/null
     17   then
     18     cd "$HOME/svn/$repos"
     19     URL=$(svn info | grep '^URL:' | cut -d' ' -f2)
     20     cd "$DEST"
     21     LDEST="file://$DEST/$repos"
     22     if [ ! -d "$DEST/$repos" ]
     23     then
     24       # https://stackoverflow.com/a/2303862
     25       svnadmin create "$repos"
     26       echo -ne '#!/bin/sh\nexit 0' > "$repos/hooks/pre-revprop-change"
     27       chmod ugo+x "./$repos/hooks/pre-revprop-change"
     28       svnsync init "$LDEST" "$URL"
     29     fi
     30     svnsync sync "$LDEST"
     31   fi
     32 done