Saturday, May 9, 2009

Moving an entire SVN repository to a public server

Suppose you have an SVN repository on a workstation at home. And suppose your home workstation does not act as a server on the public internet. It may eventually come time to move the entire SVN repository from your home workstation to a server that is on the public internet. Here's how.

The Subversion Book chapter on moving and removing repositories says the following:

Subversion repository data is wholly contained within the repository directory. As such, you can move a Subversion repository to some other location on disk, rename a repository, copy a repository, or delete a repository altogether using the tools provided by your operating system for manipulating directories—mv, cp -a, and rm -r on Unix platforms ...

You might at first think this means that UNIX scp will be enough to move an entire SVN repository from your home workstation to a server on the public internet. But this is not the case.

Enter svnadmin dump and svnadmin load.

On your home workstation, change to you svn directory and find the repository that you want to move. Make sure you find the repository and not merely a working copy of the repository:

$ cd /var/svn

Redirect the stdout from svnadmin dump to create a dumpfile:

$ svnadmin dump my_repository > my_repository_dumpfile

Copy the dumpfile to the remote server:

$ scp my_repository_dumpfile tbaca@128.129.130.22:/home/tbaca/svn

Log in to the remote server:

$ ssh -l tbaca 128.129.130.22

Switch to the appropriate directory on the remote server:

$ cd /home/tbaca/svn

Create the new repository, if it does not yet already exist:

$ svnadmin create my_repository

Load the dumpfile into the new repository, directing from stdin:

$ svnadmin load my_repository < my_repository_dumpfile

Done.

No comments: