Upgrading WordPress
Friday, 12 December 2008
Today I upgraded my WordPress installation for the first time, to 2.7 'Coltrane'. The three-step upgrade was as easy and trouble-free as advertised and there's no point in trying to make the excellent Codex instructions any clearer. But I could have been easier on myself still, so here's a cookbook on what I will do next time:
I keep a mirror of my WordPress blog on my local computer in "C:/work/enoriver blog backups/". There are three folders there: "wordpress files", "upgrades" and "database".
The folder "wordpress files" has two subfolders: "blog" and "blog_old". The folder "blog" mirrors my latest live WordPress install. It has the current sub-folders -- wp-admin, wp-content, wp-includes -- and the current loose files. The folder "blog_old" mirrors my previous WordPress install.
From here on out all file path names are relative to "C:/work/enoriver blog backups":
Next time I upgrade, I will download the zipped files of the newest version and save them to the "/upgrades" folder. Next, I will do the database backup and copy the .sql file to the "/database" folder.
Then I will synchronize -- using the excellent WinSCP -- my "/wordpress files/blog" folder with my current install. Chances are nothing will have changed between now and then, but can't hurt. Between the database backup and this sync, I will have just produced a full backup.
Next, I will erase "/wordpress files/blog_old", make a copy of my "/wordpress files/blog" folder, and rename it "/wordpress files/blog_old".
Next, in my "/wordpress files/blog" folder I will erase the "wp-includes" and "wp-admin" folders.
Next, I will unzip the new WordPress in the "/upgrades" folder. It will create a folder named "/upgrades/wordpress" with the newest version of the three sub-folders and the loose file. I will move "/upgrades/wordpress/wp-includes" and "/upgrades/wordpress/wp-admin" to my "/wordpress files/blog" folder. I will also move the loose files in "/upgrades/wordpress" and overwrite whatever loose files I have in "/wordpress files/blog".
At this point, the only sub-folder left in "/upgrades/wordpress" is "wp-content". I cannot move this one to "/wordpress files/blog", because that would erase my customizations. Instead, I must move its content to that of "/wordpress files/blog/wp-content". Once I moved the content of "/upgrades/wordpress/wp-content", this file path is now an empty shell. I can tidy up by removing "/upgrades/wordpress" and all its contents. This leaves "/upgrades" with only the zipped folder that I downloaded from WordPress, like it was just before I started this process.
Now the "/wordpress files/blog" has the latest install, which is not yet live on my site; and "/wordpress files/blog_old" mirrors my current site. Next, I overwrite the blog on my site with "/wordpress files/blog", also with WinSCP, and hope for the best. If I need to upgrade the database, WordPress will let me know and present me with a script to run. If I screwed anything up, I can just revert to "/wordpress files/blog_old".