FLAIM: Database Backup/Restore

- Main Page
- Modules
- Classes
- Files

# Database Backup/Restore
[Database Functions]

## Functions
FLMEXP RCODE FLMAPI | FlmDbBackupBegin (HFDB hDb, FBackupType eBackupType, FLMBOOL bHotBackup, HFBACKUP *phBackup)
| Begin a database backup.
FLMEXP RCODE FLMAPI | FlmBackupGetConfig (HFBACKUP hBackup, eBackupGetConfigType eConfigType, void *pvValue1, void *pvValue2=NULL)
| Get backup configuration on a backup that was started by FlmDbBackupBegin.
FLMEXP RCODE FLMAPI | FlmDbBackup (HFBACKUP hBackup, const char *pszBackupPath, const char *pszPassword, BACKER_WRITE_HOOK fnWrite, STATUS_HOOK fnStatus, void *pvAppData, FLMUINT *puiIncSeqNum)
| Perform a backup that was started by FlmDbBackupBegin.
FLMEXP RCODE FLMAPI | FlmDbBackupEnd (HFBACKUP *phBackup)
| End a backup that was started by FlmDbBackupBegin().
FLMEXP RCODE FLMAPI | FlmDbRestore (const char *pszDbPath, const char *pszDataDir, const char *pszBackupPath, const char *pszRflDir, const char *pszPassword, F_Restore *pRestoreObj)
| Restore a database from a backup.

## Function Documentation

FLMEXP RCODE FLMAPI FlmBackupGetConfig | ( | HFBACKUP | hBackup,
|  | eBackupGetConfigType | eConfigType,
|  | void * | pvValue1,
|  | void * | pvValue2 = `NULL`
| ) |

  | Get backup configuration on a backup that was started by FlmDbBackupBegin. Parameters:
  hBackup | Backup handle that was returned from FlmDbBackupBegin().
  eConfigType | Type of configuration information being requested.
  pvValue1 | Configuration information is returned here. See documentation on eBackupGetConfigType for details.
  pvValue2 | Configuration information is returned here. See documentation on eBackupGetConfigType for details.

FLMEXP RCODE FLMAPI FlmDbBackup | ( | HFBACKUP | hBackup,
|  | const char * | pszBackupPath,
|  | const char * | pszPassword,
|  | BACKER_WRITE_HOOK | fnWrite,
|  | STATUS_HOOK | fnStatus,
|  | void * | pvAppData,
|  | FLMUINT * | puiIncSeqNum
| ) |

  | Perform a backup that was started by FlmDbBackupBegin. Parameters:
  hBackup | Backup handle that was returned from FlmDbBackupBegin().
  pszBackupPath | This specifieds the directory where FlmDbBackup() is to create a backup file set for the backed up data. The files in the backup set will be named 00000001.64, 00000002.64, etc. This parameter is only used if the fnWrite parameter is NULL. If fnWrite is non-NULL, all backed up data will be passed to that function to be written to a backup medium.
  pszPassword | Password used to shroud the database encryption key in the backup. If NULL, the database encryption key will remain wrapped in the NICI local storage key. A NULL password means that the backup can only be restored to the same server the backup was taken from, because the database key can only be unwrapped using the NICI local storage key of that server.
  fnWrite | This is the callback function that FlmDbBackup() will call to write data to the backup medium (tape, disk, etc.). If NULL, FlmDbBackup() will create a backup file set in the directory specified by the pszBackupPath parameter. If a callback function is specified, the application will also want to have a corresponding implementation for the F_Restore class so that it can read data back during a FlmDbRestore() operation.
  fnStatus | This is a callback function that FlmDbBackup() calls to report backup progress.
  pvAppData | Pointer to application data. This pointer will be passed into the fnWrite callback function as well as the fnStatus callback function whenever they are called.
  puiIncSeqNum | If the backup is an incremental backup, this returns the incremental backup sequence number.

FLMEXP RCODE FLMAPI FlmDbBackupBegin | ( | HFDB | hDb,
|  | FBackupType | eBackupType,
|  | FLMBOOL | bHotBackup,
|  | HFBACKUP * | phBackup
| ) |

  | Begin a database backup. Parameters:
  hDb | Database handle.
  eBackupType | Type of backup being requested.
  bHotBackup | Specifies whether backup should be "hot" or "warm". A hot backup is one where the database is not locked during the backup. A "warm" backup is one where the database is locked during during the backup to prevent any updates from happening.
  phBackup | A handle to a database backup object is returned here. This object is basically used to maintain state during the backup. It is passed into FlmBackupGetConfig(), FlmDbBackup(), and FlmDbBackupEnd().

FLMEXP RCODE FLMAPI FlmDbBackupEnd | ( | HFBACKUP * | phBackup | ) |

  | End a backup that was started by FlmDbBackupBegin(). This is necessary to free any resources (such as memory) that may have been allocated during the backup. This should always be called if FlmDbBackupBegin() is successful, even if FlmDbBackup() is never called, or if it fails with an error code. Parameters:
  phBackup | Pointer to backup handle that is to be freed.

FLMEXP RCODE FLMAPI FlmDbRestore | ( | const char * | pszDbPath,
|  | const char * | pszDataDir,
|  | const char * | pszBackupPath,
|  | const char * | pszRflDir,
|  | const char * | pszPassword,
|  | F_Restore * | pRestoreObj
| ) |

  | Restore a database from a backup. Parameters:
  pszDbPath | Name of database FlmDbRestore() is to create from the backup.
  pszDataDir | Directory where the restored database's data files are to be created.
  pszBackupPath | Directory where backup file set is located. If NULL, the backup data is read by calling various methods on the F_Restore object specified in the pRestoreObj parameter. Otherwise, the backup data is read from files in this directory that are named 00000001.64, 00000002.64, etc. These are files that would have been created by FlmDbBackup() if it was passed a backup path instead of a writer callback function.
  pszRflDir | This is only used if pRestoreObj is NULL and pszBackupPath is non-NULL. It specifies the directory where RFL files are located. If possible, FlmDbRestore() will attempt to replay any RFL files that were created after the backup was taken. NOTE: The RFL files are actually in a subdirectory to the directory specified in this parameter. The subdirectory name is <dbname>.rfl, where dbname is the base name found in pszDbPath. For example, the dbname for abc/xyz.db would be xyz.db. Thus, the subdirectory would be xyz.rfl. If pszRflDir is NULL, FlmDbRestore() assumes that the RFL directory is the same as the directory for pszDbPath. <dbname>.rfl is still assumed to be the subdirectory.
  pszPassword | Password for unshrouding the database key. This should be the same password that was used to create the backup - i.e. the password that was passed into FlmDbBackupBegin().
  pRestoreObj | Pointer to the object whose methods will be called to read data from the backup medium. This object should know how to read data from the backup medium. It should understand whatever formatting was used by the fnWrite callback function (see FlmDbBackup()) to write the data out to the backup medium.