Tuesday, June 30, 2009

Move a project from an SVN repository to another one

Today, I need to move a project from a first subversion repository to a second one. To do that, you need to have an access to your SVN server.

So, we will use the following commands :
  • svnadmin dump to backup the repositories (I insist on 'repositories'. I think it's important to have backups of all repos before doing such operations)
  • svndumpfilter to reduce the backup scope to a single project because the dump can only be done on the entire SVN repository
  • svnadmin load (I think you can guess what this wonderful command does)
To understand this commands, it's important to know that svnadmin uses standard inputs and outputs. Thus, we can combine commands with pipes.


Let's save our project (with all its history, tags, branches...)

svnadmin dump /home/subversion/svn/repo/ | svndumpfilter include myproject > svn.myproject.dump

Now, let's backup our target repository :

svnadmin dump /home/subversion/svn/new_repo/ > svn.new_repo.dump

And let's import the project on this target repository :

cat svn.myproject.dump | svnadmin load /home/subversion/svn/new_repo/

Important note : when you use svndumpfilter, the keyword you give to the filter is only a prefix. That's very important because if you have similar project names, you must excluse the ones you don't want like that :

cat svn.myproject.dump | svndumpfilter exclude myproject2 > svn.myprojectonly.dump

Wow, that's all!

1 comment:

Rahul said...

Thanks for the great information in your blog Selenium Training in Chennai