Upgrading WB News

If you already have a previous installation of WB News and wish to upgrade you should do so by upgrading incrementally e.g. 2.0.1 to 2.0.2 instead of 2.0.1 to 2.1.0.

The following steps should be done before doing an upgrade

  1. Turn the News System off. The upgrade make break your implementation of WB News so its best to turn it off.
  2. Make a database backup
  3. Make a backup of all your WB News files

Download Upgrade Archive

You will need to download the upgrade archive

Choosing your way to upgrade

The default way to upgrade an existing system is the manual process, the other way is to use a bash script which will create database and file backups, overwrite files and upgrade the system.

Manual Upgrade

It is recommended to download the upgrade archive to your computer and extract it using a ZIP Program. Once you have extracted the files, you will need to FTP/SFTP/SCP on to your server and upload all the files extracted from the archive.

Your config.php should have write permissions again

$ chmod 777 config.php

Than you will need to open your web browser to http://localhost/news/install/install.php. The install.php file should automatically find the upgrade.php file to do the upgrade.

* Note: If the install file does not automatically detect a previous install there maybe an error in the config.php file or you may have already initiated a session for the installation. Its recommended to remove all cookies in the browser before upgrading. If it persists you will need to file a bug

The upgrade.php should update the config.php version number and make any necessary schema/data changes. If you get the complete page without any errors your upgrade has been successful and you can continue using WB News.

* Note although WB News is tested with Install/Upgrade in various settings it is not 100% bullet proof and may break your installation. It is why we recommend you do backups of files and database before doing so. Not doing so will mean you may get limited support in fixing any errors which may have occurred.

Bash Script Upgrade

The bash upgrade script will ask you if you want to make Schema and file backups before commencing. It is recommended to make your own backups.

The script does not come with the installation or upgrade archives and Webmobo will not be liable if your system breaks due to its use.

Source code below for wbnews_upgrade.sh

  1: #!/bin/sh -x
  2:
  3: # check args
  4: if [ $# -ne 2 ] ; then
  5:     echo "Expected $0 [wbnews path] [zipfile]"
  6:     exit 1
  7: fi
  8:
  9: CONFIG_FILE=`find $1 -maxdepth 1 -name config.php`
 10:
 11: # make sure 1st argument is a directory
 12: if [ ! -d $1 ] ; then
 13:     echo "The wbnews path must be a directory"
 14:     exit 1
 15: elif [ "$1/config.php" != "$CONFIG_FILE" ] ; then
 16:     echo "A config.php file must be present"
 17:     exit 1
 18: fi
 19:
 20: # make sure 2nd argument is a zip file
 21: if [ "application/x-zip" != `file -ib $2` ] ; then
 22:     echo "The second argument must be a zip file"
 23:     exit 1
 24: fi
 25:
 26: ZIP_FILE=$2
 27:
 28: # get the absolute path to the wbnews directory
 29: START_DIR=$PWD
 30: cd $1
 31: WBNEWS_DIR=$PWD
 32:
 33: # go back to where we came from we could use $OLDPWD but lets be safe
 34: cd $START_DIR
 35:
 36: # unzip file into predefined directory
 37: PREDEF_DIR=`dirname $ZIP_FILE`/wbnews_tmp
 38: mkdir -p $PREDEF_DIR
 39: unzip -d $PREDEF_DIR $ZIP_FILE
 40:
 41: # should we make a back up, lets ask our user
 42: HAS_MDUMP=`which mysqldump`
 43: if [ -n $HAS_DUMP ]; then
 44:     read -p "Do you want to make a backup of current installation [Y]:" ans
 45:
 46:     case "$ans" in
 47:         "Y" | "y" | "" )
 48:             read -p "Database name: " dbname
 49:             read -p "Database username: " dbuser
 50:
 51:             ZIP="wbnews_"`date +'%Y-%m-%d %H:%M:%S'`".zip"
 52:             DUMP="wbnews_"`date +'%Y-%m-%d'`".sql"
 53:             mysqldump $dbname --user=$dbuser -p > $DUMP
 54:             find "$WBNEWS_DIR/" | xargs zip -@ "$ZIP"
 55:             find ./ -maxdepth 1 -name `basename $DUMP` | xargs zip -@ "$ZIP"
 56:             if [ 0 -ne $? ] ; then
 57:                 echo "Couldn't back up properly. Exiting"
 58:                 exit 1
 59:             fi
 60:
 61:             rm $DUMP
 62:         ;;
 63:     esac
 64: fi
 65:
 66: cd $PREDEF_DIR
 67:
 68: FILES=`find "$PWD/" -maxdepth 1 | xargs | awk '{print $2}'`
 69:
 70: if [ ! -n $FILES ] ; then
 71:     echo "Found 0 files instead of an expected 1. Exiting"
 72:     exit 1
 73: elif [ ! -d $FILES ]; then
 74:     echo "$FILES is not a directory"
 75:     exit 1
 76: fi
 77:
 78: echo "Entering $FILES"
 79: cd $FILES
 80:
 81: for FILE in `find "$PWD/"` ;
 82: do
 83:     BASE_FILE_NAME=`php -r 'echo str_replace( $_SERVER["argv"][2], "", $_SERVER["argv"][1] );' $FILE $PWD/`
 84:     if [ -d $FILE ] ; then
 85:         if [ ! -d "$WBNEWS_DIR/$BASE_FILE_NAME" ] ; then
 86:             echo "Creating directory $WBNEWS_DIR/$BASE_FILE_NAME"
 87:             mkdir -p "$WBNEWS_DIR/$BASE_FILE_NAME"
 88:         fi
 89:     elif [ -f $FILE ] ; then
 90:         echo "Copying $FILE to $WBNEWS_DIR/$BASE_FILE_NAME"
 91:         cp -v "$FILE" "$WBNEWS_DIR/$BASE_FILE_NAME"
 92:     fi
 93: done
 94:
 95: # run the upgrade script
 96: cd "$WBNEWS_DIR/install"
 97: `php upgrade.php CLI_UPGRADE`
 98: if [ 0 -ne $? ] ; then
 99:     echo "An error occured during the upgrade you should restore your news using the backup made"
100:     exit 1
101: fi
102:
103: # clean up
104: cd $START_DIR
105: rm -rfv "$PREDEF_DIR/"
106: rm -rfv "$WBNEWS_DIR/install"

wbnews_upgrade.sh

You will need to give the file execute permissions using the command below

$ chmod +x wbnews_upgrade.sh

You will need to run the program using the following command

$ /path/to/wbnews_upgrade.sh /absolute/path/to/previous/install /absolute/path/to/upgrade/archive

You will need to stay by your terminal and following the prompts.

If you get An error occured during the upgrade you should restore your news using the backup made it means an error occurred during the upgrade. You should see what happened during the installation and copy the terminal output to ask for assistance.

If the upgrade went successfully all temporary files created during the upgrade will be cleaned and you can continue using WB News

 
manual/installation-upgrade/upgrade.txt · Last modified: 2009/01/24 23:06 by paul
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki