Firebird Documentation IndexFirebird's nbackup tool → Technical background information
Firebird Home Firebird Home Prev: Backup historyFirebird Documentation IndexUp: Firebird's nbackup toolNext: Document history

Technical background information

Nbackup performs a physical backup of the database pages by copying pages that have been modified since the last backup of the immediately preceding level. A level 0 backup copies all pages, while a level 1 copies only those pages that have been modified after the most recent level 0. To be able to find the modified pages, Firebird uses a marker that is called the SCN (short for page scan). This number is incremented at each backup state change. For each backup with nbackup there are three state changes:

  1. nbak_state_normal (no backup) to nbak_state_stalled (database writes to delta file)

  2. nbak_state_stalled to nbak_state_merge (merging delta file back into database)

  3. nbak_state_merge to nbak_state_normal (no backup)

Note

These three state changes occur even if the backup fails.

The SCN of the database before the start of the backup is recorded together with the backup. The very first backup gets SCN 0, the second 3, etc. This number is independent from the level of the backup. The SCN is used to mark the pages of a database. So for example:

SCN Explanation
0 Pages before any backup
1 Pages written/updated into the delta file during the backup
2 Pages written/updated during the merge of delta file into main backup
3 Pages written/updated after ending first backup+merge

When a level 1 backup is made, nbackup looks for the last level 0 backup and backs up all pages with an SCN higher than the SCN of that level 0 backup (and so on).

A backup and restore with gbak does not restore the content of the RDB$BACKUP_HISTORY table and it resets the SCN of all pages back to 0. The reason for this is that gbak creates a logical backup instead of a physical backup. So a restore using gbak will rewrite the entire database (and can even change the page size). This renders previous backups with nbackup meaningless as a starting point for subsequent backups: you need to start with a fresh level 0.

Prev: Backup historyFirebird Documentation IndexUp: Firebird's nbackup toolNext: Document history
Firebird Documentation IndexFirebird's nbackup tool → Technical background information