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.

CODE:
  1. #!/bin/bash
  2.  
  3. ###
  4. # CONFIGURATION
  5. ###
  6.  
  7. # List Directory Where the Update Script is Held
  8. SCRIPT_DIRECTORY=/home/david
  9.  
  10. # List Each Directory on Your Server that Contains a Wordpress Installation
  11. installations[0]=/var/www/html/blog1
  12. installations[1]=/var/www/html/blog2
  13.  
  14. ###
  15. # DO NOT EDIT BELOW THIS LINE
  16. ###
  17.  
  18. rm -Rf "$SCRIPT_DIRECTORY/wordpress"
  19. cd "$SCRIPT_DIRECTORY"
  20. wget http://wordpress.org/latest.zip --output-document wordpress.zip
  21. unzip wordpress.zip
  22.  
  23. for installation in ${installations[@]}
  24. do
  25.         echo "Updating $installation..."
  26.         cp "$SCRIPT_DIRECTORY/wordpress/*" "$installation"
  27.         cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-admin" "$installation/"
  28.         cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-includes" "$installation/"
  29.         cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-content/themes/*" "$installation/wp-content/themes"
  30.         cp -Rf "$SCRIPT_DIRECTORY/wordpress/wp-content/plugins/*" "$installation/wp-content/plugins"
  31. done
  32.  
  33. 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

Wordpress | Comments | Trackback | Del.icio.us | Digg | Technorati Jump to the top of this page

Leave a Reply

  •  
  •  
  •  

You can keep track of new comments to this post with the comments feed.

Badges

View David Tucker's profile on LinkedIn
Inside RIA Badge

Community Posts