Related YoLinux Tutorials:
°Subersion server and Trac Server Installation and Configuration
°Subversion commands and scripts
°Cabie Automated Builds and Subversion
°Subversion vs Clearcase
°YoLinux Tutorials Index
Free Information Technology Software and Development Magazine Subscriptions and Document Downloads
|Subversion repository migration:
Transferring directory branch of data from an existing SVN repository to a new repository under a new directory branch:
- Create hotcopy: (required for an active repository otherwise skip this step)
svnadmin hotcopy /srv/svn/projX /srv/svn/projxHotCopy
- 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.)
- 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.
- Create new repository: (on same or different server)
svnadmin create --fs-type fsfs /srv/svn/projZ
- 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
- 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.)
- Import directory structure:
svn import -m "Enter directory structure" trunk http://svn2.super-megacorp.com/svn/projZ/trunk
- 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)
- Allow local svnadmin command to work on local repository as root:
chown root:root -R /srv/svn/projZ
- 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.
- 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 "/".
- Change permissions for apache web server access:
chown apache:apache -R /srv/svn/projZ
- 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/...
New URL: http://svn2.super-megacorp.com/svn/projZ/trunk/dira/dirb/dir5/...
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.
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:
This will set the shell session to have no timeout duration.
This will set the timeout duration to four days (345600 seconds).