Monday, March 16, 2015

Exporting SVN to a file hierarchy

Google code is shutting down, and I wanted not migrate the code to GIT on bitbucket because my scripts are all dependent on a version number and not a hash. Furthermore, I have found that GIT does not do well with binary.

The script will make a directory called svnbackup/REVISION so that I can easily import them later.

I pulled my nextretro project, and now I just have to decide where to put it.
#!/bin/bash
#this script exports any SVN repo to a possibly huge directory export
BACKUP_LOCATION='svnbackup'
#get the current repo
REMOTE_URL=$(svn info| grep -vi "Relative" | grep URL)
CURRENT_URL="${REMOTE_URL#*:}"
#get this repo version
REMOTE_VERSION=$(svn info | grep Revision)
CURRENT_VERSION="${REMOTE_VERSION#*:}" # strip out the version number
#create the directory
mkdir -p $BACKUP_LOCATION
svn info > $BACKUP_LOCATION/repo.info
echo "backing up current svn: $REMOTE_URL"
echo "current version: $CURRENT_VERSION"
COUNTER=1
while [  $COUNTER -ne $CURRENT_VERSION ]; do
     echo Exporting revision: $COUNTER
     mkdir -p $BACKUP_LOCATION/$COUNTER
     svn co -r$COUNTER $CURRENT_URL $BACKUP_LOCATION/$COUNTER/.
     svn log --revision $COUNTER > $BACKUP_LOCATION/$COUNTER/commit.log
     let COUNTER=COUNTER+1 
done

No comments:

Post a Comment