{"id":86,"date":"2012-04-30T10:00:31","date_gmt":"2012-04-30T15:00:31","guid":{"rendered":"https:\/\/www.foell.org\/justin\/?p=86"},"modified":"2013-07-16T23:35:03","modified_gmt":"2013-07-17T04:35:03","slug":"moving-a-large-svn-repository-over-a-bad-connection","status":"publish","type":"post","link":"https:\/\/www.foell.org\/justin\/moving-a-large-svn-repository-over-a-bad-connection\/","title":{"rendered":"Moving a large SVN repository over a bad connection"},"content":{"rendered":"<p>I had a client who contracted a Chinese firm to do some development for them. When they came to me, they cited the language barrier as one of the reasons they were having a hard time getting their ideas into production. SUPPLIES! Translation: Surprise (but not a surprise to me). So the first order of business was moving their code repository stateside.<br \/>\n<!--more--><\/p>\n<h2>The normal way: svnadmin dump<\/h2>\n<p>Conventional logic lead me to starting with: <code>svnadmin dump<\/code><\/p>\n<p>What happened was <code>svnadmin dump<\/code> would get partly through it&#8217;s export and the connection would inevitably drop. This left me with a partial dump that was really of no value.<\/p>\n<p>Given the size of the repository (huge) and the quality of the link to the repository (terrible), it was time to find another solution. I still wanted revision history to be retained, so instead of using <code>svnadmin dump<\/code>, I decided to try <code>svnsync<\/code><\/p>\n<h2>The foolproof way: svnsync<\/h2>\n<p><code>svnsync<\/code> requires a second repository to sync to. No problem, just set up a local repository:<\/p>\n<pre>$ cd \/tmp\r\n$ svnadmin create local.repos\r\n$ echo '#!\/bin\/sh' &gt; local.repos\/hooks\/pre-revprop-change\r\n$ chmod +x local.repos\/hooks\/pre-revprop-change\r\n$ svnsync init file:\/\/\/tmp\/local.repos http:\/\/remote.repository.bfe\/repository_root\r\n$ svnsync sync file:\/\/\/tmp\/local.repos<\/pre>\n<p>I don&#8217;t know why <code>svnadmin create<\/code> doesn&#8217;t give you a base (empty) <code>pre-revprop-change<\/code>, but it doesn&#8217;t, so lines 3 &amp; 4 above are needed.<\/p>\n<p><code>synsync sync<\/code> is where the magic happens. It syncs the entire repository one commit at a time. So if (and when) it fails, you can simply re-run that last <code>svnsync sync<\/code> command again, and it will resume where it left off.<\/p>\n<p>Once that&#8217;s done we have to take some extra steps to be able to switch\/relocate any checkouts to the new repository URL. Otherwise subversion is going to complain about the repository UUIDs not matching:<\/p>\n<pre>svn: The repository at '...' has uuid '5242f4d0-6d7c-4812-b150-1df843629073', but the WC has 'add5d305-2225-4d42-af3e-22d1851a68c1'<\/pre>\n<p>So we need to reset some of the properties on the local copy of the repository. The easiest way to do this is to checkout the repository locally&nbsp;and run a few commands for it:<\/p>\n<pre>$ svn checkout file:\/\/\/tmp\/local.repos local.checkout\r\n$ svn proplist --revprop -r0 local.checkout\r\nUnversioned properties on revision 0:\r\n  svn:sync-from-uuid\r\n  svn:sync-last-merged-rev\r\n  svn:date\r\n  svn:sync-from-url\r\n$ svn propdel svn:sync-from-uuid --revprop -r0 local.checkout\r\n$ svn propdel svn:sync-last-merged-rev --revprop -r0 local.checkout\r\n$ svn propdel svn:sync-from-url --revprop -r0 local.checkout<\/pre>\n<p>The revprop changes are not versioned changes, so they take effect immediately &#8211; there&#8217;s no need to commit them. Now we need to set the UUID of the local repository to that of the old remote repository.<\/p>\n<pre>$ svn info http:\/\/remote.repository.bfe\/repository_root\r\n...\r\nRepository UUID: add5d305-2225-4d42-af3e-22d1851a68c1\r\n...\r\n$ svnadmin setuuid local.repos add5d305-2225-4d42-af3e-22d1851a68c1<\/pre>\n<h2>The repository is now ready for svnadmin dump (again)<\/h2>\n<p>With the repository fully copied, and the UUID sorted, you can move it to it&#8217;s final destination. If it&#8217;s ultimately going to a hosted repository (like <a title=\"Repository Hosting\" href=\"http:\/\/repositoryhosting.com\/\">repositoryhosting.com<\/a>) you can dump the local repository to use for importing at the new host:<\/p>\n<pre>svnadmin dump local.repos &gt; local_svn_dump<\/pre>\n<p>Once your repository is at it&#8217;s new location, you can switch any checkouts so they&#8217;re pointing to the new location:<\/p>\n<pre>svn switch --relocate http:\/\/remote.repository.bfe\/repository_root http:\/\/new.repository.us\/svn_root<\/pre>\n<p>It should be noted that as of svn version 1.7 <tt>svn switch --relocate<\/tt> has been deprecated in favor of <tt>svn relocate<\/tt><\/p>\n<div class='kindleWidget kindleLight' ><img decoding=\"async\" src=\"https:\/\/www.foell.org\/justin\/wp-content\/plugins\/send-to-kindle\/media\/white-15.png\" \/><span>Send to Kindle<\/span><\/div>","protected":false},"excerpt":{"rendered":"<p>I had a client who contracted a Chinese firm to do some development for them. When they came to me, they cited the language barrier as one of the reasons they were having a hard time getting their ideas into production. SUPPLIES! Translation: Surprise (but not a surprise to me). So the first order of&hellip; <a href=\"https:\/\/www.foell.org\/justin\/moving-a-large-svn-repository-over-a-bad-connection\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1,9],"tags":[10,11],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-business","category-version-control","tag-subversion","tag-svn"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":24,"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/posts\/86\/revisions\/108"}],"wp:attachment":[{"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.foell.org\/justin\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}