1. Home
  2. Tutorials
Yolinux.com Tutorial

Subversion repository data transfer

Transferring a portion of a Subversion repository (directory branch and its contents) to a new repository.

Subversion repository migration:

Transferring directory branch of data from an existing SVN repository to a new repository under a new directory branch:

  1. Create hotcopy: (required for an active repository otherwise skip this step)
    svnadmin hotcopy /srv/svn/projX /srv/svn/projxHotCopy

  2. Dump repository:
    svnadmin dump /srv/svn/projxHotCopy -r 17257:HEAD > file1.dump
    (Dump revisions from version 17257 to current. Specify "0" to transfer entire history.)

  3. Filter the directory tree branches you want:
    cat file1.dump | svndumpfilter --renumber-revs
    --drop-empty-revs include trunk/dir1/dir2/dir3/dir4/dir5
    trunk/dir1/dir2/dir3/dir4a > file2.dump
    (Data is dumped with the full directory path from trunk to dir5 and dir4a)
    Note: The directive "--renumber-revs" will renumber history starting with "1". If you wish to match the revision history numbers with the old repository, do not use this directive.

  4. Create new repository: (on same or different server)
    svnadmin create --fs-type fsfs /srv/svn/projZ

  5. Allow import of directory structure through http access:
    chown apache:apache -R /srv/svn/projZ
    Else you get this error when you perform the next step:
    svn: Can't create directory '/srv/svn/projZ/db/transactions/0-1.txn': Permission denied

  6. Create shell directory structure for new target repository:
    mkdir -p trunk/dira/dirb
    (Note that this is one directory higher than the branch to load. We create the parent directory into which the directories go. Remove local directory after it is imported into Subversion.)

  7. Import directory structure:
    svn import -m "Enter directory structure" trunk http://svn2.super-megacorp.com/svn/projZ/trunk

    Note:
    • The local directory "trunk" and the target "trunk" both have to be mentioned. This avoids the error:
      svnadmin: File not found: transaction '0-1', path 'trunk/dira/dirb'
      when a load occurs to a directory branch which does not exist. The parent path must exist before a load.
    • If you create directories too deep into the directory tree, you may get the following error:
      svnadmin: File already exists: filesystem '/srv/svn/projZ/db', transaction '1-1', path 'trunk/dira/dirb/dir5'
      The creation of "dir5" is pressent in the dump file and thus Subversion tries to create a directory which already exists and will give you this error. See the log file for the directory it was trying to create.
    • The offending "already exists" error can also be fixed by removing the command to add the directory stated in the dump file. Remove the directory addition: (example dump file snippet)
      Node-path: trunk/dira/dirb/dirxxx
      Node-action: add
      Node-kind: dir
      Prop-content-length: 10
      Content-length: 10

      PROPS-END

  8. Allow local svnadmin command to work on local repository as root:
    chown root:root -R /srv/svn/projZ

  9. Edit directory paths in file2.dump :
    cat file2.dump | sed -e 's,^Node-path: trunk/dir1/dir2/dir3/dir4,Node-path: trunk/dira/dirb,' > file3.dump

    cat file3.dump | sed -e 's,^Node-path: trunk/dir1/dir2/dir3,Node-path: trunk/dira/dirb,' > file4.dump

    Note: The path for Subversion item "Node-copyfrom-path" may also have to be edited.

  10. Load filtered repository:
    svnadmin load /srv/svn/projZ < file4.dump > log.txt
    Note: The directive "--parent-dir /dir/path" can be specified. The default is "/".

  11. Change permissions for apache web server access:
    chown apache:apache -R /srv/svn/projZ

  12. Remove old directory branch from old repository:
    svn rm http://svn1.super-megacorp.com/svn/projX/trunk/dir1/dir2/dir3/dir4/dir5

    svn rm http://svn1.super-megacorp.com/svn/projX/trunk/dir1/dir2/dir3/dir4a

Old URL: http://svn1.super-megacorp.com/svn/projX/trunk/dir1/dir2/dir3/dir4/dir5/... and http://svn1.super-megacorp.com/svn/projX/trunk/dir1/dir2/dir3/dir4a/...

New URL: http://svn2.super-megacorp.com/svn/projZ/trunk/dira/dirb/dir5/... and http://svn2.super-megacorp.com/svn/projZ/trunk/dira/dirb/dir4a/...


[Potential Pitfall]: The data for repository content in the dump file can NOT be edited before loading into the repository as it will alter the md5sum for the data item. You will get an error upon loading.

[Potential Pitfall]: Some of these commands may take a long time to execute if the Subversion repository and dump files are very large. Your shell may timeout before the task is done. Solution: change the bash shell time out defaults:

export TMOUT=0

This will set the shell session to have no timeout duration.

export TMOUT=345600

This will set the timeout duration to four days (345600 seconds).

Links:

Book imageBooks:

Version Control with Subversion
by C. Michael Pilato
ISBN #0596004486, O'Reilly Press

Amazon.com
Practical Subversion (Expert's Voice in Open Source)
Garrett Rooney
ISBN #1590592905, Apress

Amazon.com
Subversion Version Control: Using the Subversion Version Control System in Development Projects
William Nagel
ISBN #0131855182, Prentice Hall PTR

Amazon.com

   
Bookmark and Share

Advertisements