Quick Guide to using diff and patch to update a WordPress Weblog
Updates frequently come out for WordPress, such as this most recent one.
When you start upgrading multiple blogs, you’ll soon realize that the standard process of updating WordPress is time consuming, and requires a lot of manual intervention, so here’s a way to automate it using two standard unix tools, diff and patch.
diff finds all the differences between two files and folders, whereas patch takes the output of diff and makes the changes described in the patch file to the files and folders it is run on.
This example goes from WordPress 2.2 to WordPress 2.2.1, but should work for any combination of releases. This won’t update any of your themes and plugins, and you should definitely make a backup before doing it – don’t blame me if you completely screw up your installation!
Step 1
Obtain copies of both versions of WordPress you’re going to be using from the Release Archive, and decompress them into two folders (we’ll call these wordpress22 and wordpress221, in this example)
Step 2
Run diff on the directories to generate a patch file.
diff -Naur -x .DS_Store wordpress22 wordpress221 > wp22_221.patch
(The -x .DS_Store argument is only needed on the Mac, which stores directory information in that file. The other options make the diff unified, recurse through the directories, make it ascii, etc. – read the diff’s man page for more information)
Step 3
Apply the patch you created in step 2 using patch. cd into the directory, and run the patch command:
patch -p 1 < /path/to/wp22_221.patch
You will get a lot of output like this:
... patching file wp-admin/edit-form-advanced.php patching file wp-admin/edit-form-comment.php patching file wp-admin/edit-form.php patching file wp-admin/edit-page-form.php patching file wp-admin/export.php patching file wp-admin/install.php patching file wp-admin/user-edit.php patching file wp-admin/users.php patching file wp-admin/widgets.css patching file wp-admin/widgets.php ...
If there any errors, you'll see them during the patch process.
At this point, you're done. You can use the patch file you created on any WordPress weblog that you want to bring from version 2.2 to 2.2.1, but it won't work for other versions.
About this entry
You’re currently reading “Quick Guide to using diff and patch to update a WordPress Weblog,” an entry on Zack of All Trades
- Published:
- 06.21.07 / 5pm
- Categories:
- Computing, How-To, Technology, Web
- Tags:
2 Comments
Jump to comment form | comments rss [?] | trackback uri [?]