Skip to content

Instantly share code, notes, and snippets.

@gustavohenrique
Created November 14, 2011 17:53
Show Gist options
  • Save gustavohenrique/1364595 to your computer and use it in GitHub Desktop.
Save gustavohenrique/1364595 to your computer and use it in GitHub Desktop.
Copy svn folder to other repository
#!/bin/bash
SRC_REPO_BASE="/opt/ips/csvn/data/repositories"
SRC_REPO_DIR="ips_dashboard"
SRC_FOLDER_TO_COPY="trunk/ejbClient"
DST_REPOS_FILE="./projetos_bsad2.txt"
REPOS_DUMP="/tmp/repository.dump"
FILTER_DUMP="/tmp/filter.dump"
function copy() {
for dst in `cat $DST_REPOS_FILE`; do
svnadmin dump "$SRC_REPO_BASE/$SRC_REPO_DIR" > $REPOS_DUMP
svndumpfilter include $SRC_FOLDER_TO_COPY --drop-empty-revs --renumber-revs --preserve-revprops < $REPOS_DUMP > $FILTER_DUMP
svnadmin load "$SRC_REPO_BASE/$dst" < $FILTER_DUMP
done
}
function delete() {
for dst in `cat $DST_REPOS_FILE`; do
svnadmin dump "$SRC_REPO_BASE/$dst" > $REPOS_DUMP
svndumpfilter exclude $SRC_FOLDER_TO_COPY < $REPOS_DUMP > $FILTER_DUMP
rm -rf "$SRC_REPO_BASE/$dst"
svnadmin create "$SRC_REPO_BASE/$dst"
svnadmin load "$SRC_REPO_BASE/$dst" < $FILTER_DUMP
done
}
if [ ! -e $DST_REPOS_FILE ]; then
echo "Nao foi localizado o arquivo $DST_REPOS_FILE."
echo "Crie o arquivo contendo o nome do diretorio de cada projeto que vai ter uma copia de $SRC_FOLDER_TO_COPY"
exit 1
fi
case "$1" in
copy) copy; ;;
delete) delete; ;;
*) echo "Usage: $0 [copy|delete]"; ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment