# mco_backup_info

> Internal callback function. This function is used internally by the eXtremeDB backup subsystem to write metadata headers to a backup file. It is passed as a callback during backup operations and should not be called directly by applications.

### For an overview see page Incremental Online Backup in C

### Prototype

        MCO_RET mco_backup_info(
            /*IN*/ mco_uint4 phase,
            /*IN*/ const mco_backup_info_t *info,
            /*IN*/ void *param
        );

### Arguments

`phase`
Backup phase indicator:

- `MCO_BACKUP_PHASE_1` — initial header write (placeholder),
- `MCO_BACKUP_PHASE_2` — final header update with complete metadata.

`info`
Pointer to a `mco_backup_info_t` structure containing backup metadata (label, type, database name, etc.).
`param`
Opaque pointer to a `mco_backup_ctx_t` context structure, cast to `void*`. Contains the file handle, current position, CRC, timestamp, and data transfer counter.

### Description

> This internal function writes backup metadata headers to the backup file in two phases:

> - Phase 1 (`MCO_BACKUP_PHASE_1`): Writes a placeholder header at the beginning of the backup record. The `size` field is set to zero, marking it as incomplete.
> - Phase 2 (`MCO_BACKUP_PHASE_2`): Seeks back to the placeholder header and updates it with the final size, offset, CRC, timestamp, and magic number once all data chunks have been written.

> The function ensures that the backup file contains valid, self-describing records that can be parsed during restore or verify operations.

> It is invoked automatically by the core backup engine (e.g., from `mco_backup()`). Direct use may result in corrupted or unreadable backup files.

> Applications should use high-level APIs such as `mco_backup_create()` instead.

> See Incremental Backup and Restore for more details.

### Return Codes

`MCO_S_OK`
Backup metadata successfully written or updated.
`MCO_E_DISK_WRITE`
Failed to write header data to the backup file.
`MCO_E_DISK_SEEK`
Failed to reposition the file pointer during phase 2 update.
`MCO_E_ILLEGAL_PARAM`
Invalid `phase` value provided.

### Files

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