HOWTO Upgrade a SVN repository

Sometimes you may need to upgrade or regenerate an SVN repository, because it may be outdated and/or damaged.

After some investigations, I discovered that it is possible by a simple batch file like the following one:

:@echo off
set svnadm="<path>\svnadmin.exe"
set repo_out= "<full pathname of the old repository>"
set repo_in="<full pathname of the new one>"
set file_dump="<path>\repo.dump"

%svnadm% dump %repo_out% > %file_dump%
%svnadm% load %repo_in% < %file_dump%

del %file_dump%

Essentially it exports all revisions data to a file, and it imports them into a newly created repository.

Before running this one you need to:

  1. create a new repository
  2. open a text editor and copy the batch file above.
  3. set svnadm with the full pathname of your svnadmin.exe.
  4. set repo_out with the starting repository’s full pathname.
  5. set repo_in with the new repository’s full pathname.
  6. set file_dump for a temporary dump file. Depending on your repository size, it may need several Gb of free disk space.
  7. save the file with something like: upgrade.cmd
  8. open a command prompt and start it.

When it ends, you will have an upgraded and fixed (and usually smaller) copy of your old repository.

PS: the batch file above is working fine on Windows machines.   For all other OSs, I suppose it maybe needs some adjustment.