'backup ?DB? FILE: Backup DB (default "main") to FILE
Copies the contents of the current database to FILE
overwriting whatever was in FILE.  If you have attached databases
then you can specify their name instead of the default of "main".
The backup is done at the page level - SQLite copies the pages
as is.  There is no round trip through SQL code.'

def command_backup(self, cmd):

    dbname = 'main'
    if (len(cmd) == 1):
        fname = cmd[0]
    elif (len(cmd) == 2):
        dbname = cmd[0]
        fname = cmd[1]
    else:
        raise self.Error('Backup    takes    one    or    two    parameters')
    out = apsw.Connection(fname)
    b = out.backup('main', self.db, dbname)
    try:
        while (not b.done):
            b.step()
    finally:
        b.finish()
        out.close()
