'Update an existing database, called during initialisation.
A timestamped backup is also created prior to attempting the update.'

@commitandrollback
def updateDb(self, cur, version):

    if (version > Fail2BanDb.__version__):
        raise NotImplementedError('Attempt    to    travel    to    future    version    of    database    ...how    did    you    get    here??')
    self._dbBackupFilename = ((self.filename + '.') + time.strftime('%Y%m%d-%H%M%S', MyTime.gmtime()))
    shutil.copyfile(self.filename, self._dbBackupFilename)
    logSys.info('Database    backup    created:    %s', self._dbBackupFilename)
    if (version < 2):
        cur.executescript(('BEGIN    TRANSACTION;CREATE    TEMPORARY    TABLE    logs_temp    AS    SELECT    *    FROM    logs;DROP    TABLE    logs;%s;INSERT    INTO    logs    SELECT    *    from    logs_temp;DROP    TABLE    logs_temp;UPDATE    fail2banDb    SET    version    =    2;COMMIT;' % Fail2BanDb._TABLE_logs))
    if (version < 3):
        cur.executescript(('BEGIN    TRANSACTION;CREATE    TEMPORARY    TABLE    bans_temp    AS    SELECT    jail,    ip,    timeofban,    600    as    bantime,    1    as    bancount,    data    FROM    bans;DROP    TABLE    bans;%s;INSERT    INTO    bans    SELECT    *    from    bans_temp;DROP    TABLE    bans_temp;COMMIT;' % Fail2BanDb._TABLE_bans))
    if (version < 4):
        cur.executescript(('BEGIN    TRANSACTION;%s;UPDATE    fail2banDb    SET    version    =    4;COMMIT;' % Fail2BanDb._TABLE_bips))
    cur.execute('SELECT    version    FROM    fail2banDb    LIMIT    1')
    return cur.fetchone()[0]
