WordPress Updates & Converting to SVN


WordPress 2.8 came out awhile ago and there was immediate talk of WordPress 2.8.1 to fix some issues. So I was in no rush to do any update despite liking to stay up to date. WordPress 2.8.1 was released so I decided to bring all my sites up to WordPress 2.8.1 and to update the theme or convert to svn as appropriate. I had tested using svn to maintain WordPress awhile back but this site and a couple had yet to be converted. It was time to convert them now that there’s a WordPress upgrade.

The steps I followed were pretty straight-forward and allowed me to update all my sites quickly with minimal outages.

  1. Validate my previous night’s backup of the databases and file system.
  2. Update plugins to make sure they work with WordPress 2.8.1
  3. Create a new directory called newsite.
  4. Use the subversion command
    svn co http://core.svn.wordpress.org/tags/2.8.1 .
    to install the latest WordPress into this subdirectory.
  5. Here’s where I departed from the WordPress.org instructions for converting a “traditional” WordPress install to svn. Instead of looking for custom files and copying them and plugins individually I used the following copy command with my old website directory as the current directory:
    cp –p –r –i –u . ../newsite
    –p says permissions should be copied
    –r will copy subdirectories (recursive)
    –i is interactive and will prompt for any file overwrites
    –u says to update only only newer or missing files will be copied. The –u should prevent overwriting any files installed via svn and the –i switch should prompt me before any are overwritten in case I’m wrong. I use the dot ‘.’ to indicate the current directory in order to get hidden files too. If I was to use ‘*’ the hidden files wouldn’t be copied. This made sure I didn’t miss any files while not overwriting any WordPress 2.8.1 files.
  6. After the copy I issued a svn update (svn up) just to make sure nothing was overwritten and nothing was.
  7. I then updated the theme files in the newsite directory if I needed to update the theme for the site.
  8. I added the following directive to my wp-config.php file (in newsite) to allow plugin updates without having to edit file.php. This is new with WordPress 2.8. See my article on enabling automatic plugin updates for more information.
    define('FS_METHOD', 'direct');
  9. When it came time to update the live site I enabled the maintenance mode plugin and issued the following two commands. The first backs up the sites directory structure and the second moves the newsite directory to the location of the live site. (My live site is in the public directory)
    mv public public-old
    mv newsite public
  10. Run the WordPress upgrade (http://www.sitename.com/wp-admin/upgrade.php) to upgrade the database.
  11. At this point I’m done except for the testing and turn off the maintenance mode plugin. The actual site outage was only a couple of minutes during steps 9 and 10.

This made it easy to update my live sites along with test and sites in development without any problems and in record time.

%d bloggers like this: