Quick WordPress upgrades with shell access
Just another WordPress upgrade and just another upgrade process done on ‘my way’. While I did the first two upgrades according the detailed upgrade instructions which can be found in the WordPress documentation, starting with 2.0.3 – as far as I remember – I changed to a more simple approach. Before reading further, please note that this way is a very basic one and I guarantee for nothing. It may work for you as for me or it may mutate your WordPress installation into a set of useless files. So, if you have doubts, have a nice day. If you don’t have some kind of UNIX shell access to your WordPress installation (prefered by ssh), have a nice day, too.
IMPORTANT: DO NOT USE THIS METHOD WHEN UPGRADING FROM ANY OTHER RELEASE THAN 2.0.x !!!
After logging in to your webspace, you will probably end up at the home directory of your webspace account. The directory structure depends on your provider, usually the files used for your website are located in a subdirectory. In the commands mentioned below, I assume the name ‘www’ for this directory (adapt the commands accordingly, if your directory name differs or your files are located directly in the home directory).
Step 1 – Backup
Backup regulary, backup often, backup twice. Don’t leave your flat for cigarettes with leaving the keys inside if you don’t have another place to sleep, it’s cold under the bridge. A simple way to backup would be just zipping all files in your web directory (you may use tar if you prefer or don’t have a zip on board). However, if you have also stored your images and photos inside that directory, your zip file would get very large and probably go beyond your web space limit. In that case, you should first create a simple text file containing all directories which should not be backuped while upgrading WordPress. The content of the file depends on your directory names, it may look somehow like this:
With this file, a backup of your current installation can be done as follows (assumpting the name of the file just created is ‘exclude-on-upgrade.txt’):
zip -r ../wp-old.zip . -x@../exclude-on-upgrade.txt
The next step will unpack the WordPress installation archive downloaded and remove the themes directory (only if you don’t need the standard themes):
tar xfz wordpress-2.0.x.tar.gz
rm -rf themes
Before copying the new files over the old installation, you must take care of any WordPress files modified by you. Basically, you should never do this but sometimes life is not basic. Since 2.0.5 I don’t have any modification, before that release I maintained a copy of the original version together with the modified version in a directory parallel to the web space directory so that I could easily check for differences compared with the new version. If you don’t have any modification, fine.
Let’s go: the next step takes, depending on your web server performance, only a few seconds. If you fear any trouble that someone will access your site while upgrading and run into problems, use a “site unavailable” plugin like this one (that’s the one I use). However, with only a few hundred visitors each day like on this site, the risc that someone will run into trouble in these ‘three seconds’ is fairly low.
tar cf – . | (cd ../www; tar xf -)
Usually you should run the WordPress upgrade task now which can be started using the URL http://your.web.site/wp-admin/upgrade.php (this step is not required when upgrading from 2.0.5 to 2.0.6 but mentioned for completeness).
The last step is a very important one: check your plugins. Not a few, check all. My experience is that upgrades running for a older 2.0.x release don’t make trouble when upgrading inside the 2.0.x tree – your experience may differ. If you run into trouble, unzip your backup zip file in your web space directory and switch to the detailed upgrade instructions.