Incremental Backup and Restore in Python

Incremental online backup can be performed while normal database activity proceeds uninterrupted using the methods described below. Alternatively, there are APIs to save a database image or class data. (See the Data Export and Import page for further details.)

BACKUP

The eXtremeDB database backup and restore functionality is implemented by the Python class Backup which is used to backup and restore database data to/from an external file. The class is defined with the following constants (which correspond to enum mco_backup_type, enum mco_backup_flags in struct mco_db_params_t in the C API :

 
    class Backup(object):
        MCO_BACKUP_TYPE_AUTO        = 0
        MCO_BACKUP_TYPE_SNAPSHOT    = 1
        MCO_BACKUP_TYPE_INCREMENTAL = 2
         
        MCO_BACKUP_FLAG_COMPRESSED  = 1
        MCO_BACKUP_FLAG_ENCRYPTED   = 2
         

The backup and restore methods are defined as follows:

createBackup()

     
    def createBackup(filename = None, label = None, type = MCO_BACKUP_TYPE_AUTO,
                        compression_level = 0, cipher = None)
     

restoreBackup()

     
    def restoreBackup(filename = None, label = None, cipher = None)
     

listBackup()

In addition It is possible to retrieve information from a backup file with method listBackup() defined as follows:

 
    def listBackup(filename = None)
     

The listBackup() method returns a list of Python objects with fields Magic, ProtocolVersion, Type, Flags, BackupNo, Timestamp, Size, Offset, Crc, TransNo, MemPageSize, DiskPageSize, NPagesTotal, DbName, Label which correspond to the to struct mco_backup_info_t in struct mco_db_params_t in the C API :

Additional backup parameters

Further backup parameters can be specified in the Database.Parameters used for the exdb.open_database() method that map to the corresponding parameters in the C API:

     
    def open_database(..., 
                backup_map_size = 0, backup_min_pages = 0, 
                backup_max_passes = 10, backup_map_filename = None)
     

And, for SQL connections, these parameters are defined as follows:

     
    class SqlOpenParameters(object):
        def __init__(..., backupMapSize = 0, backupMinPages = 0,
        backupMaxPasses = 10, backupMapFile = None)