# mco_translog_db_save

> Save a database image to an external file and truncate a transaction log.

### Prototype

        MCO_RET	mco_translog_db_save(	/*IN*/ void * stream_handle,
                    /*IN*/ mco_stream_write output_stream_writer,
                    /*IN*/ mco_db_h db);

### Arguments

stream_handle | Handle to the output stream
output_stream_writer | Handler function called by the runtime to format output
db | The database handle

### Description

> This function is used to stream an eXtremeDB database to permanent storage. Used together with `mco_db_load()` an application can implement robust backup and restore capability.

> It is the application’s responsibility to open the output stream, in the proper mode to stream binary data, and to ensure that there is adequate space at the destination to hold the database. Indexes are not streamed; they will be rebuilt when the database is reloaded. See the control structure stream writer for further details.

> With release 7.1, eXtremeDB has simplified the `mco_db_save()` and `mco_db_load()` APIs and the former variants `mco_inmem_save()`, `mco_inmem_load()`, `mco_disk_save()`, `mco_disk_load()` and `mco_disk_load_file()` have been deprecated.

> The simplified version of `mco_db_save()` and `mco_db_load()` allow the application to stream database contents to and from a persistent media file, socket, or pipe, with `CRC` checking, “binary schema evolution” (`BSE`) support and buffering to allow interruption and restart of the streaming process. Database snapshot files are also encrypted if `mco_db_params_t::cipher_key` is specified.

### Return Codes

MCO_S_OK | The database was closed successfully
MCO_E_NOINSTANCE | The specified database is not opened
MCO_E_WRITE_STREAM | Error writing to output stream

### Example

See TLog_Checkpoint

### Files

Header file:
mcolog.h
Source file:
mcolog.c
Library:
libmcolog.a