Perform a file backup for a persistent database.
For an overview see page File_Backup
MCO_RET mco_disk_backup( /*IN*/ mco_db_h db, /*IN*/ char const* db_backup_path, /*IN*/ char const* log_backup_path);
db | The database handle that was established by mco_db_connect() |
db_backup_path | The path and filename for the backup database file |
log_backup_path | The path and filename for the backup log file |
This function 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. Note that the application performing a file backup must use log type
REDO_LOG.
The
parameter passed to
file_backup_delay
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.
MCO_S_OK | File backup completed successfully. |
MCO_E_DISK_INCOMPATIBLE_LOG_TYPE | Invalid database log type. Only REDO_LOG is supported by the backup |
MCO_E_DISK_OPEN | Unable to open backup files* |
MCO_E_DISK_READ | Unable to read the database or the log file* |
MCO_E_DISK_WRITE | Unable to write the database backup or log file* |
MCO_E_DISK_CLOSE | Unable to close the log or the database backup file* |
*These errors indicate a file system failure or possibly invalid file names
Application snippet: const char * dbname = "SimpleDb"; int main(int argc, char* argv[]) { mco_db_h db; MCO_RET rc; mco_device_t dev[4]; mco_db_params_t db_params; char * db_file = "SimpleDb_backup.dbs"; char * log_file = "SimpleDb_backup.log"; ... rc = mco_db_open_dev( dbname, simple_get_dictionary(), dev, 4, &db_params ); if ( MCO_S_OK != rc ) { rc = mco_db_connect( dbname, &db ); ... rc = mco_disk_backup( db, db_file, log_file); ... } }