So I saw that nifty little notice in my administrative panel tonight at my in-laws house that says, “A new version of WordPress has been released. Update now” (or something along those lines). Generally a Major.Minor.Subminor update (2.5.0 –> 2.5.1 for example) means minor bugs & quirks were fixed, but more importantly, some security flaws were found and fixed. These updates are usually pretty darn important to be safe, but upgrading can be such a pain and so the minor updates often get put off until a new major version comes out.

Why is it always a pain you ask? Well here’s the list of steps to upgrade a site safely:

  1. Backup your MySQL Database
  2. Backup your existing folder and infrastructure
  3. Back it all up again either on or off the server (whichever you didn’t do in step 2)
  4. Download the new version to your server and extract it
  5. Copy over any custom files or folders you created during the last x number of months since your last upgrade into your new folder
  6. Copy over your configuration files from your existing site
  7. Change ownership and permissions on all the files in your new folder
  8. Remove the current folder for your blog
  9. Copy the new extracted folder with all necessary files to your existing folder name
  10. Visit http://yourdomain.com/wp-admin/upgrade.php and Upgrade your database (if needed)
  11. Verify all your plugins, themes, and custom modificatons / files are still working properly
  12. Verify your caching plugins and permissions are still working properly

How about reducing all that to one command and one URL, with only verification being the hardest task? There are two ways to do this, the first is to start from scratch (the easiest if you’re setting up a new blog) and the second is to migrate your existing site to this setup so that it is easier the next time around.

The first way (a new install)

  1. Create your website blog folder, cd into it, and execute the command:
    $ svn co http://svn.automattic.com/wordpress/tags/2.5.1 .
  2. Next, install WordPress using the famous “Five Minute Install”

To upgrade an instance of WordPress installed this way simply do the following:

  1. Backup your database (just to be safe)
  2. Go to the directory above your blog folder and execute:
    $ cp -r ./blogFolder ./blogFolder.bak
  3. Then to upgrade, merely cd into your blog directory and execute:
    $ svn sw http://svn.automattic.com/wordpress/tags/2.5.2/
  4. Verify that everything still works
  5. Enjoy your five minute upgrades for life :)

Note that the command in step 3 above will need be modified to whatever version of WordPress you are upgrading to. Any custom folders / files you created should not be impacted by this command as your local subversion checkout knows what has or hasn’t been customized.

The second way (migrating an existing site) is a combination of your typical migration and your new subversion installation method.

  1. Backup your MySQL Database
  2. Backup your existing folder and infrastructure
  3. Back it all up again either on or off the server (whichever you didn’t do in step 2)
  4. Create a temporary blog folder, cd into it, and execute the command:
    $ svn co http://svn.automattic.com/wordpress/tags/2.5.1 .
  5. Copy over any custom files or folders you created during the last x number of months since your last upgrade into your new folder created in step 4
  6. Copy over your configuration files from your existing site
  7. Change ownership and permissions on all the files in your new folder
  8. Remove the current folder for your blog to blogFolder.bak
  9. Copy the new extracted folder with all necessary files to your original folder name
  10. Visit http://yourdomain.com/wp-admin/upgrade.php and Upgrade your database (if needed)
  11. Verify all your plugins, themes, and custom modificatons / files are still working properly
  12. Verify your caching plugins and permissions are still working properl

After you have done this you simply need to perform the following process to upgrade your blog in the future:

  1. Backup your database (just to be safe)
  2. Go to the directory above your blog folder and execute:
    $ cp -r ./blogFolder ./blogFolder.bak
  3. Then to upgrade, merely cd into your blog directory and execute:
    $ svn sw http://svn.automattic.com/wordpress/tags/2.5.2/
  4. Verify that everything still works
  5. Enjoy your five minute upgrades for life :)

Note: This blog post was inspired by the tutorial I used from WordPress’ site to guide me through my migration and upgrading process with subversion.

Also note, that one of the sites I worked on with my most recent job had some custom core file modifications. Those will make it much harder to upgrade and I suggest avoiding core file modifications at all costs. That will help to ensure that your blog is easily upgradeable in the future without any hassles. Enjoy!

Comments