WordPress mass update script 3.4.2


This script will search /var/www (changeable in a variable) for any wordpress installs and make sure its upgraded to the latest version.
It will run a backup to /root/wp_upgrade/ of all files and database before doing anything with the site in case of major catastrophe (make sure you have spare disk space if your sites have a lot of uploaded files).

It pays to check each site after the upgrade to make sure plugins all worked (and upgrade plugins before the upgrade works also!)

Let me know if you have any bugs at all, or any problems.

Here’s your script to upgrade them all.

wget http://b.ri.mu/files/wordpress-upgrade.sh
bash wordpress-upgrade.sh

MD5
d2e204576652457fd543c6ae3587941a wordpress-upgrade-3.4.2.sh

SHA1
8276bec77e19ee752d2cbfe51f32310d63115bfa wordpress-upgrade-3.4.2.sh

If you find any bugs or problems, just let me know at liz at rimuhosting dot com. I have now renamed the script to wordpress-upgrade.sh for easy future memorability (using symlinks to link to the latest version)


2 responses to “WordPress mass update script 3.4.2”

  1. Here is a patch to fix some minor issues and spelling errors, and make it work with the current version of WordPress (3.5) which has a shorter version number:


    --- wordpress-upgrade.sh 2012-09-09 21:42:08.000000000 +0000
    +++ /usr/local/sbin/wordpress-upgrade.sh 2013-01-23 06:28:12.000000000 +0000
    @@ -9,7 +9,7 @@
    # do not set it to be / because then it will also find your 'backups' and possibly overwrite them
    FINDDIR=/var/www
    # This is the version, change the version if a later release is released
    -CURRENT_VER="3.4.2"
    +CURRENT_VER="3.5"
    CURRENT_MUVER="2.9.2"

    if [ $(whoami) != "root" ]
    @@ -26,21 +26,21 @@
    wp_root=$(echo $file | sed s@wp-includes/version.php@@)
    wpmu=$(grep wpmu_version ${wp_root}wp-includes/version.php)
    if [ "${wpmu}" == "" ]; then
    - thisis="Standerd WordPress";
    + thisis="Standard WordPress";
    WPCURRENT_VER=$CURRENT_VER
    WP_URL=http://wordpress.org/latest.zip
    - your_ver=$(grep wp_version "$file" |grep -v global |cut -c16-20)
    + your_ver=$(grep wp_version "$file" |grep -v global |cut -d\' -f2)
    else
    thisis="Wordpress MultiUser - you should have upgraded this long back to normal wordpress!";
    WPCURRENT_VER=$CURRENT_MUVER
    WP_URL=http://mu.wordpress.org/latest.zip
    - your_ver=$(grep wpmu_version "$file" |grep -v global |cut -c18-23)
    + your_ver=$(grep wpmu_version "$file" |grep -v global |cut -d\' -f2)
    fi
    if [ ${your_ver} != ${WPCURRENT_VER} ];then
    - echo "You have version $your_ver ${thisis} located at $wp_root that needs updateing to ${WPCURRENT_VER}"
    + echo "You have version $your_ver ${thisis} located at $wp_root that needs updating to ${WPCURRENT_VER}"
    echo -n "Would you like me to upgrade it? [y/N] "
    read yn
    - if [ $yn == "y" ];then
    + if [ "$yn" == "y" ];then
    echo "Upgrading $wp_root"
    mkdir -p /tmp/wpupgrade
    cd /tmp/wpupgrade

    • Cheers, i have been working on a new version which polls the site for newer wordpress versions thanks to other contributions, Currently im on vacation for another week, hence why its not been done (sorry!)