GE Smallworld (cold) backup script

Recently I have been certified as a GE Smallworld Administrator.

Smallworld provides you with internal tools and procedures to take hot-backups of a live system but they sometimes are a bit complicated to deploy if you aren’t “fluent” in Magik and, in my case, it was “too much” for my Smallworld environment.

Because it is also possible to totally shutdown the Smallworld process to make a cold-backup (another supported method), I created the following script which, added to the system as a cronjob, allows you to take a full cold-backup of your Smallworld environment.


# SmallWorld backup script v0.001
#       20120220 - martin at mielke dot com
#                  initial version
#                      - full backup
#                      - compressed tarball
#                      - transfer to backup server

# Some useful definitions
year=`date +%Y`
month=`date +%m`
day=`date +%d`

# Define the variables below according to your SmallWorld environment:
#       smDir = root directory of the local SmallWorld installation
#       smTmp = used for temporary operations, it's safe to leave it so
#       backuptarget = remote user and hostname - you must be able to use ssh keys
#       backupdir= backup directory on the remote host
#    init_script = SmallWorld init script

stopPNI() {
        echo " - Stopping SmallWorld instances..."
        $init_script stop
        echo " - Cleaning up temporary JOU files..."
        find $smDir -type f -name '*.jou' -exec rm -f {} \;

startPNI() {
        echo " - Starting SmallWorld..."
        $init_script start
        exit 0

# main()

# first we need to stop SmallWorld

# This line actually makes the full backup 
tar -zcf $smTmp/SmallWorld-$timestamp.tar.gz $smDir

# we could start SmallWorld here ...but we won't :-)
# before that we'll copy the tar.gz file to our remote backup server
scp -p $smTmp/SmallWorld-$timestamp.tar.gz $backuptarget:$backupdir

# Some clean-up...
rm -f $smTmp/SmallWorld-$timestamp.tar.gz

# start SmallWorld instance

Disclaimer: this is provided on an “AS IS” basis. The author is not to be held responsible for any damage this script and its usage might cause.

The script is very straight-forward and doesn’t make many checks but it works for the environment I created it for. Feel free to tailor it to your own needs.