An easy way to keep WordPress up to date
Another WordPress security update was released recently. Since I maintain about 10 wordpress installations on one of my servers, I wanted an easier way to update them.
First of all, I needed to get my wordpress directories switched over to use subversion. I found a pretty easy way to do this and will probably post about it later. Then, I just run this handy script (changing the version to the appropriate number.)
export datetime=`date +%Y%m%d%H%M`
export sitedirs="website1.com website2.com website3.com"
export databases="website1 website2 website3"
echo "backing up directories"
tar cf wordpress-sites-backups.$datetime.tar $sitedirs
nice -n 19 bzip2 wordpress-sites-backups.$datetime.tar &
echo "directories backed up, now backing up databases"
mysqldump -p --databases $databases > wordpress-db-backups.$datetime.sql
nice -n 19 bzip2 wordpress-db-backups.$datetime.sql &
echo "Backup complete, press Enter to continue with upgrade to version $wptag"
for upgradedir in $sitedirs
echo "in /websites/$upgradedir"
svn switch http://svn.automattic.com/wordpress/tags/$wptag
This script makes a backup of your site files and databases prior to the upgrade. This way, you can revert back if something bad happens during (or soon after) the upgrade.
The key there is the svn switch (which I recently discovered), which updates the files which are under subversion control to the version you have specified.
Depending on the update, you may have to login to your wordpress installation to finish it. In the case of 2.2.2, it wasn’t necessary.