HOWTO: Upgrade an SVN Managed Drupal Installation (without CVS)
At Chapter Three we use the Subversion Version Control System to manage our client and internal Drupal projects. When we kick off a new project we roll out the latest version of Drupal, stick it in the SVN repository, and start developing.
As a matter of best practices it is usually a good idea to check Drupal directly out of the Drupal CVS repository which makes upgrading as simple as "cvs update -dP -r DRUPAL-5--X". However, we have a number of sites that were not checked out in this way and this makes updating Drupal sort of a pain. Our SVN management system wants us to update each file individually (so the changes can be versioned), but individually updating each of Drupal core's 300+ files is a little bit tedious.
However, with a little command line wizardry we can quickly download a copy of Drupal and generate a command to copy the new version of each Drupal core file on top of our installation in a way that can be committed up to SVN. To do this we need to wget a copy of Drupal and then use the all powerful find command to detect and copy the relevant files.
# Download a Copy of Drupal, Extract it, and Enter its Directory
wget http://ftp.drupal.org/files/projects/drupal-5.9.tar.gz
gzip -d drupal-5.9.tar.gz
tar xf drupal-5.9.tar
cd drupal-5.9
# Use Find to Detect Each Local File in Drupal Core and Execute a
# Command to Copy the File to the Live Version of the Website
find * -type f -exec echo cp {} /path/to/www/{} \; # this just echos the commands
find * -type f -exec cp {} /path/to/www/{} \; # this actually runs the commandsTo make sure the copy worked we can use the same find command do an individual diff on each file. This will assure us that we successfully updated our website with the version of code we downloaded from Drupal. This command can also be used prior to updating to compare different versions of Drupal to see what core changes are going to be (or have been) made.
find * -type f -exec diff {} /path/to/www/{} \;












am i missing something?
if you perform a cp of every frile from the downloaded site to your existing site, won’t you overwrite your existing site files no questions asked?
i guess if you don’t modify core, that’s ok. but if for some reason you did, it would overwrite your changes.
and if something went wrong for whatever reason you’d be screwed if you didn’t back up your existing site. you couldn’t backout and get back to where you were before. so you probably should mention doing a backup in your post.
finally. i imagine the aim of this post is so that you can convert a NON CVS existing site into a CVS based one that you check back into svn. but when you download and extract a drupal tar file it does NOT have the CVS directories in it right? at least that’s been my experience. so wouldn’t you do a CVS checkout instead of the wget / tar operation listed in the post? otherwise your existing site will never be under CVS control (e.g. have the ncessary CVS metadata directories included). or am i missing something?
last but not least. after your existing site is updated to CVS you then have to check it back into SVN as an svn project. so it would be nice to see a followup post on how you get the drupal CVS source into svn, how you perform updates to the svn check’d out drupal site / src using CVS, and how you perform regular updates and VERSIONING/TRACKING (e.g. tags) to svn as you make daily fixes to the drupal svn site.
the whole CVS inside of svn is sort of double work. since it sounds like you use this on a regular basis it’d be a great idea for a post if you guys can swing it.
thanks
you are copying a fresh download of drupal into the existing site. so i imagine that means you’re
Why not use just tar?
Good article, Matt.
Just one suggestion/question:
Why not use ‘tar xfz’ to gunzip and untar the archive, instead of calling gzip and tar separately?
Smells just as sweet
There is no worries to use tar xfz in the command. I was trying to be a little more specific with everything (first you unzip, then you untar). It works just as well the other way of course.
Thanks for this
I’ve previously only done Drupal upgrades on a PC where dragging the new files and folders over to the existing working copy preserves all the .svn directories and only replaces changed files.
Now I’m developing on my Mac, and finder insists on deleting my .svn directories instead of performing a merge.
Your tip works around this problem perfectly, and is a lot faster than doing it in the GUI anyway.
Doesn't seem to function correctly
When I run this find command, it seems to take all the new files and copies them into the main drupal directory of the existing installation, not into the subdirectories, so you end up with everything in /path/to/www, no matter what subdirectory it came from.
Post new comment