Library Version 12.1.6.2

DbEnv::dbbackup()
Prev | Chapter 5. The DbEnv Handle | Next

## DbEnv::dbbackup()

    #include <db_cxx.h>

    int
    DbEnv::dbbackup(const char *dbfile, const char *target,
                    u_int32_t flags);

The `DbEnv::dbbackup()` method performs a hot backup of a single database file contained within the environment.

To back up an entire environment, use the DbEnv::backup() method.

This method's default behavior can be changed by setting backup callbacks. See DbEnv::set_backup_callbacks() for more information. Additional tuning parameters can also be set using the DbEnv::set_backup_config() method.

The `DbEnv::dbbackup()` method may only be called after the environment handle has been opened.

The `DbEnv::dbbackup()` method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Parameters

#### dbfile

Identifies the database file that you want to back up.

#### target

Identifies the directory in which the back up will be placed. This target must exist; otherwise this method exits with an `ENOENT` error return.

Note that if the backup callbacks are set, then the value specified to this parameter is passed on to the `open_func()` callback. If this parameter is NULL, then the target must be specified directly to the `open_func()` callback.

#### flags

The flags parameter must be set to 0 or the following value:

- `DB_EXCL`

  Return an `EEXIST` error if a target backup file already exists.

### Errors

The `DbEnv::dbbackup()` method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

#### EEXIST

`DB_EXCL` was specified for the `flags` parameter, and an existing target file was discovered when attempting to back up a source file.

#### ENOENT

The target directory does not exist.

#### EINVAL

An invalid flag value or parameter was specified.

### Class

DbEnv

### See Also

Database Environments and Related Methods

Prev | Up | Next
DbEnv | Home | DbEnv::dbremove()