Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I export (and then import) a Subversion repository?

Tags:

svn

I'm just about wrapped up on a project where I was using a commercial SVN provider to store the source code. The web host the customer ultimately picked includes a repository as part of the hosting package, so, now that the project is over, I'd like to relocate the repository to their web host and discontinue the commercial account.

How would I go about doing this?

like image 778
Brian Warshaw Avatar asked Sep 08 '08 10:09

Brian Warshaw


People also ask

How do I export and import svn repository?

In the main menu, select VCS | Browse VCS Repository | Browse Subversion Repository to open the SVN Repositories tool window. Right-click a directory you want to export and choose Export from the context menu. In the Select Path dialog that opens, specify the destination directory and click OK.

How do I export a project from svn repository?

To import a project into the repository, right click the project you want to import and select Team > Share Project... from the context menu. This will begin the Share Project wizard. Select SVN as the repository type and click Next.

How does svn export work?

svn export simply extracts all the files from a revision and does not allow revision control on it. It also does not litter each directory with . svn directories. svn checkout allows you to use version control in the directory made, e.g. your standard commands such as svn update and svn commit .


2 Answers

If you want to move the repository and keep history, you'll probably need filesystem access on both hosts. The simplest solution, if your backend is FSFS (the default on recent versions), is to make a filesystem copy of the entire repository folder.

If you have a Berkley DB backend, if you're not sure of what your backend is, or if you're changing SVN version numbers, you're going to want to use svnadmin to dump your old repository and load it into your new repository. Using svnadmin dump will give you a single file backup that you can copy to the new system. Then you can create the new (empty) repository and use svnadmin load, which will essentially replay all the commits along with its metadata (author, timestamp, etc).

You can read more about the dump/load process here:

http://svnbook.red-bean.com/en/1.8/svn.reposadmin.maint.html#svn.reposadmin.maint.migrate

Also, if you do svnadmin load, make sure you use the --force-uuid option, or otherwise people are going to have problems switching to the new repository. Subversion uses a UUID to identify the repository internally, and it won't let you switch a working copy to a different repository.

If you don't have filesystem access, there may be other third party options out there (or you can write something) to help you migrate: essentially you'd have to use the svn log to replay each revision on the new repository, and then fix up the metadata afterwards. You'll need the pre-revprop-change and post-revprop-change hook scripts in place to do this, which sort of assumes filesystem access, so YMMV. Or, if you don't want to keep the history, you can use your working copy to import into the new repository. But hopefully this isn't the case.

like image 151
Tadmas Avatar answered Sep 22 '22 08:09

Tadmas


rsvndump worked great for me migrating a repository from svnrepository.com to an Ubuntu server that I control.

How to install and use rsvndump on Ubuntu:

  1. Install missing dependencies ("APR" and Subversion libraries)

    sudo apt-get install apache2-threaded-dev sudo apt-get install libsvn-dev 
  2. Install rsvndump

    wget http://prdownloads.sourceforge.net/rsvndump/rsvndump-0.5.5.tar.gz tar xvfz rsvndump-0.5.5.tar.gz cd rsvndump-0.5.5 ./configure make sudo make install 
  3. Dump the remote SVN repository to a local file

    rsvndump http://my.svnrepository.com/svn/old_repo > old_repo_dump 
  4. Create a new repository and load in the local dump file

    sudo svnadmin create /opt/subversion/my_new_rep sudo svnadmin load --force-uuid /opt/subversion/my_new_repo < old_repo_dump 
like image 21
tkdave Avatar answered Sep 23 '22 08:09

tkdave