1 .\" Hey, EMACS: -*- nroff -*-
2 .\" First parameter, NAME, should be all caps
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
4 .\" other parameters are allowed: see man(7), man(1)
5 .TH DBCHECK 8 "26 May 2006" "Kern Sibbald" "Network backup, recovery and verification"
6 .\" Please adjust this date whenever revising the manpage.
9 dbcheck \- Bacula's Catalog Database Check/Clean program
19 This manual page documents briefly the
23 dbcheck will not repair your database if it is broken. Please see your
24 vendor's instructions for fixing broken database.
26 dbcheck is a simple program that will search for logical
27 inconsistencies in the Bacula tables in your database, and optionally fix them.
28 It is a database maintenance routine, in the sense that it can
29 detect and remove unused rows, but it is not a database repair
30 routine. To repair a database, see the tools furnished by the
31 database vendor. Normally dbcheck should never need to be run,
32 but if Bacula has crashed or you have a lot of Clients, Pools, or
33 Jobs that you have removed, it could be useful.
37 Usage: dbcheck [-c config] [-C catalog name] [-d debug_level] []
39 -C catalog name in the director conf file
40 -c director conf filename
41 -dnn set debug level to nn
42 -f fix inconsistencies
46 If the -c option is given with the Director's conf file, there is no
47 need to enter any of the command line arguments, in particular the working
48 directory as dbcheck will read them from the file.
50 If the -f option is specified, dbcheck will repair (fix) the
51 inconsistencies it finds. Otherwise, it will report only.
53 If the -b option is specified, dbcheck will run in batch mode, and
54 it will proceed to examine and fix (if -f is set) all programmed inconsistency
55 checks. If the -b option is not specified, dbcheck will enter
56 interactive mode and prompt with the following:
58 Hello, this is the database check/correct program.
59 Please select the function you want to perform.
60 1) Toggle modify database flag
61 2) Toggle verbose flag
62 3) Repair bad Filename records
63 4) Repair bad Path records
64 5) Eliminate duplicate Filename records
65 6) Eliminate duplicate Path records
66 7) Eliminate orphaned Jobmedia records
67 8) Eliminate orphaned File records
68 9) Eliminate orphaned Path records
69 10) Eliminate orphaned Filename records
70 11) Eliminate orphaned FileSet records
71 12) Eliminate orphaned Client records
72 13) Eliminate orphaned Job records
73 14) Eliminate all Admin records
74 15) Eliminate all Restore records
77 Select function number:
79 By entering 1 or 2, you can toggle the modify database flag (-f option) and
80 the verbose flag (-v). It can be helpful and reassuring to turn off the modify
81 database flag, then select one or more of the consistency checks (items 3
82 through 9) to see what will be done, then toggle the modify flag on and re-run
85 The inconsistencies examined are the following:
88 Duplicate filename records. This can happen if you accidentally run two
89 copies of Bacula at the same time, and they are both adding filenames
90 simultaneously. It is a rare occurrence, but will create an inconsistent
91 database. If this is the case, you will receive error messages during Jobs
92 warning of duplicate database records. If you are not getting these error
93 messages, there is no reason to run this check.
96 Repair bad Filename records. This checks and corrects filenames that
97 have a trailing slash. They should not.
100 Repair bad Path records. This checks and corrects path names that do
101 not have a trailing slash. They should.
104 Duplicate path records. This can happen if you accidentally run two
105 copies of Bacula at the same time, and they are both adding filenames
106 simultaneously. It is a rare occurrence, but will create an inconsistent
107 database. See the item above for why this occurs and how you know it is
111 Orphaned JobMedia records. This happens when a Job record is deleted
112 (perhaps by a user issued SQL statement), but the corresponding JobMedia
113 record (one for each Volume used in the Job) was not deleted. Normally, this
114 should not happen, and even if it does, these records generally do not take
115 much space in your database. However, by running this check, you can
116 eliminate any such orphans.
119 Orphaned File records. This happens when a Job record is deleted
120 (perhaps by a user issued SQL statement), but the corresponding File record
121 (one for each Volume used in the Job) was not deleted. Note, searching for
122 these records can be {\bf very} time consuming (i.e. it may take hours) for a
123 large database. Normally this should not happen as Bacula takes care to
124 prevent it. Just the same, this check can remove any orphaned File records.
125 It is recommended that you run this once a year since orphaned File records
126 can take a large amount of space in your database. You might
127 want to ensure that you have indexes on JobId, FilenameId, and
128 PathId for the File table in your catalog before running this
132 Orphaned Path records. This condition happens any time a directory is
133 deleted from your system and all associated Job records have been purged.
134 During standard purging (or pruning) of Job records, Bacula does not check
135 for orphaned Path records. As a consequence, over a period of time, old
136 unused Path records will tend to accumulate and use space in your database.
137 This check will eliminate them. It is recommended that you run this
138 check at least once a year.
141 Orphaned Filename records. This condition happens any time a file is
142 deleted from your system and all associated Job records have been purged.
143 This can happen quite frequently as there are quite a large number of files
144 that are created and then deleted. In addition, if you do a system update or
145 delete an entire directory, there can be a very large number of Filename
146 records that remain in the catalog but are no longer used.
148 During standard purging (or pruning) of Job records, Bacula does not check
149 for orphaned Filename records. As a consequence, over a period of time, old
150 unused Filename records will accumulate and use space in your database. This
151 check will eliminate them. It is strongly recommended that you run this check
152 at least once a year, and for large database (more than 200 Megabytes), it is
153 probably better to run this once every 6 months.
156 Orphaned Client records. These records can remain in the database long
157 after you have removed a client.
160 Orphaned Job records. If no client is defined for a job or you do not
161 run a job for a long time, you can accumulate old job records. This option
162 allow you to remove jobs that are not attached to any client (and thus
166 All Admin records. This command will remove all Admin records,
167 regardless of their age.
170 All Restore records. This command will remove all Restore records,
171 regardless of their age.
173 By the way, I personally run dbcheck only where I have messed up
174 my database due to a bug in developing Bacula code, so normally
175 you should never need to run dbcheck inspite of the
176 recommendations given above, which are given so that users don't
177 waste their time running dbcheck too often.
184 This manual page was written by Jose Luis Tallon
186 <jltallon@adv\-solutions.net>.