Upgrading Wordpress
Created this article to document the upgrading of Wordpress on my server.
I initially used the rsync method but have now begun using the svn method because of ease of upgrading versions after the initial setup.
Contents |
Using svn
Converting a non-svn instance
If you have not used svn to install/upgrade your Wordpress instance, you need to make some modifications to use the svn upgrade method.
Checkout your old version
To retrieve the version of your instance, you could try to look at the readme.html:
$ grep 'Version' readme.html
And now check out that version into a temporary new directory:
$ svn co http://core.svn.wordpress.org/tags/2.9.1 wp-temp
Copy custom files over
To make this process easier, navigate to your Wordpress instance. Now copy custom files in the Wordpress root with a command like this:
$ cp -p wp-config.php favicon.ico .htaccess ../wp-temp
Now, copy custom directories:
$ cp -rp images storage ../wp-temp
Next, copy wp-content:
$ cp -rpfu wp-content/* ../wp-temp/wp-content
And finally, make sure you did not miss any custom files or directories by doing a diff on both directories:
$ cd .. $ diff -rq html/ wp-temp/ | grep -v svn
If you missed some files or directories, go back to your old instance and use the cp commands demonstrated above.
Swap in svn instance
Finally, put the temp directory live.
$ cd .. $ mv html html.wp2.9.1; mv wp-temp html
Visit your site to make sure everything is okay now.
Upgrading an svn instance
Upgrading is easy. First, back up your current instance:
cp -rp html html.wp2.9.1
Now, upgrade to a new version, you have to change the svn URL the instance is tied to. The command will look something like this:
$ svn sw http://core.svn.wordpress.org/tags/2.9.2 html
Finally, visit http://sitename/wp-admin/upgrade.php to upgrade database and you're done.
References
http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion
Using rsync
Backing up old files
Backup the whole Wordpress instance folder by doing something like the following:
$ cp -rp html html.backup
Download latest version
Using wget, download the latest version. I tend to download to my ~/downloads.
$ cd ~/download $ wget http://wordpress.org/latest.tar.gz
Now, un-tar it:
tar -xzf latest.tar.gz
There should be a directory called ~/downloads/wordpress. You could view the readme.html file for information on the downloaded version.
Modifying files
Now you could modify permissions and ownership to match your configuration. For example, I change group of all apache served files.
chgrp -R www wordpress
Upgrading instances
Finally, upgrade the files on all our Wordpress installations. This is my example:
rsync -gorRv wordpress/./ /var/www/sites/iambelmin/html rsync -gorRv wordpress/./ /var/www/sites/bfworks/html
(You need to use the ./ in the origin because you need to set the base for the relative copying. See man rsync for more information)
Explanation of the options:
- -g - Preserve the group attribute of files.
- -o - Preserve the ownership of files.
- -r - Copy files recursively.
- -R - Copy files relatively.
- -v - Tell us what's going on.
Finishing and double checking
Double check files like:
- Site's icon (favicon.ico)
- Custom content (in wp-content like themes and uploads)
- Apache config file (.htaccess, etc)
- Other non-Wordpress files you are hosting
Finally, visit http://sitename/wp-admin/upgrade.php to upgrade database and you're done.

