Menu

SVN Import

Importing an existing SVN repository

There are a number of different ways to import an existing SVN repository onto SourceForge, each with its own pros and cons. A few of these methods are outlined on this page.

It is best to start with a new repository. If necessary, you can remove and create a new svn repository via Admin -> Tools

Also, it's always a good idea to read through the entire instructions before starting to get the full picture, and to make sure to have backups.

Repository import tool

Pros: The simplest method
Cons: The repository needs to be accessible in svn format already, and is often the slowest import method

This is accomplished via Admin -> Tools, under where the svn repository is listed, select Import Repository and enter the full URL of where the repository is found online and it will start the import. You will receive an email when this is complete. Also note, we only allow importing over an empty repository (this is to prevent accidental data loss).

svnadmin load via the shell

Pros: Faster than the web based import tool
Cons: Due to the shell time limit, importing very large repositories may need to be broken into parts

For this example, we'll be using the following, for your own import, make the appropriate substitutions:

  • Project UNIX name: strawhat
  • Repository mount point: code
  • username: ctsai

Note: lines in blue are run locally, everything else is run in the Shell service

  1. Make a dump of the repository to import using svnadmin dump. If this is a very large repository, we recommend splitting up the dump into several pieces using the --incremental option (the number of revisions in each chunk will depend greatly on the size of each revision)
    $ svnadmin dump -r 0:3000 > svn_dump_1
    $ svnadmin dump -r 3001:HEAD > svn_dump_2
  2. Upload the dump file(s) to your project's home directory
    $ scp svn_dump_* ctsai@frs.sourceforge.net:/home/project-web/strawhat/
  3. Login to the shell service and use svnadmin to load each dump, shutting down and recreating the shell as necessary in between each dump section.
    $ ssh -t ctsai,strawhat@shell.sourceforge.net create
    [ctsai@shell-24005 ~]$ svnadmin load /home/svn/p/strawhat/code < /home/project-web/strawhat/svn_dump_1
    [ctsai@shell-24005 ~]$ timeleft
    Time remaining before shutdown: 83 minutes.
    [ctsai@shell-24005 ~]$ shutdown ; exit
    $ ssh -t ctsai,strawhat@shell.sourceforge.net create
    [ctsai@shell-24005 ~]$ svnadmin load /home/svn/p/strawhat/code < /home/project-web/strawhat/svn_dump_2
    Repeat as necessary
  4. Once finished, go to Admin -> Tools then under where the repo is listed, select "Refresh Repository" to scan in the repo contents into the Allura system.

svnrdump

Pros: Faster than the web based import tool. Does not require dump to be broken into parts
Cons: Slower than direct load. Can't resume in case of errors.

Note: lines in blue are run locally, lines starting with "[ctsai@shell-24005 ~]$" are run in the Shell service

Note 2: It is also highly recommended to set up SSH Keys to handle authentication for this.

  1. Use the shell service to access the repository hook scripts.
    $ ssh -t ctsai,strawhat@shell.sourceforge.net create
    [ctsai@shell-24005 ~]$ cd /home/svn/p/strawhat/code/hooks
  2. Create a "pre-revprop-change" hook and set it as executable. For just an import (and as long as it's removed afterwards), a simple one will work.
    [ctsai@shell-24005 ~]$ echo -e '#!/bin/sh\n\nexit 0' > pre-revprop-change
    [ctsai@shell-24005 ~]$ chmod a+x pre-revprop-change
  3. Rename the "post-commit" hook to temporarily disable it and exit the shell:
    [ctsai@shell-24005 ~]$ mv post-commit post-commit.bak
    [ctsai@shell-24005 ~]$ shutdown ; exit
  4. Locally, run the svnrdump to import:
    $ svnrdump load svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code < svn_dump
  5. Go back to the shell to reactivate the post-commit hook and remove the pre-revprop-change hook.
    $ ssh -t ctsai,strawhat@shell.sourceforge.net create
    [ctsai@shell-24005 ~]$ cd /home/svn/p/strawhat/code/hooks
    [ctsai@shell-24005 ~]$ mv post-commit.bak post-commit
    [ctsai@shell-24005 ~]$ rm pre-revprop-change
    [ctsai@shell-24005 ~]$ shutdown ; exit
  6. Once finished, go to Admin -> Tools then under where the repo is listed, select "Refresh Repository" to scan in the repo contents into the Allura system.

svnsync via local repository

Pros: Can be done remotely. With a little work, able to resume in case of errors.
Cons: Slower than direct load and svnrdump. Have to work from a svn repo instead of a repository dump

Note: It is also highly recommended to set up SSH Keys to handle authentication for this.

  1. Follow the same instructions as the svnrdump steps 1-3.
  2. Create a local repository and import into that first:
    $ svnadmin create svnrepo
    $ svnadmin load svnrepo/ < svn_dump
  3. Print UUID of imported repository, which will be needed in step 6.
    $ svnlook uuid svnrepo/
  4. Initialize and sync from the local repository:
    $ svnsync init svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code file:///path/to/local/svnrepo/
    $ svnsync sync svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code
  5. If the sync is interrupted for any reason, delete the sync lock (if necessary) and continue.
    $ svn propdel --revprop svn:sync-lock -r0 svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code
    $ svnsync sync svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code
  6. Go back to the shell to reactivate the post-commit hook, remove the pre-revprop-change hook, and set the UUID to match that of the imported repository.
    $ ssh -t ctsai,strawhat@shell.sourceforge.net create
    [ctsai@shell-24005 ~]$ svnadmin setuuid /home/svn/p/strawhat/code/ <UUID obtained in step 3>
    [ctsai@shell-24005 ~]$ cd /home/svn/p/strawhat/code/hooks
    [ctsai@shell-24005 ~]$ mv post-commit.bak post-commit
    [ctsai@shell-24005 ~]$ rm pre-revprop-change
    [ctsai@shell-24005 ~]$ shutdown ; exit
  7. Once finished, go to Admin -> Tools then under where the repo is listed, select "Refresh Repository" to scan in the repo contents into the Allura system.
  8. To prevent accidental future svnsyncs, remove the following revprops:
    $ svn propdel --revprop -r0 svn:sync-from-url svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code
    $ svn propdel --revprop -r0 svn:sync-from-uuid svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code
    $ svn propdel --revprop -r0 svn:sync-last-merged-rev svn+ssh://ctsai@svn.code.sf.net/p/strawhat/code