Previously I wrote about the Subversion Maintenance Scripts that I use for doing things like backups and upgrades. They were bash shell scripts that automated dealing with multiple Subversion repositories. The secret was that those guys were being run using Cygwin on Windows. Recently we got a new, more powerful server to run our Virtuals on. I decided to rewrite the scripts using native Windows Batch files so that I wouldn't have to install Cygwin again. Hopefully someone else will find this useful too.
Windows Batch Script for Creating a Default Repository StructureI work for a custom software development consulting firm so we have a lot of different clients. We don't want to mix different clients' code so we create a repository per client. We often get multiple projects per client though (yeah, they like us) so we go ahead and create a project under the client. We also like to use the trunk, tags and branches directories by default.
With all of these rules: Automate!
Some of the interesting pieces: %~dp0 gives you the directory that the current script lives in. %CUR_DIR:\=/% replaces the backslash (\) with forward slashes (/) so that the SVN file:// URL will work correctly.
Windows Batch Script to Dump Your Subversion RepositoriesThe next thing you might want to do is to dump all of your repositories so that you can back them up or upgrade SVN or move to a new server. With just one repository it's easy to do by hand. With 20+ repositories it's much nicer to run a script and then go do something else.
Some of the interesting pieces: FOR /f %%i IN ('dir /B /A:D %REPOS_DIR%\*') DO is the part that finds each directory (in this case an SVN repository). Then for each repository you run the svnadmin dump command and send the dump file to a different directory.
Windows Batch Script to Load Your Subversion RepositoriesAfter you've dumped all of your repositories and you need to restore them, because you've upgraded or moved them to a new server we need to do the reverse of the dump script.
Some of the interesting pieces: FOR in this case is the same as the dump, except it's looking for all the dump files. %%i holds the name of the dump file (e.g. repo.dump). %%~ni strips off the extension to give you just the name of the file (e.g. repo).
Now you can manage your repositories with ease if you're stuck on a Windows machine.