Disclaimer:
Subversion can be tricky. Not only that, the example given is how to use svn to install the latest alpha version of WordPress. Even if you choose to use svn to get stable releases of WordPress, please be careful with what you are about to do. You can mess things up really quickly and have no way to retrieve lost data. If you happen to screw something up, please don't e-mail me for help. I don't have the time to support your problems. So...read carefully, understand each step, and have fun!

Using Subversion to Keep WordPress Fresh

Written by Joe Rodgers on Sunday, September 25, 2005. URI is subject to change.

A short article to teach you how to go from a working WordPress installation that you have been updating "by hand" to one that updates a lot quicker and easier using ssh and svn.

Who doesn't love WordPress? If you're like me you want to use the freshest version available. Updating WordPress is not that hard, as many will attest. I learned a while back that the updating process can be made even simpler using Subversion, or svn. Subversion is nice because it can track changes in a directory in which there is a svn history. The people behind WordPress allow Subversion access to their stable and alpha releases. What we will do is setup your WordPress directories to check for and reflect changes that occur in the "master" WordPress directories maintained by the developers.

Here's the bottom line: What we need to do is move/rename your current WordPress directory, setup a new one with subversion, and migrate your essential installation files (wp-config.php, themes/, plugins/) from the old directory to the new one. From there, updating is a cinch.

svn co

I am assuming that you already have a basic installation of WordPress that has no intrusive modifications to the WordPress core files. Any modifications should only be in your wp-content/themes/ and wp-content/plugins/ directories. If you have hacked the core files in any way then this might not be as painless.

I am a TextDrive customer and they allow me to use ssh to manage my account. I use Mac OS X, so I use Terminal (Applications --> Utilities --> Terminal) and start the following. Be sure to read the notes.

  1. ssh -l textdrive-username server.textdrive.com
  2. cd pathname/
  3. mv wordpress/ wordpress-old/
  4. mkdir wordpress
  5. cd wordpress/
  6. svn co http://svn.automattic.com/wordpress/trunk/ .
  7. cp ../wordpress-old/wp-config.php .
  8. cp -R ../wordpress-old/wp-content/themes/your-theme/ ./wp-content/themes/your-theme/
  9. cp ../wordpress-old/wp-content/plugins/your-plugin.php ./wp-content/plugins/
  10. Open a browser and visit http://example.com/wordpress/wp-admin/upgrade.php
  11. Go back to public_html/ and type rm -Rf wordpress-old/
  12. exit (x2)

Out with the old, in with the new! I wouldn't perform that second-to-last step until you have determined everything is working OK. Tread lightly with rm, it can cause a lot of heartache if used wrongly.

What I Really Do

Instead of Step 7, here is what I actually do. I like to use the latest wp-config-sample.php and use vi to retype my MySQL database, username, and password information in each time. So, following Step 6, in wordpress/

I like to keep the index.php file in public_html/ and keep all my WordPress files in their own directory. So I move the index.php to public_html/ and edit it using vi. Since I am already in wordpress/ here is what I do.

I am kind of lazy. For Step 9 I just type cp ../wordpress-old/wp-content/plugins/*.php ./wp-content/plugins/ and watch out for plugins with directories. WordPress Tiger Administration comes to mind.

Notes

1.

The -l is used to signify that you want to use the following username when logging in.

2.

You want to change directories to start your work. The first path is for older TextDrive customers. The second would be used for newer customers.

Here is a probable snapshot of a typical WordPress installation. Your file structure may differ. The bolded directory signifies what directory you are working from at each step. I am only showing the files that we are concerned with, so you won't see wp-admin/, wp-rss.php, etc.

3.

4.

6.

When you set up a new directory with svn you make a checkout. From then on out you do an svn update. You could just get the latest stable release with svn co http://svn.automattic.com/wordpress/tags/1.5.2/ . You could then use svn switch to keep up-to-date with any newer version that comes out.

Incidentally, you could also use svn to checkout the latest version of K2, e.g. svn co http://svn.boxofclue.com/k2/ . OR svn co -r 62 http://svn.boxofclue.com/k2/ . if you want to use a particular revision (e.g. revision number 62).

7.

8.

You have to perform this for every theme you have.

9.

You have to perform this for every plugin you have. Hypothetically you should be able to type cp ../wordpress-old/wp-content/plugins/*.php ./wp-content/plugins/, but plugins are a little tricky. Some plugins have directories, etc. Use your best judgment.

11.

Back where we started!

svn up

  1. ssh -l textdrive-username server.textdrive.com
  2. cd public_html/wordpress/
  3. svn up
  4. Open a browser and visit http://example.com/wordpress/wp-admin/upgrade.php
  5. exit (x2)

What I Really Do

I basically repeat what I do above and delete files that I don't use: rm index.php, rm wp-config-sample.php

Sources & Acknowledgments

Many thanks should go to Firas from the #wordpress channel on irc.freenode.net. He helped me work out some of the kinks along the way. I'm sure there were others and I would gladly acknowledge your help. Let me know.