Backing Up Directory or Information Store Data

The following procedures outline a typical methodology to programmatically back up the directory and information store databases. The first procedure explains how to perform a full backup. The second procedure explains differential and incremental backups.

    To perform a full backup of data
  1. Call HrBackupPrepare to get a client-side context handle and to specify the backup method. In this call, specify that the type of backup to be performed is FULL.
  2. Call HrBackupGetDatabaseNames to get a list of the files to backup. These files cannot be backed up using normal file copy routines. They must be backed up using HrBackupOpenFile and HrBackupRead. Each file name in the list is preceded by a one-byte token (defined in EDBBCLI.H) that indicates the type of file. This token should be saved along with the data backup so it can be matched with the proper directory returned by HrRestoreGetDatabaseLocations at restore time. For more information, see Backup File Locations.
  3. Call HrBackupOpenFile to open the file for each file in the list returned by HrBackupGetDatabaseNames. When the file has been successfully opened, call HrBackupRead to read the data in that file. When the file has been read and stored to the desired location, call HrBackupClose.
  4. Release the memory returned by HrBackupGetDatabaseNames by calling BackupFree on it.
  5. Call HrBackupGetBackupLogs to get a list of transaction log files to back up. These files are all located in the current log file path (configurable in the Microsoft Exchange Server Administrator program). For a full backup, one of the files returned in this list will be a patch file that contains the changes that occurred to the database while the backup was running. As with the files returned by HrBackupGetDatabaseNames (see step 2), each file returned by HrBackupGetBackupLogs will be preceded by a token indicating the file type that should be saved and matched with tokens returned by HrRestoreGetDatabaseLocations at restore time.
  6. Call HrBackupOpenFile, HrBackupRead, and HrBackupClose for this list of files in the same manner as step 3.
  7. Release the memory returned by HrBackupGetBackupLogs by calling BackupFree on it.
  8. Call HrBackupTruncateLogs to delete the log files.
    To perform differential or incremental backup of data
  1. Call HrBackupPrepare to get a client-side context handle and to specify the backup method. In this call, specify that the type of backup to be performed is Logs Only (for differential or incremental). Under certain situations, a differential or incremental backup may not be possible in certain situations such as when a full has not been performed because a defragmentation or migration has been performed on the database, or transaction log files are out of sequence on the disk, or Circular Logging is enabled on the database. If HrBackupPrepare fails for the type of backup you wish to perform, a full backup should be performed before retrying a differential or incremental backup.
  2. Call HrBackupGetBackupLogs to get a list of transaction log files to backup. These files are all located in the current log file path (configurable in Microsoft Exchange Administrator). Each file returned by HrBackupGetBackupLogs will be preceded by a token indicating the file type, which should be saved and matched with tokens returned by HrRestoreGetDatabaseLocations at restore time.
  3. Call HrBackupOpenFile, HrBackupRead, and HrBackupClose for this list of files.
  4. Release the memory returned by HrBackupGetBackupLogs by calling BackupFree on it.
  5. This step is performed only for incremental (not differential) backups

    Call HrBackupTruncateLogs to delete the log files.

    Important Do not call HrBackupTruncateLogs if the backup is unsuccessful. If you call HrBackupTruncateLogs and the backup is not successful, your database will not be recoverable if it is interrupted before a clean shutdown.

  6. Call HrBackupEnd to release the backup context.