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?
This question is related to
svn
You can also use the svnadmin hotcopy
command:
svnadmin hotcopy OLD_REPOS_PATH NEW_REPOS_PATH
It takes a full backup from repository, including all hooks, configuration files, etc.
You might find some help on migrating SVN repositories in Chapter 5. Repository Administration, Migrating a repository.
This approach requires access to svnadmin.
I found an article about how to move svn repositories from a hosting service to another, and how to do local backups:
Define where you will store your repositories:
mkdir ~/repo
MYREPO=/home/me/someplace ## you should use full path here
svnadmin create $MYREPO
Create a hook file and make it executable:
echo '#!/bin/sh' > $MYREPO/hooks/pre-revprop-change
chmod +x $MYREPO/hooks/pre-revprop-change
Now we can start importing the repository with svnsync
, that will initialize a destination repository for synchronization from another repository:
svnsync init file://$MYREPO http://your.svn.repo.here/
And the finishing touch to transfer all pending revisions to the destination from the source with which it was initialized:
svnsync sync file://$MYREPO
There now you have a local svn repository in the ~/repo
directory.
Source:
Basically, there are plenty of ways to accomplish the task. The topic is covered in depth in SVNBook | Migrating Repository Data Elsewhere, so I suggest reading the book's section.
Here is a brief description of your options:
It depends on your environment, but there is a great chance that you can simply copy the repository to the new server and it will work. You have to revise repository hook scripts after copying the repo to ensure that they are working as you expect.
You can use svnadmin dump
and svnadmin load
commands to, ehm, generate full dump and then load it to another repository on another server. You will need to svnadmin create
a new clean repository to load the dump into it. Keep in mind that the approach deals with repository history only and does not move hook scripts and repository configuration files! As well, you must have read filesystem access to the original repository to dump it.
Since Subversion 1.7, svnrdump
tool is available. Generally speaking, it mimics svnadmin dump
and svnadmin load
functionality, but operates remotely. You are not required to have read / write filesystem access to original and target repositories as tool operates remotely like Subversion client, e.g. over HTTPS protocol. So you need to have read access to original repository and read / write to the target one.
Another option is to use svnadmin hotcopy
command. The command is mostly used for backup purpose, it creates full copy of the repository including configuration and hook scripts. You can move hotcopied repository to another server then.
If you do not have file access to the repository, I prefer rsvndump (remote Subversion repository dump) to make the dump file.
The tool to do that would be
svnadmin dump
But for this to work, you need filesystem-access to the repository. And once you have that (and provided the repository is in FSFS format), you can just copy the repository to its new location (if it's in BDB format, dump/load is strongly recommended).
If you do not have filesystem access, you would have to ask your repository provider to provide the dump for you (and make them delete their repository - and hope they comply)
rsvndump
worked great for me migrating a repository from svnrepository.com to an Ubuntu server that I control.
Install missing dependencies ("APR" and Subversion libraries)
sudo apt-get install apache2-threaded-dev
sudo apt-get install libsvn-dev
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
Dump the remote SVN repository to a local file
rsvndump http://my.svnrepository.com/svn/old_repo > old_repo_dump
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
You can also use svnsync. This only requires read-only access on the source repository
Excerpt from my Blog-Note-to-myself:
Now you can import a dump file e.g. if you are migrating between machines / subversion versions. e.g. if I had created a dump file from the source repository and load it into the new repository as shown below.
Commands for Unix-like systems (from terminal):
svnadmin dump /path/to/your/old/repo > backup.dump
svnadmin load /path/to/your/new/repo < backup.dump.dmp
Commands for Microsoft Windows systems (from cmd shell):
svnadmin dump C:\path\to\your\old\repo > backup.dump
svnadmin load C:\path\to\your\old\repo < backup.dump
Source: Stackoverflow.com