Cyotek Development Bloghttps://devblog.cyotek.com/tag/svnadmin/atom.xml2018-08-07T16:04:33ZUpgrading a SVN repository using VisualSVN Serverurn:uuid:f51c9650-297a-4c31-90cc-bff6a1212f4c2018-08-07T16:04:33Z2018-08-07T16:04:33Z<p>Although I use Git for anything open source we produce, all
other code is still in a SVN repository. I use <a href="https://www.visualsvn.com/server/" rel="external nofollow noopener">VisualSVN
Server</a> for the server side things. When upgrading it last
week to the latest version, it mentioned that Apache SVN 1.10
had new compression options and it occurred to me that while
I've upgraded working copy formats before, my SVN databases are
probably still using whatever format they were created at. This
article covers how to upgrade SVN repositories using the
VisualSVN Server software.</p>
<h2 id="checking-the-version-of-a-repository">Checking the version of a repository</h2>
<p>According to the <a href="https://subversion.apache.org/docs/release-notes/1.10.html" rel="external nofollow noopener">release notes</a>, the current filesystem
format version used by SVN is <code>8</code>. We can either use the
<code>svnadmin info</code> command to view the version, or via a GUI by
right clicking a repository in the <strong>Visual SVN Server
Manager</strong>, selecting <strong>Properties</strong> from the context menu then
accessing the <strong>Details</strong> tab.</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1a.png" class="gallery" title="An example of a repository using an older file format" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1a.png" alt="An example of a repository using an older file format" decoding="async" loading="lazy" /></a><figcaption>An example of a repository using an older file format</figcaption></figure>
<p>In the above example, my SVN Repository is at version 4, so a
little bit out of date. This particular repository was created
in <a href="/post/migrating-from-visual-sourcesafe-to-subversion">June 2011</a> using whatever version of VisualSVN Server was
current at the time.</p>
<h2 id="upgrading-a-repository">Upgrading a repository</h2>
<p>There are two ways of upgrading the repository. The first is a
simple action that doesn't change any existing commits; they
remain in whatever format they were created with. Only new
commits will use the features of the new format.</p>
<p>The second approach essentially recreates the repository from a
backup, and rewrites everything using the new format.</p>
<blockquote>
<p>Warning! If you upgrade the repository format, then you won't
be able use this repository with older versions of SVN Server.</p>
</blockquote>
<hr />
<blockquote>
<p>Important! Make sure you have backups before following either
of the processes in this article, especially the latter</p>
</blockquote>
<h2 id="upgrading-the-easy-way">Upgrading the easy way</h2>
<p>To perform a basic upgrade:</p>
<ol>
<li><p>Right click the repository to upgrade, and select <strong>All
Tasks</strong> from the context menu, then <strong>Upgrade Repository
Format...</strong></p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1b.png" class="gallery" title="Initiating an upgrade via VisualSVN Server" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1b.png" alt="Initiating an upgrade via VisualSVN Server" decoding="async" loading="lazy" /></a><figcaption>Initiating an upgrade via VisualSVN Server</figcaption></figure></li>
<li><p>A confirmation prompt will be displayed, accept it to
continue</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1c.png" class="gallery" title="Take note if you need to revert to an older version of SVN" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1c.png" alt="Take note if you need to revert to an older version of SVN" decoding="async" loading="lazy" /></a><figcaption>Take note if you need to revert to an older version of SVN</figcaption></figure></li>
<li><p>In my case, the &quot;upgrade&quot; was instantaneous and a completion
message was quickly displayed</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1d.png" class="gallery" title="A simple and painless upgrade" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1d.png" alt="A simple and painless upgrade" decoding="async" loading="lazy" /></a><figcaption>A simple and painless upgrade</figcaption></figure></li>
<li><p>When checking the properties for the repository, we can now
see that the <em>Filesystem format</em> is <code>8</code>, and the
<em>Compression</em> is <code>lz4</code>. So the upgrade seems to have done
something.</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1e.png" class="gallery" title="The properties of the same repository after upgrading" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1e.png" alt="The properties of the same repository after upgrading" decoding="async" loading="lazy" /></a><figcaption>The properties of the same repository after upgrading</figcaption></figure></li>
</ol>
<p>I was curious what the upgrade process had really done, so I
compared the upgraded repository with a copy I'd made of the
original.</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1f.png" class="gallery" title="Comparing the changed made by the upgrade" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1f.png" alt="Comparing the changed made by the upgrade" decoding="async" loading="lazy" /></a><figcaption>Comparing the changed made by the upgrade</figcaption></figure>
<p>Out of the 20 thousand (with spare change!) files making up the
repository, only two had changed. The <code>format</code> file had a change
from <code>4</code> to <code>8</code>, very logical. The <code>uuid</code> file had a new entry
added to it, which I assume is for new commits.</p>
<p>After I did the compare, I checked out the repository to a clean
working copy, created a new file, then committed it. I then
repeated the compare and could see the new transaction in the
repository. No idea if it's using the new format or not though.</p>
<p>This was as far as I went with the basic upgrade. I checked that
it seemed to be working as expected, but then reverted to my
backup.</p>
<h2 id="upgrading-the-harder-way">Upgrading the harder way</h2>
<p>The second option isn't really an upgrade, or at least the
approach I took wasn't. It basically involves creating a new
repository by importing a dump of your current repository, which
I assume upgrades as it goes.</p>
<blockquote>
<p>I'm not covering how to create a dump file in this article -
I'm going to assume that you are properly backing up your SVN
repository already!</p>
</blockquote>
<ol>
<li><p>Right click the repositories root node and select <strong>Import
Existing Repository...</strong> from the context menu</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1n.png" class="gallery" title="Initiating a repository import" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1n.png" alt="Initiating a repository import" decoding="async" loading="lazy" /></a><figcaption>Initiating a repository import</figcaption></figure></li>
<li><p>When prompted for a source, select the second option, <strong>Load
repository from a dump file</strong>, and click <strong>Next</strong></p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1g.png" class="gallery" title="Choosing the source to import from" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1g.png" alt="Choosing the source to import from" decoding="async" loading="lazy" /></a><figcaption>Choosing the source to import from</figcaption></figure></li>
<li><p>Enter the name of the SVN dump to import, then click <strong>Next</strong></p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1h.png" class="gallery" title="Selecting a SVN dump to import" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1h.png" alt="Selecting a SVN dump to import" decoding="async" loading="lazy" /></a><figcaption>Selecting a SVN dump to import</figcaption></figure></li>
<li><p>Next you need to specify a name for the repository, it will
default to one based on the filename of the dump. However, it
doesn't sanitise this default name and so you might find it
it invalid</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1i.png" class="gallery" title="Specifying the repository name" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1i.png" alt="Specifying the repository name" decoding="async" loading="lazy" /></a><figcaption>Specifying the repository name</figcaption></figure><figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1j.png" class="gallery" title="An example error if your name isn't suitable" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1j.png" alt="An example error if your name isn't suitable" decoding="async" loading="lazy" /></a><figcaption>An example error if your name isn't suitable</figcaption></figure></li>
<li><p>The last step is to set the permissions. The default seemed a
little restrictive and weren't appropriate for my scenario, I
went with <strong>No specific permissions (global permissions
apply)</strong> to use the NTFS permissions I have set up on the
repository folders. Make sure the permissions you set match
those of the repository you're upgrading, then click
<strong>Import</strong> to start the process</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1k.png" class="gallery" title="Setting the permissions for the new repository" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1k.png" alt="Setting the permissions for the new repository" decoding="async" loading="lazy" /></a><figcaption>Setting the permissions for the new repository</figcaption></figure></li>
<li><p>Wait for the import to complete. This make take some time.</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1l.png" class="gallery" title="A slowly moving progress bar as the dump is imported" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1l.png" alt="A slowly moving progress bar as the dump is imported" decoding="async" loading="lazy" /></a><figcaption>A slowly moving progress bar as the dump is imported</figcaption></figure></li>
<li><p>Once it's finished, a summary dialog will be displayed</p>
<figure class="screenshot" ><a href="https://images.cyotek.com/image/devblog/svnrepoupgrade-1m.png" class="gallery" title="A summary screen for a successful import" ><img src="https://images.cyotek.com/image/thumbnail/devblog/svnrepoupgrade-1m.png" alt="A summary screen for a successful import" decoding="async" loading="lazy" /></a><figcaption>A summary screen for a successful import</figcaption></figure></li>
<li><p>Exit the VisualSVN Manager</p>
</li>
<li><p>Stop any running VisualSVN services</p>
</li>
<li><p>Open the folder where your repositories are located</p>
</li>
<li><p>Rename your current repository</p>
</li>
<li><p>Rename the import repository to have the name of the
original repository</p>
</li>
<li><p>If you have created custom hooks, you'll need to copy these
from the <code>hooks</code> folder of your original repository. If you
have customised other settings you may need to copy these
too, however as I've always used default settings this
didn't apply to me and so I don't know what files you'd need
to modify</p>
</li>
<li><p>To stop VisualSVN Server from seeing the renamed original
repository, you may wish to move it to a different location,
until you are sure you don't need it and it is safe to
delete</p>
</li>
<li><p>Restart the VisualSVN services that stopped previously</p>
</li>
</ol>
<p>Once again, I performed a compare of the repository to try and
get a feel for what the upgrade process does. Unfortunately,
importing the dump file seems to re-order files within each
transaction and so every single file was different even without
looking for anything format specific. In all honesty, I couldn't
see anything special about any change when looking at a sample
of files.</p>
<p>One thing I did note was that the new repository was 746MB in
size, compared with 680MB previously. I wasn't really expecting
the repository to be larger given it was supposed to be
optimised, and using a different compression method which you'd
assume was chosen as it gave better returns than the older one.</p>
<h2 id="which-approach-to-take">Which approach to take?</h2>
<p>I don't really know which approach is better - the former is
certainly quicker, whilst the latter should result in a more
optimised. However, VisualSVN Server doesn't make the latter
approach particular easy at all - it would be much simpler to do
<code>svnadmin load</code> from a command window instead of jumping the
hoops of creating a new repository and then replacing the old
one with the new.</p>
<p>As always, your mileage may vary. As always this article might
have errors, proceed at your own risk and make sure you have
backups!</p>
<h2 id="update-history">Update History</h2>
<ul>
<li>2018-08-07 - First published</li>
<li>2020-11-22 - Updated formatting</li>
</ul>

<p><small>
All content <a href="https://devblog.cyotek.com/copyright-and-trademarks">Copyright (c) by Cyotek Ltd</a> or its respective writers. Permission to reproduce news and web log entries and other RSS feed content in unmodified form without notice is granted provided they are not used to endorse or promote any products or opinions (other than what was expressed by the author) and without taking them out of context. Written permission from the copyright owner must be obtained for everything else.<br />Original URL of this content is https://devblog.cyotek.com/post/upgrading-a-svn-repository-using-visualsvn-server .
</small></p>Richard Mosshttps://www.cyotek.com/richard.moss@cyotek.com