Skip to main content

Create a new SVN repository

#!/bin/bash

#echo "arguments:"$#

POSITIONAL=()
if [[ $# -gt 0 ]]
    then
    while [[ $# -gt 0 ]]
    do
    key="$1"
    case $key in
        -n|--name)
        SVNNAME="$2"
        shift # past argument
        shift # past value
        ;;
        -p|--svnpath)
        SVNPATH="$2"
        shift # past argument
        shift # past value
        ;;
        *)    # unknown option
        POSITIONAL+=("$1") # save it in an array for later
        shift # past argument
        ;;
    esac
    done
    set -- "${POSITIONAL[@]}" # restore positional parameters
   
    if [ "${SVNPATH}" == "" ]; then
        SVNPATH="svn"
    fi
   
    MAINSVNPATH="/srv/repos/"
    SVNPATH="${MAINSVNPATH}${SVNPATH}"
    echo FILE SVNNAME  = "${SVNNAME}"
    echo SEARCH PATH     = "${SVNPATH}"
   
    if [ ! -d "$SVNPATH" ]; then
      # Control will enter here if $DIRECTORY doesn't exist.
      mkdir -p "$SVNPATH"
    fi
   
   
    svnadmin create "${SVNPATH}/${SVNNAME}"
    chown -R www-data:www-data "${SVNPATH}/${SVNNAME}"
    chmod -R g+w "${SVNPATH}/${SVNNAME}"
    chmod -R g+s "${SVNPATH}/${SVNNAME}"

else
    echo 'usage: ./test.sh -n svnName -p sysOps -d "SVN Description" '
fi

To top

automatically add to SVN all the new file in a folder

to add to SVN all the new file in /etc:

svn add `svn status /etc|grep \?|awk '{print $2}'`


To top

recursively removing .svn folders

#!/bin/sh 
echo "recursively removing .svn folders from" 
pwd 
rm -rf `find . -type d -name .svn`

To top

Change svn repository on all .svn/entries

grep  -l -R -i oldServer .svn *
spedition/config/sql/.svn/entries
spedition/config/.svn/entries
spedition/tests/fixtures/.svn/entries
spedition/tests/groups/.svn/entries
spedition/tests/cases/behaviors/.svn/entries
spedition/tests/cases/controllers/.svn/entries
spedition/tests/cases/helpers/.svn/entries
spedition/tests/cases/models/.svn/entries
spedition/tests/cases/components/.svn/entries
spedition/tests/cases/.svn/entries
spedition/tests/.svn/entries
spedition/controllers/components/.svn/entries
spedition/controllers/.svn/entries
spedition/views/causals/.svn/entries
spedition/views/packaging_types/.svn/entries
spedition/views/items/.svn/entries
spedition/views/pages/.svn/entries

sed -i.bak 's/oldServer/newServer/g' `grep  -l -R -i oldServer .svn *`

 

To top

SVN Repository migration

In the old SVN server

cd /opt/projects/svn/
root@ITB-S0032:/opt/projects/svn# ll
total 1
drwxrwsr-x 19 root  www-data 1 2010-11-16 18:41 .
drwxrwsr-x  5 root  www-data 1 2011-03-07 15:09 ..
drwxrwsr-x  7 root  www-data 1 2009-04-29 17:10 amico2008
drwxrwsr-x  7 root  www-data 1 2009-02-27 15:26 calibrazione
drwxrwsr-x  7 root  www-data 1 2009-03-03 11:07 db_prod
drwxrwsr-x  7 root  www-data 1 2009-08-22 18:50 iphone
drwxrwsr-x  7 root  www-data 1 2009-03-29 19:48 ocaGame
drwxrwsr-x  7 root  www-data 1 2009-04-10 19:18 oldDbProd
drwxrwsr-x  7 root  www-data 1 2010-11-16 18:41 paroliamo
drwxrwsr-x  7 root  www-data 1 2009-02-27 13:52 PatchPanels
drwxrwsr-x  7 root  www-data 1 2010-11-03 16:57 presences
drwxrwsr-x  7 root  www-data 1 2010-01-19 09:14 Production2010
drwxrwsr-x  7 root  www-data 1 2009-02-23 09:06 sandbox
drwxrwsr-x  7 root  www-data 1 2009-04-01 08:42 SapRfc
drwxrwsr-x  7 root  www-data 1 2010-07-27 09:02 spedition
 

for svnName in `ls -1`; do svnadmin dump ${svnName} >/media/svnDump/${svnName}.dump ; done;

in the new SVN server:

for svnName in `ls -1 /media/svnDump/`; do svnadmin create /srv/www/svn/svnrepos/`basename ${svnName} .dump`; svnadmin load /srv/www/svn/svnrepos/`basename ${svnName} .dump` < /media/svnDump/${svnName}; done;

To top