1Catalog Services
2================
3
4General
5-------
6
7This chapter is intended to be a technical discussion of the catalog
8services and as such is not targeted at end users but rather at
9developers and system administrators who want or need to know more of
10the working details of **Bareos**.
11
12Currently, we prefer the usage of PostgreSQL. Therefore our support
13for SQLite or other databases could be discontinued in the future.
14PostgreSQL was chosen because it is a full-featured, very mature database,
15and because Dan Langille did the Bareos driver for it.
16
17SQLite was chosen because it is small, efficient, and can be directly
18embedded in **Bareos** thus requiring much less effort from the system
19administrator or person building **Bareos**. In our testing SQLite has
20performed very well, and for the functions that we use, it has never
21encountered any errors except that it does not appear to handle
22databases larger than 2GBytes. That said, we would not recommend it for
23serious production use. Nonetheless SQLite is very suitable for test
24environments.
25
26Bareos **requires** one of the three databases (MySQL, PostgreSQL, or SQLite)
27to run. Therefore it is mandatory to specify one of them for the cmake
28configuration step, i.e.: ``-Dpostgresql=yes``.
29
30Filenames and Maximum Filename Length
31~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33In general, either MySQL, PostgreSQL or SQLite permit storing arbitrary
34long path names and file names in the catalog database. In practice,
35there still may be one or two places in the catalog interface code that
36restrict the maximum path length to 512 characters and the maximum file
37name length to 512 characters. These restrictions are believed to have
38been removed. Please note, these restrictions apply only to the catalog
39database and thus to your ability to list online the files saved during
40any job. All information received and stored by the Storage daemon
41(normally on tape) allows and handles arbitrarily long path and
42filenames.
43
44Database Table Design
45~~~~~~~~~~~~~~~~~~~~~
46
47All discussions that follow pertain to the PostgreSQL database.
48
49Because the catalog database may contain very large amounts of data for
50large sites, we have made a modest attempt to normalize the data tables
51to reduce redundant information. While reducing the size of the database
52significantly, it does, unfortunately, add some complications to the
53structures.
54
55In simple terms, the catalog database must contain a record of all Jobs
56run by Bareos, and for each Job, it must maintain a list of all files
57saved, with their File Attributes (permissions, create date, …), and the
58location and Media on which the file is stored. This is seemingly a
59simple task, but it represents a huge amount of interlinked data.
60The data stored in the File records, which allows the user or
61administrator to obtain a list of all files backed up during a job,
62is by far the largest volume of information put into the catalog database.
63
64Although the catalog database has been designed to handle backup data
65for multiple clients, some users may want to maintain multiple
66databases, one for each machine to be backed up. This reduces the risk
67of confusion of accidental restoring a file to the wrong machine as well
68as reducing the amount of data in a single database, thus increasing
69efficiency and reducing the impact of a lost or damaged database.
70
71Database Tables
72---------------
73
74Path
75~~~~
76
77The **Path** table contains shown above the path or directory names of all
78directories on the system or systems.
79
80+-------------+-----------+-------------+
81| Column Name | Data Type | Remark      |
82+=============+===========+=============+
83| PathId      | serial    | Primary Key |
84+-------------+-----------+-------------+
85| Path        | text      | Full Path   |
86+-------------+-----------+-------------+
87
88The filename and any disk name are stripped off. As with the filename,
89only one copy of each directory name is kept regardless of how many machines
90or drives have the same directory. These path names should be stored in Unix
91path name format.
92
93File
94~~~~
95
96The **File** table contains one entry for each file backed up by Bareos.
97
98+-------------+---------------+---------------------------------------+
99| Column Name | Data Type     | Remark                                |
100+=============+===============+=======================================+
101| FileId      | serial        | Primary Key                           |
102+-------------+---------------+---------------------------------------+
103| FileIndex   | integer       | The sequential file number in the Job |
104+-------------+---------------+---------------------------------------+
105| JobId       | integer       | Link to Job Record                    |
106+-------------+---------------+---------------------------------------+
107| PathId      | integer       | Link to Path Record                   |
108+-------------+---------------+---------------------------------------+
109| DeltaSeq    | smallint      |                                       |
110+-------------+---------------+---------------------------------------+
111| MarkId      | integer       | Used to mark files during Verify Jobs |
112+-------------+---------------+---------------------------------------+
113| Fhinofo     | numeric(20)   |                                       |
114+-------------+---------------+---------------------------------------+
115| Fhnode      | numeric(20)   |                                       |
116+-------------+---------------+---------------------------------------+
117| LStat       | text          | File attributes in base64 encoding    |
118+-------------+---------------+---------------------------------------+
119| MD5         | text          | MD5/SHA1 signature in base64 encoding |
120+-------------+---------------+---------------------------------------+
121| name        | text          |                                       |
122+-------------+---------------+---------------------------------------+
123
124File that is backed up multiple times (as is normal) will have multiple
125entries in the File table. This will probably
126be the table with the most number of records. Consequently, it is
127essential to keep the size of this record to an absolute minimum. At the
128same time, this table must contain all the information (or pointers to
129the information) about the file and where it is backed up.
130
131This table contains by far the largest amount of information in the
132catalog database, both from the stand point of number of records, and
133the stand point of total database size.
134
135As MD5 hash (also termed message digests) consists of 128-bit (16-byte).
136A typical format (eg. ``md5sum``, …) to represent them is as a sequence
137of 32 hexadecimal digits. However, in the **MD5** column, the digest is
138represented as base64.
139
140To compare a Bareos digest with command line tools, you have to use
141
142::
143
144    openssl dgst -md5 -binary $PATH_OF_YOUR_FILE | base64
145
146Please note, even the table column is named **MD5**, it is used to store
147any kind of digest (MD5, SHA1, …). This is not directly indicated by the
148value, however, you can determine the type depending of the length of
149the digest.
150
151Job
152~~~
153
154The **Job** table contains one record for each Job run by Bareos.
155
156+----------------+----------------+------------------------------------------+
157| Column         | Data Type      | Remark                                   |
158| Name           |                |                                          |
159+================+================+==========================================+
160| JobId          | serial         | Primary Key                              |
161+----------------+----------------+------------------------------------------+
162| Job            | text           | Unique Job Name                          |
163+----------------+----------------+------------------------------------------+
164| Name           | text           | Job Name                                 |
165+----------------+----------------+------------------------------------------+
166| Type           | char(1)        | Job Type: Backup, Copy, Clone, Archive,  |
167|                |                | Migration                                |
168+----------------+----------------+------------------------------------------+
169| Level          | char(1)        | Job Level                                |
170+----------------+----------------+------------------------------------------+
171| ClientId       | integer        | Client index                             |
172+----------------+----------------+------------------------------------------+
173| JobStatus      | char(1)        | Job Termination Status                   |
174+----------------+----------------+------------------------------------------+
175| SchedTime      | timestamp      | Time/date when Job scheduled             |
176+----------------+----------------+------------------------------------------+
177| StartTime      | timestamp      | Time/date when Job started               |
178+----------------+----------------+------------------------------------------+
179| EndTime        | timestamp      | Time/date when Job ended                 |
180+----------------+----------------+------------------------------------------+
181| RealEndTime    | timestamp      | Time/date when original Job ended        |
182+----------------+----------------+------------------------------------------+
183| JobTDate       | bigint         | Start day in Unix format but 64 bits;    |
184|                |                | used for Retention period.               |
185+----------------+----------------+------------------------------------------+
186| VolSessionId   | integer        | Unique Volume Session ID                 |
187+----------------+----------------+------------------------------------------+
188| VolSessionTime | integer        | Unique Volume Session Time               |
189+----------------+----------------+------------------------------------------+
190| JobFiles       | integer        | Number of files saved in Job             |
191+----------------+----------------+------------------------------------------+
192| JobBytes       | bigint         | Number of bytes saved in Job             |
193+----------------+----------------+------------------------------------------+
194| ReadBytes      | bigint         |                                          |
195+----------------+----------------+------------------------------------------+
196| JobErrors      | integer        | Number of errors during Job              |
197+----------------+----------------+------------------------------------------+
198| JobMissinFiles | integer        | Number of files not saved (not yet used) |
199+----------------+----------------+------------------------------------------+
200| PoolId         | integer        | Link to Pool Record                      |
201+----------------+----------------+------------------------------------------+
202| FileSetId      | integer        | Link to FileSet Record                   |
203+----------------+----------------+------------------------------------------+
204| PriorJobId     | integer        | Link to prior Job Record when migrated   |
205+----------------+----------------+------------------------------------------+
206| PurgedFiles    | smallint       | Set when all File records purged         |
207+----------------+----------------+------------------------------------------+
208| HasBase        | smallint       | Set when Base Job run                    |
209+----------------+----------------+------------------------------------------+
210| HasCache       | smallint       |                                          |
211+----------------+----------------+------------------------------------------+
212| Reviewed       | smallint       |                                          |
213+----------------+----------------+------------------------------------------+
214| Comment        | text           |                                          |
215+----------------+----------------+------------------------------------------+
216
217The Name field of the Job record corresponds to the Name resource record
218given in the Director’s configuration file.
219
220The Job field contains a combination of the Name and the schedule time
221of the Job by the Director. Thus for a given Director, even with
222multiple catalog databases, the Job will contain a unique name that
223represents the Job.
224
225For a given Storage daemon, the VolSessionId and VolSessionTime form a
226unique identification of the Job. This will be the case even if multiple
227Directors are using the same Storage daemon.
228
229The JobStatus field specifies how the job terminated.
230
231FileSet
232~~~~~~~
233
234The **FileSet** table contains one entry for each FileSet that is used.
235
236+-------------+-----------+-------------------------------+
237| Column Name | Data Type | Remark                        |
238+=============+===========+===============================+
239| FileSetId   | serial    | Primary Key                   |
240+-------------+-----------+-------------------------------+
241| FileSet     | text      | FileSet name                  |
242+-------------+-----------+-------------------------------+
243| FileSetText | text      |                               |
244+-------------+-----------+-------------------------------+
245| MD5         | text      | MD5 checksum of FileSet       |
246+-------------+-----------+-------------------------------+
247| CreateTime  | timestamp | Time and date Fileset created |
248+-------------+-----------+-------------------------------+
249
250The MD5 signature is kept to ensure that if the user changes anything
251inside the FileSet, it will be detected and the new FileSet will be
252used. This is particularly important when doing an incremental update.
253If the user deletes a file or adds a file, we need to ensure that a Full
254backup is done prior to the next incremental.
255
256JobMedia
257~~~~~~~~
258
259The **JobMedia** table contains one entry at the following: start of the
260job, start of each new tape file mark, start of each new tape, end of
261the job. You will have 2 or more JobMedia records per Job.
262
263+-------------+-------------+---------------------------------------------------+
264| Column      | Data        | Remark                                            |
265| Name        | Type        |                                                   |
266+=============+=============+===================================================+
267| JobMediaId  | serial      | Primary Key                                       |
268+-------------+-------------+---------------------------------------------------+
269| JobId       | integer     | Link to Job Record                                |
270+-------------+-------------+---------------------------------------------------+
271| MediaId     | integer     | Link to Media Record                              |
272+-------------+-------------+---------------------------------------------------+
273| FirstIndex  | integer     | The index (sequence number) of the first file     |
274|             |             | written for this Job to the Media                 |
275+-------------+-------------+---------------------------------------------------+
276| LastIndex   | integer     | The index of the last file written for this Job   |
277|             |             | to the Media                                      |
278+-------------+-------------+---------------------------------------------------+
279| StartFile   | integer     | | *Tape*: The physical media file mark number of  |
280|             |             |   the first block written for this Job.           |
281|             |             | | *Other*: Upper 32-bit of the position of the    |
282|             |             |   first block written for this Job.               |
283+-------------+-------------+---------------------------------------------------+
284| EndFile     | integer     | | *Tape*: The physical media file mark number of  |
285|             |             |   the last block written for this Job             |
286|             |             | | *Other*: Upper 32-bit of the position of the    |
287|             |             |   last block written for this Job                 |
288+-------------+-------------+---------------------------------------------------+
289| StartBlock  | integer     | | *Tape*: The number of the first block written   |
290|             |             |   for this Job                                    |
291|             |             | | *Other*: Lower 32-bit of the position of the    |
292|             |             |   first block written for this Job                |
293+-------------+-------------+---------------------------------------------------+
294| Endblock    | integer     | | *Tape*: The number of the last block written for|
295|             |             |   this Job                                        |
296|             |             | | *Other*: Lower 32-bit of the position of the    |
297|             |             |   last block written for this Job                 |
298+-------------+-------------+---------------------------------------------------+
299| JobBytes    | numeric(20) | The Volume use sequence number within the Job     |
300+-------------+-------------+---------------------------------------------------+
301| VolIndex    | integer     | The Volume use sequence number within the Job     |
302+-------------+-------------+---------------------------------------------------+
303
304Device
305~~~~~~
306
307This is the device table. It contains information about reading and or writing devices.
308
309+----------------------------+-------------+---------------------------------------+
310| Column                     | Data        | Remark                                |
311| Name                       | Type        |                                       |
312+============================+=============+=======================================+
313| DeviceId                   | serial      |                                       |
314+----------------------------+-------------+---------------------------------------+
315| Name                       | text        |                                       |
316+----------------------------+-------------+---------------------------------------+
317| MediaTypeId                | integer     |                                       |
318+----------------------------+-------------+---------------------------------------+
319| StorageId                  | integer     |                                       |
320+----------------------------+-------------+---------------------------------------+
321| DevMounts                  | integer     |                                       |
322+----------------------------+-------------+---------------------------------------+
323| DevReadBytes               | bigint      |                                       |
324+----------------------------+-------------+---------------------------------------+
325| DevWriteBytes              | bigint      |                                       |
326+----------------------------+-------------+---------------------------------------+
327| DevReadBytesSinceCleaning  | bigint      |                                       |
328+----------------------------+-------------+---------------------------------------+
329| DevWriteBytesSinceCleaning | bigint      |                                       |
330+----------------------------+-------------+---------------------------------------+
331| DevReadTime                | bigint      |                                       |
332+----------------------------+-------------+---------------------------------------+
333| DevWriteTime               | bigint      |                                       |
334+----------------------------+-------------+---------------------------------------+
335| DevReadTimeSinceCleaning   | bigint      |                                       |
336+----------------------------+-------------+---------------------------------------+
337| DevWriteTimeSinceCleaning  | bigint      |                                       |
338+----------------------------+-------------+---------------------------------------+
339| CleaningDate               | timestamp   |                                       |
340+----------------------------+-------------+---------------------------------------+
341| CleaningPeriod             | bigint      |                                       |
342+----------------------------+-------------+---------------------------------------+
343
344
345Tape Volume
346^^^^^^^^^^^
347
348The number ob records depends on the “Maximum File Size” specified in
349the Device resource. This record allows Bareos to efficiently position
350close to any given file in a backup. For restoring a full Job, these
351records are not very important, but if you want to retrieve a single
352file that was written near the end of a 100GB backup, the JobMedia
353records can speed it up by orders of magnitude by permitting forward
354spacing files and blocks rather than reading the whole 100GB backup.
355
356Other Volume
357^^^^^^^^^^^^
358
359StartFile and StartBlock are both 32-bit integer values. However, as the
360position on a disk volume is specified in bytes, we need this to be a
36164-bit value.
362
363Therefore, the start position is calculated as:
364
365::
366
367    StartPosition = StartFile * 4294967296 + StartBlock
368
369The end position of a job on a volume can be determined by:
370
371::
372
373    EndPosition = EndFile * 4294967296 + EndBlock
374
375Be aware, that you can not assume, that the job size on a volume is
376``EndPosition - StartPosition``. When interleaving is used other jobs
377can also be stored between Start- and EndPosition.
378
379::
380
381    EndPosition - StartPosition >= JobSizeOnThisMedia
382
383Media (Volume)
384~~~~~~~~~~~~~~
385
386The **Media** table contains one entry for each volume, that is each tape
387or file on which information is or was backed up. There is one volume record
388created for each of the NumVols specified in the Pool resource record.
389
390+------------------+-----------+-----------------------------------------+
391| Column Name      | Data      | Remark                                  |
392|                  | Type      |                                         |
393+==================+===========+=========================================+
394| MediaId          | serial    | Primary Key                             |
395+------------------+-----------+-----------------------------------------+
396| VolumeName       | text      | Volume name                             |
397+------------------+-----------+-----------------------------------------+
398| Slot             | integer   | Autochanger Slot number or zero         |
399+------------------+-----------+-----------------------------------------+
400| PoolId           | integer   | Link to Pool Record                     |
401+------------------+-----------+-----------------------------------------+
402| MediaType        | text      | The MediaType supplied by the user      |
403+------------------+-----------+-----------------------------------------+
404| MediaTypeId      | integer   | The MediaTypeId                         |
405+------------------+-----------+-----------------------------------------+
406| LabelType        | integer   | The type of label on the Volume         |
407+------------------+-----------+-----------------------------------------+
408| FirstWritten     | timestamp | Time/date when first written            |
409+------------------+-----------+-----------------------------------------+
410| LastWritten      | timestamp | Time/date when last written             |
411+------------------+-----------+-----------------------------------------+
412| LabelDate        | timestamp | Time/date when tape labeled             |
413+------------------+-----------+-----------------------------------------+
414| VolJobs          | integer   | Number of jobs written to this media    |
415+------------------+-----------+-----------------------------------------+
416| VolFiles         | integer   | Number of files written to this media   |
417+------------------+-----------+-----------------------------------------+
418| VolBlocks        | integer   | Number of blocks written to this media  |
419+------------------+-----------+-----------------------------------------+
420| VolMounts        | integer   | Number of time media mounted            |
421+------------------+-----------+-----------------------------------------+
422| VolBytes         | bigint    | Number of bytes saved in Job            |
423+------------------+-----------+-----------------------------------------+
424| VolErrors        | integer   | Number of errors during Job             |
425+------------------+-----------+-----------------------------------------+
426| VolWrites        | integer   | Number of writes to media               |
427+------------------+-----------+-----------------------------------------+
428| VolCapacityBytes | bigint    | Capacity estimate for this volume       |
429+------------------+-----------+-----------------------------------------+
430| VolStatus        | text      | | Status of media:                      |
431|                  |           | | Full, Archive, Append,                |
432|                  |           |   Recycle, Read-Only, Disabled, Error,  |
433|                  |           |   Busy                                  |
434+------------------+-----------+-----------------------------------------+
435| Enabled          | smallint  | Whether or not Volume can be written    |
436+------------------+-----------+-----------------------------------------+
437| Recycle          | smallint  | Whether or not Bareos can recycle the   |
438|                  |           | Volumes: Yes, No                        |
439+------------------+-----------+-----------------------------------------+
440| ActionOnPurge    | smallint  | What happens to a Volume after purging  |
441+------------------+-----------+-----------------------------------------+
442| VolRetention     | bigint    | 64 bit seconds until expiration         |
443+------------------+-----------+-----------------------------------------+
444| VolUseDureation  | bigint    | 64 bit seconds volume can be used       |
445+------------------+-----------+-----------------------------------------+
446| MaxVolJobs       | integer   | maximum jobs to put on Volume           |
447+------------------+-----------+-----------------------------------------+
448| MaxVolFiles      | integer   | maximume EOF marks to put on Volume     |
449+------------------+-----------+-----------------------------------------+
450| MaxVolBytes      | bigint    | Maximum bytes to put on this media      |
451+------------------+-----------+-----------------------------------------+
452| InChanger        | smallint  | Whether or not Volume in autochanger    |
453+------------------+-----------+-----------------------------------------+
454| StorageId        | integer   | Storage record ID                       |
455+------------------+-----------+-----------------------------------------+
456| DeviceId         | integer   | Device record ID                        |
457+------------------+-----------+-----------------------------------------+
458| MediaAddressing  | smallint  | Method of addressing media              |
459+------------------+-----------+-----------------------------------------+
460| VolReadTime      | bigint    | Time Reading Volume                     |
461+------------------+-----------+-----------------------------------------+
462| VolWriteTime     | bigint    | Time Writing Volume                     |
463+------------------+-----------+-----------------------------------------+
464| EndFile          | integer   | End File number of Volume               |
465+------------------+-----------+-----------------------------------------+
466| EndBlock         | bigint    | End block number of Volume              |
467+------------------+-----------+-----------------------------------------+
468| LocationId       | integer   | Location record ID                      |
469+------------------+-----------+-----------------------------------------+
470| RecycleCount     | integer   | Number of times recycled                |
471+------------------+-----------+-----------------------------------------+
472| MinBlockSize     | integer   | Minimum block size on this media        |
473+------------------+-----------+-----------------------------------------+
474| MaxBlockSize     | integer   | Maximum block size on this media        |
475+------------------+-----------+-----------------------------------------+
476| InitialWrite     | timestamp | When Volume first written               |
477+------------------+-----------+-----------------------------------------+
478| ScratchPoolId    | integer   | Id of Scratch Pool                      |
479+------------------+-----------+-----------------------------------------+
480| RecyclePoolId    | integer   | Pool ID where to recycle Volume         |
481+------------------+-----------+-----------------------------------------+
482| EncryptionKey    | text      | Key used for encryptoion                |
483+------------------+-----------+-----------------------------------------+
484| Comment          | text      | User text field                         |
485+------------------+-----------+-----------------------------------------+
486
487Pool
488~~~~
489
490The **Pool** table contains one entry for each media pool controlled by
491Bareos in this database.
492
493+-----------------------+-----------------------+-----------------------+
494| Column Name           | Data Type             | Remark                |
495+=======================+=======================+=======================+
496| PoolId                | serial                | Primary Key           |
497+-----------------------+-----------------------+-----------------------+
498| Name                  | text                  | Pool Name             |
499+-----------------------+-----------------------+-----------------------+
500| NumVols               | integer               | Number of Volumes in  |
501|                       |                       | the Pool              |
502+-----------------------+-----------------------+-----------------------+
503| MaxVols               | integer               | Maximum Volumes in    |
504|                       |                       | the Pool              |
505+-----------------------+-----------------------+-----------------------+
506| UseOnce               | smallint              | Use volume once       |
507+-----------------------+-----------------------+-----------------------+
508| UseCatalog            | smallint              | Set to use catalog    |
509+-----------------------+-----------------------+-----------------------+
510| AcceptAnyVolume       | smallint              | Accept any volume     |
511|                       |                       | from Pool             |
512+-----------------------+-----------------------+-----------------------+
513| VolRetention          | bigint                | 64 bit seconds to     |
514|                       |                       | retain volume         |
515+-----------------------+-----------------------+-----------------------+
516| VolUseDuration        | bigint                | 64 bit seconds volume |
517|                       |                       | can be used           |
518+-----------------------+-----------------------+-----------------------+
519| MaxVolJobs            | integer               | max jobs on volume    |
520+-----------------------+-----------------------+-----------------------+
521| MaxVolFiles           | integer               | max EOF marks to put  |
522|                       |                       | on Volume             |
523+-----------------------+-----------------------+-----------------------+
524| MaxVolBytes           | bigint                | max bytes to write on |
525|                       |                       | Volume                |
526+-----------------------+-----------------------+-----------------------+
527| AutoPrune             | smallint              | yes or no for         |
528|                       |                       | autopruning           |
529+-----------------------+-----------------------+-----------------------+
530| Recycle               | smallint              | yes or no for         |
531|                       |                       | allowing auto         |
532|                       |                       | recycling of Volume   |
533+-----------------------+-----------------------+-----------------------+
534| ActionOnPurge         | smallint              | Default Volume        |
535|                       |                       | ActionOnPurge         |
536+-----------------------+-----------------------+-----------------------+
537| PoolType              | text                  | Backup, Copy, Cloned, |
538|                       |                       | Archive, Migration    |
539+-----------------------+-----------------------+-----------------------+
540| LabelType             | integer               | Type of label         |
541|                       |                       | ANSI/Bareos           |
542+-----------------------+-----------------------+-----------------------+
543| LabelFormat           | text                  | Label format          |
544+-----------------------+-----------------------+-----------------------+
545| Enabled               | smallint              | Whether or not Volume |
546|                       |                       | can be written        |
547+-----------------------+-----------------------+-----------------------+
548| ScratchPoolId         | integer               | Id of Scratch Pool    |
549+-----------------------+-----------------------+-----------------------+
550| RecyclePoolId         | integer               | Pool ID where to      |
551|                       |                       | recycle Volume        |
552+-----------------------+-----------------------+-----------------------+
553| NextPoolId            | integer               | Pool ID of next Pool  |
554+-----------------------+-----------------------+-----------------------+
555| MinBlockSize          | integer               | Pool ID of next Pool  |
556+-----------------------+-----------------------+-----------------------+
557| MaxBlockSize          | integer               | Pool ID of next Pool  |
558+-----------------------+-----------------------+-----------------------+
559| MigrationHighBytes    | bigint                | High water mark for   |
560|                       |                       | migration             |
561+-----------------------+-----------------------+-----------------------+
562| MigrationLowBytes     | bigint                | Low water mark for    |
563|                       |                       | migration             |
564+-----------------------+-----------------------+-----------------------+
565| MigrationTime         | bigint                | Time before migration |
566+-----------------------+-----------------------+-----------------------+
567
568In the **Media** table one or more records exist
569for each of the Volumes contained in the Pool. The MediaType is defined
570by the administrator, and corresponds to the MediaType specified in the
571Director’s Storage definition record.
572
573Client
574~~~~~~
575
576The **Client** table contains one entry for each machine backed up by
577Bareos in this database. Normally the Name is a fully qualified domain
578name.
579
580+---------------+-----------+-------------------------------------+
581| Column Name   | Data Type | Remark                              |
582+===============+===========+=====================================+
583| ClientId      | serial    | Primary Key                         |
584+---------------+-----------+-------------------------------------+
585| Name          | text      | File Services Name                  |
586+---------------+-----------+-------------------------------------+
587| UName         | text      | uname -a from Client (not yet used) |
588+---------------+-----------+-------------------------------------+
589| AutoPrune     | smallint  | yes or no for autopruning           |
590+---------------+-----------+-------------------------------------+
591| FileRetention | bigint    | 64 bit seconds to retain Files      |
592+---------------+-----------+-------------------------------------+
593| JobRentention | bigint    | 64 bit seconds to retain Job        |
594+---------------+-----------+-------------------------------------+
595
596Storage
597~~~~~~~
598
599The **Storage** table contains one entry for each Storage used.
600
601+-------------+-----------+---------------------------------+
602| Column Name | Data Type | Remark                          |
603+=============+===========+=================================+
604| StorageId   | serial    | Unique Id                       |
605+-------------+-----------+---------------------------------+
606| Name        | text      | Resource name of Storage device |
607+-------------+-----------+---------------------------------+
608| AutoChanger | integer   | Set if it is an autochanger     |
609+-------------+-----------+---------------------------------+
610
611Counters
612~~~~~~~~
613
614The **Counter** table contains one entry for each permanent counter
615defined by the user.
616
617+--------------+-----------+-----------------------------+
618| Column Name  | Data Type | Remark                      |
619+==============+===========+=============================+
620| Counter      | serial    | Counter name                |
621+--------------+-----------+-----------------------------+
622| MinValue     | integer   | Start/Min value for counter |
623+--------------+-----------+-----------------------------+
624| MaxValue     | integer   | Max value for counter       |
625+--------------+-----------+-----------------------------+
626| CurrentValue | integer   | Current counter value       |
627+--------------+-----------+-----------------------------+
628| WrapCounter  | text      | Name of another counter     |
629+--------------+-----------+-----------------------------+
630
631Log
632~~~
633
634The **Log** table contains a log of all Job output.
635
636+-------------+-----------+------------------------------+
637| Column Name | Data Type | Remark                       |
638+=============+===========+==============================+
639| LogId       | serial    | Primary Key                  |
640+-------------+-----------+------------------------------+
641| JobId       | integer   | Points to Job record         |
642+-------------+-----------+------------------------------+
643| Time        | timestamp | Time/date log record created |
644+-------------+-----------+------------------------------+
645| LogText     | text      | Log text                     |
646+-------------+-----------+------------------------------+
647
648Location
649~~~~~~~~
650
651The **Location** table defines where a Volume is physically.
652
653+-------------+-----------+-----------------------------------+
654| Column Name | Data Type | Remark                            |
655+=============+===========+===================================+
656| LocationId  | serial    | Primary Key                       |
657+-------------+-----------+-----------------------------------+
658| Location    | text      | Text defining location            |
659+-------------+-----------+-----------------------------------+
660| Cost        | integer   | Relative cost of obtaining Volume |
661+-------------+-----------+-----------------------------------+
662| Enabled     | smallint  | Whether or not Volume is enabled  |
663+-------------+-----------+-----------------------------------+
664
665LocationLog
666~~~~~~~~~~~
667
668The **LocationLog** table contains a log of all Job output.
669
670+-------------+-----------+-----------------------------------------------+
671| Column      | Data      | Remark                                        |
672| Name        | Type      |                                               |
673+=============+===========+===============================================+
674| LocLogId    | serial    | Primary Key                                   |
675+-------------+-----------+-----------------------------------------------+
676| Date        | timestamp | Time/date log record created                  |
677+-------------+-----------+-----------------------------------------------+
678| Comment     | text      | Time/date log record created                  |
679+-------------+-----------+-----------------------------------------------+
680| MediaId     | integer   | Points to Media record                        |
681+-------------+-----------+-----------------------------------------------+
682| LocationId  | integer   | Points to Location record                     |
683+-------------+-----------+-----------------------------------------------+
684| NewVolStaus | integer   | enum: Full, Archive, Append, Recycle, Purged  |
685|             |           | Read-only, Disabled, Error, Busy, Used,       |
686|             |           | Cleaning                                      |
687+-------------+-----------+-----------------------------------------------+
688| Enabled     | tinyint   | Whether or not Volume is enabled              |
689+-------------+-----------+-----------------------------------------------+
690
691Version
692~~~~~~~
693
694The **Version** table defines the Bareos database version number. Bareos
695checks this number before reading the database to ensure that it is
696compatible with the Bareos binary file.
697
698+-------------+-----------+-------------+
699| Column Name | Data Type | Remark      |
700+=============+===========+=============+
701| VersionId   | integer   | Primary Key |
702+-------------+-----------+-------------+
703
704BaseFiles
705~~~~~~~~~
706
707The **BaseFiles** table contains all the File references for a
708particular JobId that point to a Base file.
709
710+-------------+-----------+-------------------+
711| Column Name | Data Type | Remark            |
712+=============+===========+===================+
713| BaseId      | serial    | Primary Key       |
714+-------------+-----------+-------------------+
715| JobId       | integer   | Reference to Job  |
716+-------------+-----------+-------------------+
717| FileId      | bigint    | Reference to File |
718+-------------+-----------+-------------------+
719| FileIndex   | integer   | File Index number |
720+-------------+-----------+-------------------+
721| BaseJobId   | integer   | JobId of Base Job |
722+-------------+-----------+-------------------+
723
724For example they were previously saved and hence were not saved in
725the current JobId but in BaseJobId under FileId. FileIndex is the
726index of the file, and is used for optimization of Restore jobs to
727prevent the need to read the FileId record when creating the in
728memory tree. This record is not yet implemented.
729
730UML Diagram of Database Schema
731------------------------------
732
733.. uml:: catalog/schema_bareos_postgresql.puml
734
735