Continuing my trials and tribulations of SVN and Rsync, I came across a new problem today.
This time the client does have Subversion installed, but it is an old version and I can’t update it as I don’t have sudo access.
The problem now is that the working copy has been rsync’d from an existing server, with all the .svn directories intact. If I try and run
$ svn update
on the working copy I get this error:
svn: This client is too old to work with working copy 'xxxx'; please get a newer Subversion client
Using my heightened Google-fu I found this article on Williamo’s Blog. Clearly he’d been having the same problems. The solution was to do a fresh SVN checkout.
All well and good, but this is a production site with extra components (such as stats, a blog which I have no control over cached imaged and other content) that I can’t simply remove just to do a fresh checkout.
So what to do.
Huzzah – Rsync to the rescue again!
As it turns out it’s a simple 3 step process.
- Checkout a fresh copy of the subversion repository in a temp directory
- Remove all the existing .svn directories held in the directory containing the live site
- Rsync the updates from the temp directory to the live directory, this will in effect re-add in the .svn directories, but this time they’ll be the correct version
So here goes.
Step 1. Checkout a fresh copy
$ mkdir ./tmp_dir $ svn co http://domain/path/to/svn ./tmp_dir
Step 2. Remove existing .svn directories from live site
$ cd ./live_site $ rm -rf `find . -type d -name .svn`
Please note: be very careful when running a rm -rf command. Make sure you do a backup. If you are unsure, DON’T DO IT!
Step 3. Rsync the temp directory to the live directory
$ cd ../
(to get back into our root directory)
$ rsync -auv ./tmp_dir/ ./live_site/
If all worked out ok, you should be able to go into the live iste and run an SVN update (which shouldn’t update anything as it would have copied over the fresh checkout)
$ cd ./live_site $ svn update
That’s it! Simple really, but spent a few hours pulling my hair out over this one!