]> git.sur5r.net Git - bacula/bacula/blob - bacula/manpages/dbcheck.8
fb1ec8ddd678b8f392d688e7ed501f76890417aa
[bacula/bacula] / bacula / manpages / dbcheck.8
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.
7 .\"
8 .SH NAME
9  dbcheck \- Bacula's Catalog Database Check/Clean program
10 .SH SYNOPSIS
11 .B bcopy 
12 .RI [ options ]
13 .I working-directory
14 .I bacula-database
15 .I user
16 .I password
17 .br
18 .SH DESCRIPTION
19 This manual page documents briefly the
20 .B dbcheck 
21 command.
22 .PP
23 dbcheck is a simple program that will search for logical
24 inconsistencies in the Bacula tables in your database, and optionally fix them. 
25 It is a database maintenance routine, in the sense that it can
26 detect and remove unused rows, but it is not a database repair
27 routine. To repair a database, see the tools furnished by the
28 database vendor.  Normally dbcheck should never need to be run,
29 but if Bacula has crashed or you have a lot of Clients, Pools, or
30 Jobs that you have removed, it could be useful.  
31                              
32 It is called: 
33
34 Usage: dbcheck [-c config] [-C catalog name] [-d debug_level]     []
35        -b              batch mode
36        -C              catalog name in the director conf file
37        -c              director conf filename
38        -dnn            set debug level to nn
39        -f              fix inconsistencies
40        -v              verbose
41        -?              print this message
42
43 If the -c option is given with the Director's conf file, there is no
44 need to enter any of the command line arguments, in particular the working
45 directory as dbcheck will read them from the file. 
46
47 If the -f option is specified, dbcheck will repair (fix) the
48 inconsistencies it finds. Otherwise, it will report only. 
49
50 If the -b option is specified, dbcheck will run in batch mode, and
51 it will proceed to examine and fix (if -f is set) all programmed inconsistency
52 checks. If the -b option is not specified, dbcheck will enter
53 interactive mode and prompt with the following: 
54
55 Hello, this is the database check/correct program.
56 Please select the function you want to perform.
57      1) Toggle modify database flag
58      2) Toggle verbose flag
59      3) Repair bad Filename records
60      4) Repair bad Path records
61      5) Eliminate duplicate Filename records
62      6) Eliminate duplicate Path records
63      7) Eliminate orphaned Jobmedia records
64      8) Eliminate orphaned File records
65      9) Eliminate orphaned Path records
66     10) Eliminate orphaned Filename records
67     11) Eliminate orphaned FileSet records
68     12) Eliminate orphaned Client records
69     13) Eliminate orphaned Job records
70     14) Eliminate all Admin records
71     15) Eliminate all Restore records
72     16) All (3-15)
73     17) Quit
74 Select function number:
75
76 By entering 1 or 2, you can toggle the modify database flag (-f option) and
77 the verbose flag (-v). It can be helpful and reassuring to turn off the modify
78 database flag, then select one or more of the consistency checks (items 3
79 through 9) to see what will be done, then toggle the modify flag on and re-run
80 the check. 
81
82 The inconsistencies examined are the following: 
83
84 .BR
85    Duplicate filename records. This can happen if you accidentally run  two
86    copies of Bacula at the same time, and they are both adding  filenames
87    simultaneously. It is a rare occurrence, but will create  an inconsistent
88    database. If this is the case, you will receive  error messages during Jobs
89    warning of duplicate database records.  If you are not getting these error
90    messages, there is no reason  to run this check. 
91
92 .BR
93 Repair bad Filename records. This checks and corrects filenames  that
94    have a trailing slash. They should not.  
95
96 .BR
97 Repair bad Path records. This checks and corrects path names  that do
98    not have a trailing slash. They should.  
99
100 .BR
101 Duplicate path records. This can happen if you accidentally run  two
102    copies of Bacula at the same time, and they are both adding  filenames
103    simultaneously. It is a rare occurrence, but will create  an inconsistent
104    database. See the item above for why this occurs and  how you know it is
105    happening. 
106
107 .BR
108 Orphaned JobMedia records. This happens when a Job record is deleted 
109    (perhaps by a user issued SQL statement), but the corresponding  JobMedia
110    record (one for each Volume used in the Job) was not deleted.  Normally, this
111    should not happen, and even if it does, these records  generally do not take
112    much space in your database. However, by running  this check, you can
113    eliminate any such orphans.  
114
115 .BR
116 Orphaned File records. This happens when a Job record is deleted 
117    (perhaps by a user issued SQL statement), but the corresponding  File record
118    (one for each Volume used in the Job) was not deleted.  Note, searching for
119    these records can be {\bf very} time consuming (i.e.  it may take hours) for a
120    large database. Normally this should not  happen as Bacula takes care to
121    prevent it. Just the same, this  check can remove any orphaned File records.
122    It is recommended that  you run this once a year since orphaned File records
123    can take a  large amount of space in your database. You might
124    want to ensure that you have indexes on JobId, FilenameId, and
125    PathId for the File table in your catalog before running this
126    command.
127
128 .BR
129 Orphaned Path records. This condition happens any time a directory is 
130    deleted from your system and all associated Job records have been purged. 
131    During standard purging (or pruning) of Job records, Bacula does  not check
132    for orphaned Path records. As a consequence, over a period  of time, old
133    unused Path records will tend to accumulate and use  space in your database.
134    This check will eliminate them. It is recommended that you run this
135    check at least once a year. 
136
137 .BR
138 Orphaned Filename records. This condition happens any time a file is 
139    deleted from your system and all associated Job records have been purged. 
140    This can happen quite frequently as there are quite a large number  of files
141    that are created and then deleted. In addition, if you  do a system update or
142    delete an entire directory, there can be  a very large number of Filename
143    records that remain in the catalog  but are no longer used.  
144
145    During standard purging (or pruning) of Job records, Bacula does  not check
146    for orphaned Filename records. As a consequence, over a period  of time, old
147    unused Filename records will accumulate and use  space in your database. This
148    check will eliminate them. It is strongly  recommended that you run this check
149    at least once a year, and for  large database (more than 200 Megabytes), it is
150    probably better to  run this once every 6 months.  
151
152 .BR
153 Orphaned Client records. These records can remain in the database  long
154    after you have removed a client. 
155
156 .BR
157 Orphaned Job records. If no client is defined for a job or you  do not
158    run a job for a long time, you can accumulate old job  records. This option
159    allow you to remove jobs that are not  attached to any client (and thus
160    useless).  
161
162 .BR
163 All Admin records. This command will remove all Admin records, 
164    regardless of their age.  
165
166 .BR
167 All Restore records. This command will remove all Restore records, 
168    regardless of their age. 
169
170 By the way, I personally run dbcheck only where I have messed up
171 my database due to a bug in developing Bacula code, so normally
172 you should never need to run dbcheck inspite of the
173 recommendations given above, which are given so that users don't
174 waste their time running dbcheck too often.
175
176 .SH SEE ALSO
177 .BR bls (1),
178 .BR bextract (1).
179 .br
180 .SH AUTHOR
181 This manual page was written by Jose Luis Tallon
182 .nh 
183 <jltallon@adv\-solutions.net>.