How to remove old SVN revisions

Wes picture Wes · Dec 3, 2010 · Viewed 12k times · Source

Our SVN repository is approaching 0.5 GB. We have nowhere near that amount of code in our production system.

Is it possible to remove old revisions. I tried svn dump with a beginning revision number, but to no avail. I couldn't import that into a clean SVN repository.

We don't need the history over a year old.

Any ideas?

Answer

Peter Parker picture Peter Parker · Dec 5, 2010

You can remove or better "shrink" the history of your SVN repository. Say you have 1000 revisions and you want to shrink to only have the revisions from r950-r1000. You can do the following:

svnadmin dump /path/to/current/repo -r950:1000 > small_svn.dump
svnadmin create /path/to/new/repo
svnadmin load /path/to/new/repo < small_svn.dump

However, there are two caveat to see:

1st: all your tags and branches will end up as standalone copies and so will take much more space than before (this could end in an even bigger repository, you have to try) - you can use svndumpfilter to remove tags and branches, however, than you need the old repository to get information of these tags/branches.

2nd: If your branches stay in your new repository, all mergeinfo will show wrong revisions as your new repository starts with revision 0 again and also all branches are gone in version history (due to pt. 1)

A much better solution:

  • Find the revision(s) which are responsible for the growth of your repository(search for large files in your repository datastorage usually located under: /path/to/repo/db/revs/[0...X]).
  • Check the log history of these revisions and locate the files which are responsible.
  • If you do not need these files, remove them via svndumpfilter.
  • Teach your user how to avoid committing unnecessary, large files.

Otherwise you will have to shrink your repository in several weeks again!