70

One of my teammates has asked if it is possible to export from one SVN to another, all while maintaining history.

To me, this seems like it would be a common request.

So: Is it possible to migrate between SVN repositories all while maintaining history?

It is important to note that we do not have svnadmin access on the Source, but we do have that on the Destination.

If this comes down to just checking out each revision from the source, and checking it in to the destination, we would be OK with that, as long as there was an automated process for that.

EDIT: I forgot to mention that the destination repo is on windows.

John Gietzen
  • 48,783
  • 32
  • 145
  • 190

5 Answers5

42

[Edit: The original reply below is from pre SVN 1.7, and there this was the best way to solve the problem (although it is not the primary use case of svnsync). In SVN 1.7 client or later there is the svnrdump tool that does more directly what you are trying to achieve)]


use svnsync to synchronize the source to the destination (needs admin access to the destination repository or at least a way to add hooks, but no special access to the source repository). If the destination already has revisions, sync the source to a temporary repository, and then use svn-merge-repos.pl to merge the two local repositories.

mihi
  • 6,507
  • 1
  • 38
  • 48
  • This looks pretty close to my requirements. – John Gietzen Jun 10 '09 at 17:04
  • Is it not possible to do a simple `svnsync TOURL FROMURL`? – John Gietzen Jun 11 '09 at 04:39
  • The command line options are different, see http://linux.die.net/man/1/svnsync. And you have to create a (maybe empty) pre-revprop-change hook (or pre-revprop-change.bat if you are on Windows) first. – mihi Jun 11 '09 at 18:33
  • @mihi response New svnsync documentation link is now http://svn.apache.org/repos/asf/subversion/trunk/notes/svnsync.txt – randomperson25 Oct 19 '10 at 16:29
  • 1
    the way I read the doc is that `svnsync` is for read-only mirroring. – MarkHu Mar 22 '13 at 01:19
  • hey, that question is *old*. Nowadays there is `svnrdump` so you won't need `svnsync` any more for that task... – mihi Mar 22 '13 at 17:36
  • Can I use it with dead svn repository, I have the checkout code in my backup.. but main repo is down now. Pls check http://stackoverflow.com/questions/25861512/create-new-svn-repository-from-checkout-code-from-dead-svn-repo – Krunal Sep 16 '14 at 05:54
  • From a checkout you will only be able to restore the version you have last checked out. No more history. If you have sufficiently many backups, you could use them to build a "new history" manually. And: please do not hijack unrelated questions... – mihi Sep 16 '14 at 11:38
  • Once I create my .dump file with full history using svnrdump command, how can I commit all this history into the new repository ? – AmineG Feb 11 '15 at 11:14
  • in case it is a local repository, `svnadmin load`, and in case it is a remote repository `svnrdump load`. Probably you want to run `svndumpfilter` in case you want to load it into a non-empty repository first, as you will get errors if files already exist in the other repo (or delete/rename them first and fix it up later after import) – mihi Feb 11 '15 at 18:01
9

I had a similar need (hence visited this page) and ended up writing my own program to do the work. Thought the tool may be useful to others who are still looking for a solution:

  • The tool needs no admin access to the source repository.
  • It supports add/delete/copy/move, preserves node property (e.g. svn:ignore, svn:external) and revision property (i.e., you get the correct author and date/time).
  • Can also incrementally copy new revisions.
  • Has both GUI and a command line utility.

If anybody is interested, check it out here

Montag451
  • 1,168
  • 3
  • 14
  • 30
Kenneth Xu
  • 1,514
  • 15
  • 15
9

The way to typically achieve this is the svnadmin dump command. If you don't have svnadmin access then I would ask the person that does if they can supply you with a dump. This will make the process of importing much easier as well.

Are you on a shared repository currently? This might make the person that owns the repository leary of giving you a dump, since it will be a copy of the entire repository, not just your piece of it.

Lee
  • 18,529
  • 6
  • 58
  • 60
  • Yeah, this would be a shared repository source. And that is why we can't get a dump. – John Gietzen Jun 10 '09 at 17:03
  • Perhaps you could convince the owner to provide you with a filtered dump, using svndumpfilter? See http://svnbook.red-bean.com/en/1.5/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svndumpfilter for more information. – markusk Jun 10 '09 at 17:08
  • looks like svnsync is almost the best way to go. – John Gietzen Jun 10 '09 at 17:21
8

You can use git-svn (or perhaps another SCM system) to accomplish this task.

The steps would be:

1. Get a git svn clone of each repository:
    git svn clone <SVN-REPOSITORY-FROM> source-repo
    git svn clone <SVN-REPOSITORY-TO> dest-repo

 2. Create patches to be imported:
    cd source-repo/
    export commitFrom=`git log --pretty=%H | tail -1`
    git format-patch -o /tmp/mergepatchs ${commitFrom}..HEAD .

 3. Import the patches
    cd dest-repo/
    git am /tmp/mergepatchs/*.patch

Referenced: http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/

scottysb
  • 89
  • 1
  • 1
  • 2
    worked imperfectly for me. I am now the author of all changes--and all dated today. Note that the "dest-repo" from the example above is now a GIT repo, and your SVN-REPOSITORY-TO is still in SVN. – MarkHu Mar 22 '13 at 02:26
  • Works great, but as mentioned you end up with a local git repository, so I had to run "git svn dcommit" in the dest-repo to commit it all to the destination SVN repository. – Johan Falk Dec 04 '17 at 10:55
0

If you need only a version control repo with full changeset, you can use bzr with bzr-svn plugin. When you checkout a svn repo, everything will be syncronized.

naan
  • 39
  • 4