Bacula dbcheck

After many years of use or customizations Bacula (e.g.: rename or disable clients, filesets etc.) it is likely that your catalog has orphaned entries: information that remains in the database but do not have relating indexes to existing retained backups. The same thing may happen to restore jobs information  that may be no longer needed if you could validate the restore contents. This behavior can leave the more complex management of Bacula and bring some impact on the catalog performance.

Fortunately there is the dbcheck application that is installed with the Bacula Director can be used to clean those entries. The main requirement for this command is only to inform the Bacula working directory, set in the bacula-dir.conf.

Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>]

To estimate the amount of entries that can be discarded can be used the -b option . It is likely dbcheck asks to creating new indexes to optimize its routines:

[root@localhost bacula]# dbcheck -b /var/spool/bacula/
Checking for Paths without a trailing slash
Found 1 bad Path records.
Checking for Filenames with a trailing slash
Found 0 bad Filename records.
Checking for duplicate Filename entries.
Found 0 duplicate Filename records.
Checking for duplicate Path entries.
Found 0 duplicate Path records.
Checking for orphaned JobMedia entries.
Checking for orphaned File entries. This may take some time!
Note. Index over the PathId column not found, that can greatly slow down dbcheck.
Create temporary index? (yes/no): yes
Create temporary index... This may take some time!
Checking for orphaned Path entries. This may take some time!
Found 9 orphaned Path records.
Drop temporary index.
Note. Index over the FilenameId column not found, that can greatly slow down dbcheck.
Create temporary index? (yes/no): yes
Create temporary index... This may take some time!
Checking for orphaned Filename entries. This may take some time!
Found 140 orphaned Filename records.
Drop temporary index.
Checking for orphaned FileSet entries. This takes some time!
Found 3 orphaned FileSet records.
Checking for orphaned Client entries.
Found 1 orphaned Client records.
Checking for orphaned Job entries.
Found 0 orphaned Job records.
Checking for Admin Job entries.
Found 0 Admin Job records.
Checking for Restore Job entries.
Found 8 Restore Job records.

And finally to remove orphaned entries from the database use the -f (fix):

[root@localhost bacula]# dbcheck -f /var/spool/bacula/
Hello, this is the database check/correct program.
Modify database is on. Verbose is off.
Please select the function you want to perform.

1) Toggle modify database flag
2) Toggle verbose flag
3) Repair bad Filename records
4) Repair bad Path records
5) Eliminate duplicate Filename records
6) Eliminate duplicate Path records
7) Eliminate orphaned Jobmedia records
8) Eliminate orphaned File records
9) Eliminate orphaned Path records
10) Eliminate orphaned Filename records
11) Eliminate orphaned FileSet records
12) Eliminate orphaned Client records
13) Eliminate orphaned Job records
14) Eliminate all Admin records
15) Eliminate all Restore records
16) All (3-15)
17) Quit
Select function number: 12
Checking for orphaned Client entries.
Found 1 orphaned Client records.
Deleting 1 orphaned Client records.

Disponível em: pt-brPortuguês (Portuguese (Brazil)) enEnglish

Leave a Reply

Close Menu