Saturday, April 4, 2015

Reimporting SVN exports.

As a followup to my post regarding SVN exports, I now have an importer. This script re-imports whatever I had exported. You do need to set 3 variables:
SVN_TARGET_REPO, the target repository.
SVN_LOCAL_REPO, this is the new location of your files
SVN_BACKUP, this is the svn export directory


#!/bin/sh
SVN_TARGET_REPO="svn+ssh://LOGIN@SERVER/var/svn/nextretro"
SVN_LOCAL_REPO="/Users/degs/personal/projects.svn/nextretro.new"
SVN_BACKUP="/Users/degs/personal/projects.svn/nextretro/svnbackup"

#create the directory for the target, and checkout revision 0, if no .svn
if [[ ! -e $SVN_LOCAL_REPO/.svn ]]; then
 echo "creating SVN repo"
 mkdir -p $SVN_LOCAL_REPO
 svn co $SVN_TARGET_REPO $SVN_LOCAL_REPO/.
else
 echo "skipping export: $SVN_LOCAL_REPO/.svn" 
fi
#now reimport everything
cd $SVN_BACKUP
for f in $(ls -d * |sort -n); do
    if [[ -d $f ]]; then
     echo "importing rev: $f"
        rsync -r --exclude=.svn --exclude=commit.log $SVN_BACKUP/$f/* $SVN_LOCAL_REPO
        svn add $SVN_LOCAL_REPO/* --force
        COMMITLOG=`cat $SVN_BACKUP/$f/commit.log`
        svn commit $SVN_LOCAL_REPO -m "$COMMITLOG"
        
    fi
done

No comments:

Post a Comment