Updating Multiple Wordpress Installations Programatically
May 2nd, 2008
Shell scripts are great (of course - this is only going to work if you are on a Linux server). This script should also preserve plug-ins and themes (assuming that you keep data in the standard directories).
NOTICE: I cannot guarantee the functionality of this script. It is meant to be used as a guide. Backup your Wordpress installations before using this script.
-
#!/bin/bash
-
-
###
-
# CONFIGURATION
-
###
-
-
# List Directory Where the Update Script is Held
-
SCRIPT_DIRECTORY=/home/david
-
-
# List Each Directory on Your Server that Contains a Wordpress Installation
-
installations[0]=/var/www/html/blog1
-
installations[1]=/var/www/html/blog2
-
-
###
-
# DO NOT EDIT BELOW THIS LINE
-
###
-
-
rm -Rf "$SCRIPT_DIRECTORY/wordpress"
-
cd "$SCRIPT_DIRECTORY"
-
wget http://wordpress.org/latest.zip --output-document wordpress.zip
-
unzip wordpress.zip
-
-
for installation in ${installations[@]}
-
do
-
echo "Updating $installation..."
-
cp "$SCRIPT_DIRECTORY/wordpress/*" "$installation"
-
cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-admin" "$installation/"
-
cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-includes" "$installation/"
-
cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-content/themes/*" "$installation/wp-content/themes"
-
cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-content/plugins/*" "$installation/wp-content/plugins"
-
done
-
-
echo "Updates Complete..."
You will have to update two settings in the script. First, you will need to update the SCRIPT_DIRECTORY variable. This will be the directory where wordpress will be downloaded and unzipped. Next, you will need to update the array of wordpress installations. Be sure to increment the number in the array.
You can download the script below. This script will not update your database tables - you will have to log into the administrator and click through the update process there.
Download Code
Update Script



Leave a Reply