Após muitos anos de uso ou customizações do Bacula (ex.: renomear ou desativar clients, filesets etc.) é provavel que seu catálogo possua entradas órfãs, ou seja: continuam no banco de dados mas não possuem índices referentes a backups existentes. Da mesma forma índices de jobs de restauração que provavelmente já tiveram seu conteúdo validado e que não são mais necessários. Esse comportamento pode deixar a administração do Bacula mais complexa e trazer algum impacto na performance do Banco.
Felizmente o aplicativo dbcheck que é instalado junto ao Bacula Director pode ser utilizado para limpar essas entradas. O principal requisito para uso do comando é informar apenas o working directory (diretório de trabalho), configurado no bacula-dir.conf.
Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] [] []
Para estimar a quantidade de entradas que podem ser descartadas pode ser utilizada a opção -b. É provável que o dbcheck solicite criar novos índices no Banco para otimizar suas rotinas:
[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.
E finalmente para eliminar as entradas órfãs do Banco de Dados use a opção -f (fix):
[root@localhost bacula]# sudo -u bacula dbcheck -f /opt/bacula/working/
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: Português