mco_async_backup_start

Start the asynchronous backup process.

For an overview see page Incremental Online Backup in C

Prototype

    MCO_RET mco_async_backup_start(
        /*IN*/ mco_db_h connection,
        /*IN*/ unsigned int backup_cycle_delay_msec,
        /*IN*/ const char *file_name,
        /*IN*/ const char *label,
        /*IN*/ mco_backup_type type,
        /*IN*/ int compression_level,
        /*IN*/ const char *cipher
    );

Arguments

connection
Database connection handle used to initiate the backup cycle.
backup_cycle_delay_msec
Delay (in milliseconds) between consecutive backup operations in the cycle.
file_name
Path and name of the backup file to which records will be written.
label
Optional prefix for backup record labels. The system appends a 5-digit sequence number (e.g., "mylabel00001"). If NULL, records are named "AUTOBACKUP#####".
type
Type of backup record to create. One of the following:
    typedef enum {
        MCO_BACKUP_TYPE_AUTO,
        MCO_BACKUP_TYPE_SNAPSHOT,
        MCO_BACKUP_TYPE_INCREMENTAL
    } mco_backup_type;
compression_level
Compression level (0–9). Use 0 to disable compression; higher values increase compression ratio at the cost of CPU usage.
cipher
Optional encryption key for the backup. May be NULL for unencrypted backups.

Description

This function starts a background thread that periodically creates backup records according to the specified parameters. It stores the backup cycle context in the database header and establishes its own internal database connection (which does not include a sniffer context).

Only one asynchronous backup or restore operation can run per database at a time.

See Incremental Backup and Restore for more details.

Return Codes

MCO_S_OK
Asynchronous backup cycle started successfully.
MCO_E_BACKUP
Another backup or restore operation is already active, or the backup thread could not be created.
MCO_E_ILLEGAL_PARAM
One or more input parameters are invalid (e.g., unsupported type, negative delay, etc.).
MCO_ERR_DB_NOMEM_HEAP
Insufficient space in the database heap to store the backup cycle context.

Example

    {
        const char *db_name = "myDb";
        mco_db_h con;
        MCO_RET rc;

        rc = mco_db_connect(db_name, &con);
        if (rc != MCO_S_OK) {
            /* handle connection error */
        }

        rc = mco_async_backup_start(
            con,
            500,                    // backup every 500 ms
            "file.backup",
            "label",                // → "label00001", "label00002", ...
            MCO_BACKUP_TYPE_AUTO,
            0,                      // no compression
            NULL                    // no encryption
        );
        if (rc != MCO_S_OK) {
            /* handle backup start error */
        }
    }

Files

Header file:
mco.h
Source file:
mcobackup.c
Library:
libmcobackup.a