Backing up and restoring your Subversion repository

Most tutorials around show how to backup your Subversion repository:

svnadmin dump /path/to/your/repository > ./repository.dump

And how to restore it:

mkdir /new/path/to/your/repository
svnadmin create /new/path/to/your/repository
svnadmin load /new/path/to/your/repository < ./repository.dump

But don’t tell you what to do to solve the problem that will arise when you try to restore it:

svnadmin: Dump stream contains a malformed header (with no ':') at '* Dumped revision 0.'

The solution is too simple; just run:

grep --binary-files=text -v '^* Dumped revision' ./repository.dump > ./repository.clear-dump

Now you should be able to restore your subversion repository with no problems:

svnadmin load /new/path/to/your/repository < ./repository.clear-dump

PS: I don’t use hotcopy because I prefer to have a single file for these backups.