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
dbFileThe path and filename for the backup database file.logFileThe path and filename for the backup log file.nThreadsThe 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_delayparameter passed tomco_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
interruptedflag (see pageMcoSqlEngine). This flag is cleared before execution of each SQL query, but whenfileBackup()is called directly, this flag is not cleared. So it is recommended to first callSqlEngine::setIterrupted(false)before starting the file backup and callSqlEngine::setIterrupted(true)if it is necessary to stop the current backup.Return Codes
voidNo 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(); }