mco_backup_restore

Restore backup records starting from the latest snapshot record in the specified file up to the specified label.

For an overview see page Incremental Online Backup in C

Prototype

 
    void	mco_backup_restore(	/*IN*/ mco_db_h con,
                    /*IN*/ char const* file_name,
                    /*IN*/ char const* label,
                    /*IN*/ char const* cipher,
                    /*IN*/ char* err_buf,
                    /*IN-OUT*/ unsigned int * err_buf_sz)
 

Arguments

con A database connection used to restore the backup record into the database
file_name The name of the backup file to use for the restoration procedure
label The backup's label to restore
cipher An optional cipher to decrypt the backup
err_buf A buffer for error description
err_buf_sz On input this specifies the size of 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

Description

This function restores the backup (specified by file_name and label) by reading the backup from the latest snapshot record up to the specified label. Many incremental backup records may be used during the procedure. Note that the database properties (size, page size, etc.) have to match those in the backup file. It is not possible to backup a database and restore it into a database with different properties. (See the Incremental Backup and Restore page for further details.)

Return Codes

MCO_S_OK The restore was successful
MCO_E_DISK_OPEN Could not open the backup file
MCO_E_ILLEGAL_PARAM

One of the following error conditions:

  • Incremental backups in the backup file are out of order
  • The label was not found in the backup file
  • The backup cipher key was not given
MCO_E_DISK_SEEK Failure to set the position in the backup file

Example

     
    {
        mco_db_h con;
        MCO_RET rc;
        char * filename = “backup.bak”;
        char * label = “a label”;
 
        /* connect to a database */
        rc = mco_db_connect( db_name, &con );
 
        /* restore the database */
        rc = mco_backup_restore( con, filename, label, 0, 0);
    }
     

Files

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