Created
December 30, 2011 16:35
-
-
Save mjangda/1540538 to your computer and use it in GitHub Desktop.
Sync files between two SVN folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script Name: Sync SVN folders | |
# Description: Use this script to sync changes from one SVN folder to another. A common use is syncing between prod and preprod repos. | |
# Tags: svn, sync | |
# Usage: ./sync-svn-folders.sh /path/to/from-repo /path/to/to-repo | |
FROM_REPO=$1 | |
TO_REPO=$2 | |
# Check that we don't have empty paths | |
if [ -z "$FROM_REPO" -o -z "$TO_REPO" ]; then | |
echo "usage: $0 /path/to/from-repo /path/to/to-repo" | |
exit | |
fi | |
# Validate paths are actual folders | |
if [ ! -d $FROM_REPO ]; then | |
echo "Invalid 'from' repo $FROM_REPO" | |
exit | |
fi | |
if [ ! -d $TO_REPO ]; then | |
echo "Invalid 'to' repo $TO_REPO" | |
exit | |
fi | |
# TODO validate paths are valid svn repos | |
echo "Syncing $FROM_REPO to $TO_REPO" | |
# rm all non-.svn files in "to" repo | |
echo "Remove files from 'to' repo" | |
find $TO_REPO -not -iwholename '*.svn*' -type f | xargs rm --force | |
# svn export from "from" repo to "to" repo | |
echo "Export files from 'from' repo to 'to' repo" | |
svn export $FROM_REPO $TO_REPO --force | |
# svn rm deleted files | |
echo "Remove deleted files" | |
svn status $TO_REPO | grep '^!' | awk '{print $2}' | xargs svn rm | |
# svn add new files | |
echo "Add new files" | |
svn status $TO_REPO | grep '^?' | awk '{print $2}' | xargs svn add | |
#done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment