In order to run some test with svn and git, I needed to have a copy of an existing SVN repository to play around. Since I was pretty sure nobody was current accessing it, I could have gone for a copy of the existing repository files and a rename. But I wanted to do it in a clean way because I may need it again when I have less time to experiment.
Actually it was very easy. SVN provides two commands called dump and load. Dump exports a repository including the whole history i.e. the individual revisions. And load does the opposite, it imports all those revisions into a repository. So we need to do the following:
- Dump the repository to a file
- Create a new repository
- Load the dumped file to the new repository
So first the dump:
# svnadmin dump /var/svn-repos/kanban > /tmp/kanban.dump * Dumped revision 0. ... * Dumped revision 303.
So now, we’ve dumped all 304 revisions. Next create a new repository:
# svnadmin create /var/svn-repos/kanban_board
And load the dump in the new repository:
# svnadmin load /var/svn-repos/kanban_board < /tmp/kanban.dump <<< Started new transaction, based on original revision 1 * adding path : README.txt ... done. ... ------- Committed revision 1 >>> ... <<< Started new transaction, based on original revision 303 * editing path : styles/main_ci.css ... done. ------- Committed revision 303 >>>
Then I checked out from the new repository, which worked fine. Next test was to change something and check in. I got the following error message:
svn: E000013: Commit failed (details follow): svn: E000013: Can't open file '/var/svn-repos/kanban_board/db/txn-current-lock': Permission denied
This basically means that I have the wrong permissiong on the db subdirectory of my repository:
# l /var/svn-repos/kanban_board/ total 24 drwxr-xr-x 2 root root 4096 Sep 23 18:52 conf drwxr-sr-x 6 root root 4096 Sep 23 18:52 db -r--r--r-- 1 root root 2 Sep 23 18:52 format drwxr-xr-x 2 root root 4096 Sep 23 18:52 hooks drwxr-xr-x 2 root root 4096 Sep 23 18:52 locks -rw-r--r-- 1 root root 229 Sep 23 18:52 README.txt
It all belongs to the root user (the user I was logged in when creating the repository). So I just need to change it to the svn user. In my case I use the apache user and the svn user group so that I have access to the repository via a web interface as well as from the command line:
# chown -R www-data:svn /var/svn-repos/kanban_board/ # l /var/svn-repos/kanban_board/ total 28 drwxr-xr-x 2 www-data svn 4096 Sep 23 18:52 conf drwxr-xr-x 3 www-data www-data 4096 Sep 23 19:02 dav drwxr-sr-x 6 www-data svn 4096 Sep 23 19:02 db -r--r--r-- 1 www-data svn 2 Sep 23 18:52 format drwxr-xr-x 2 www-data svn 4096 Sep 23 18:52 hooks drwxr-xr-x 2 www-data svn 4096 Sep 23 18:52 locks -rw-r--r-- 1 www-data svn 229 Sep 23 18:52 README.txt
Note: the additional dav directory is there because I used websvn to check whether I could also see the repository in the web UI before listing the directory contents.
Now the commit works too and I have a clone of my original repository including the revision history !