fileBackup

Perform a file backup for a persistent database.

For an overview see page File_Backup

Prototype

     
    void fileBackup(char const *dbFile, char const* logFile, int nThreads = 1);
     

Arguments

dbFile The path and filename for the backup database file
logFile The path and filename for the backup log file
nThreads The number of threads to perform the file copy operation

Description

This method allows applications to copy the database and log file for a persistent database. The database can then be "restored" by simply specifying these backup files in the device definition and opening the database in the normal way. File backup can be the most efficient way of creating a backup of a disk database because it copies data at the file level, sequentially, without interpreting the content of the pages. Please see the File Backup page for further details. (See also C API mco_disk_backup().)

The file_backup_delay parameter passed to mco_db_open_dev() can be adjusted to specify the delay in milliseconds between writing backup blocks in order to minimize backup impact on performance.

It is possible to interrupt the file backup procedure by explicitly setting the interrupted flag (see page McoSqlEngine). This flag is cleared before execution of each SQL query, but when fileBackup() is called directly, this flag is not cleared. So it is recommended to first call SqlEngine::setIterrupted(false) before starting the file backup and call SqlEngine::setIterrupted(true) if it is necessary to stop the current backup.

Return Codes

void No value returned

Example

 
    Application snippet:
            
     
    const char * dbname = "SimpleDb";
     
    int main(int argc, char* argv[])
    {
        mco_db_h db;
        MCO_RET rc;
        mco_device_t       dev[4];
        McoSqlEngine engine;
        McoSqlOpenParameters params;
        char * db_file = "SimpleDb_backup.dbs";
        char * log_file = "SimpleDb_backup.log";
                 
        ...
        engine.open(params);
        ...
        engine.fileBackup( db_file, log_file, 1);
            
        ...
        engine.close();
    }