klenwell information services : WikkaUpgrade134

Wikka Upgrades

return to WikkaUpgradeCore

Version 1.3.4 Upgrade

New Version: 1.3.4
Previous Version: 1.3.2-p7
Date: 2013.03.06
Duration: 6-8 hours


This update took as long as it did because I wanted to create a Fabric script that would download this, my production, site and database and install it on my local development server. From there, I could install the update. Then I could run my Fabric script again to upload the update code and datebase back here.

Update Steps

  1. Clone Production Code and Database (fab)
  2. Install Latest Source Code (fab)
  3. Complete Upgrade Wizard on Local Development Server
  4. Check Wikka Config File Change (fab)
  5. Check Config Directory (Menu File) Changes
  6. Test Site Locally
  7. Upload Updated Code and Database (Fab)

Fab Commands

I did not include my whole Fabric script here as it contains some private information. But here are some key functions from that script:

Backup Production Database

from fabric.api import (local, sudo, get)
from os.path import join as pathjoin

def wiki_back_db(archive_dir, email_address):
    """backup production database, email as attachment to given address, and
    save to archive_path"
    global datestamp
    global mysqldump_user, mysqldump_pass, live_wiki_db_name
    global email_subject_for_db_backup, email_subject_for_db_backup
    dump_file = 'db-%s-%s.bz2' % (live_wiki_db_name, datestamp)
    dump_path = '/tmp/%s' % (dump_file)
    archive_path = pathjoin(archive_dir, dump_file)
    # dump database
    # mysqldump DB_NAME | bzip2 > /tmp/DB_NAME-$(date +%Y%m%d).bz2
    mysqldump_f = 'mysqldump -u%s -p%s %s | bzip2 > %s'
    mysqldump = mysqldump_f % (mysqldump_user, mysqldump_pass,
        live_wiki_db_name, dump_path)
    sudo(mysqldump, shell=False)
    # download
    get(dump_path, dump_path)
    # email as attachment
    to_ = email_address
    subject = email_subject_for_db_backup
    body = email_template_for_db_backup % dict(
    email_attachment(to_, subject, body, dump_path)
    # move to archive path
    local('mv %s %s' % (dump_path, archive_path))
    # cleanup
    sudo('rm -f %s' % (dump_path), shell=False)
    return archive_path

Backup Production Source Code

from fabric.api import (sudo, get)
from os.path import join as pathjoin

def wiki_back_code(archive_dir, email_address):
    """backup production source code, email as attachment to given address,
    and save to archive_dir"
    # globals
    global datestamp, timestamp
    global live_wiki_root
    # parameters
    remote_wd = '/tmp/wiki-back-%s' % (datestamp)
    tar_file = 'wiki-%s.tar.gz' % (timestamp)
    archive_path = pathjoin(archive_dir, tar_file)
    # create remote working dir
    mkdir = 'mkdir -p %s' % (remote_wd)
    sudo(mkdir, shell=False)
    # copy wiki root dir to working dir
    cp = 'cp -R %s %s' % (live_wiki_root, remote_wd)
    sudo(cp, shell=False)
    # tar wiki dir
    tar_dir_target = pathjoin(remote_wd, basename(live_wiki_root))
    tar_file_path = pathjoin(remote_wd, tar_file)
    tar = tar_dir(tar_dir_target, tar_file_path)
    sudo(tar, shell=False)
    # download tar file
    get(tar_file_path, archive_dir)
    # mail
    to_ = email_address
    subject = email_subject_for_code_backup
    body = email_template_for_code_backup % dict(tar_file=tar_file)    
    attachment = archive_path
    email_attachment(to_, subject, body, attachment)
    # cleanup remote
    rm = 'rm -Rf /tmp/is'
    sudo(rm, shell=False)
    # return archive file
    return archive_path