Create a backup record of the database.
void mco_backup_create( /*IN*/ mco_db_h con,
/*IN*/ char const* file_name,
/*IN*/ char const* label,
/*IN*/ mco_backup_type type,
/*IN*/ int compression_level,
/*IN*/ char const* cipher,
/*IN*/ char* err_buf,
/*IN-OUT*/ unsigned int * err_buf_sz);
con
file_name
label
type
The type of backup record; one of the following:
typedef enum {
MCO_BACKUP_TYPE_SNAPSHOT,
MCO_BACKUP_TYPE_INCREMENTAL,
MCO_BACKUP_TYPE_AUTO
} mco_backup_type;
where type has the following effect:
MCO_BACKUP_TYPE_SNAPSHOT — An image of the entire database; must be done at least onceMCO_BACKUP_TYPE_INCREMENTAL — A partial image of the database. Contains only differences in the
database content between two consecutive backup records.MCO_BACKUP_TYPE_AUTO — Automatic selection of a snapshot or incremental record depending
on the content of the backup file. If there is no snapshot in the file yet the backup process will create one;
otherwise a partial backup record is createdcompression_level
cipher
err_buf
err_buf_sz
err_buf. On return it contains the number of characters written into the buffer.
If err_buf_sz is null the routine returns MCO_E_ILLEGAL_PARAM.This function creates a backup record of the database. The record can be full (a snapshot) or partial (an incremental record)
depending on the type specified. Note that it is necessary to have at least one snapshot in a backup file. The backup
process does not block database processing so the application is allowed to run transactions normally while the backup is in progress.
The backup process blocks the database for only a short period of time when the normal data processing is paused or after a set number of
transactions as specified by the backup parameters backup_min_pages
and backup_max_passes passed to
mco_db_open_dev() on database creation.
(See the Incremental Backup and Restore
page for further details.)
MCO_S_OK
MCO_E_ILLEGAL_PARAM
MCO_MAX_BACKUP_LABEL_SIZE)MCO_E_DISK_OPEN
MCO_E_DISK_SEEK
fseek() failed, probably due to backup file integrity failureMCO_E_DISK_VERSION_MISMATCH
{
const char *db_name = "myDb";
mco_db_h con;
MCO_RET rc;
char *filename = "backup.bak";
char label[MAX_LABEL_SIZE];
int duration_msec = 1000;
int msec;
do
{
rc = mco_db_connect( db_name, &con );
if ( MCO_S_OK == rc )
{
msec = (int)MCO_SYSTEM_GET_CURRENT_TIME_MSEC();
sprintf(label, "Backup at %d msec", msec);
/* backup the database */
rc = mco_backup_create(con, filename, label,
MCO_BACKUP_TYPE_AUTO, 1, NULL, NULL, NULL);
sleep_msec(duration_msec);
mco_db_disconnect(con);
}
} while (rc == MCO_S_OK && !stop);
}