mco_backup_restore
接口适用于实时数据库 RT 。
从指定文件中的最新快照记录开始,恢复备份记录,直至指定标签为止。
此功能通过从最新快照记录读取备份直至指定标签来恢复备份(由文件名和标签指定)。在此过程中可能会使用许多增量备份记录。请注意,数据库属性(大小、页大小等)必须与备份文件中的属性相匹配。无法将数据库备份到具有不同属性的数据库中。
有关概述,请参阅页面C中的增量备份和恢复。
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
)
参数
con
mco_db_h
用于获取备份文件中数据库名称的数据库连接。
file_name
char const*
要列出的备份文件的名称。
label
char const*
用于恢复的备份标签。
cipher
char const*
用于解密备份的可选密码。
err_buf
char*
错误描述缓冲区。
err_buf_sz
unsigned int *
在输入时,它指定了 err_buf
的大小。在返回时,它包含写入缓冲区的字符数。如果 err_buf_sz
为 null
,则该例程返回 MCO_E_ILLEGAL_PARAM
。
返回
MCO_S_OK
恢复成功了。
MCO_E_DISK_OPEN
无法打开备份文件。
MCO_E_ILLEGAL_PARAM
以下错误情况之一:
- 备份文件中的增量备份顺序错乱。
- 备份文件中未找到标签。
- 未提供备份加密密钥。
MCO_E_DISK_SEEK
在备份文件中设置位置失败。
示例
{
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);
}
文件
- 头文件:
mco.h
- 源文件:
mcobackup.c
- 库:
libmcobackup.a