2

Tip #468   Moved Trac and Subversion repositories to another machine/direct

CASE: You've relocated Subversion and Trac repositories to another machine/directories. You don't want to edit n+1 trac.ini files.

You have for example:
/repos/svn-myprojects/my-first-project
/repos/trac-myprojects/my-first-project

/repos/svn-myprojects/my-second-project
/repos/trac-myprojects/my-second-project

...etc...

Change ALL trac.ini repository_dir settings:

trac-mass-repodir-edit.sh:

#!/bin/bash TRACSPATH=$1 REPOPATH=$2 for i in $( find $TRACSPATH -maxdepth 1 -type d | grep -v "^$TRACSPATH\$" ); do BN=`basename $i` INIPATH=$i/conf/trac.ini TMP=$i/conf/trac.ini-temp # Replace repository_dir cat $INIPATH | perl -pe "s@repository_dir = .*@repository_dir = $REPOPATH/$BN@i" > $TMP mv $INIPATH $INIPATH-old && mv $TMP $INIPATH && rm $INIPATH-old done


Usage:
./trac-mass-repodir-edit.sh /repos/trac-myprojects /repos/svn-myprojects


Then you want to resync and upgrade all existing Tracs:

trac-mass-upgrade.sh:
#!/bin/bash

TRACSPATH=$1
REPOPATH=$2

for i in $( find $TRACSPATH -maxdepth 1 -type d | grep -v "^$TRACSPATH\$" ); do
  BN=`basename $i`
  # SVN directory exists
  if [ -d $REPOPATH/$BN ]; then
    echo "Processinc Trac: $BN.."
    trac-admin $i resync
    trac-admin $i upgrade
  fi
done


Usage:
./trac-mass-upgrade.sh /repos/trac-myprojects /repos/svn-myprojects


Now you have everything in order.