1.. _TutorialChapter:
2
3Tutorial
4========
5
6:index:`\ <single: Tutorial>`\
7
8This chapter will guide you through running Bareos. To do so, we assume you have installed Bareos. However, we assume that you have not modified the configuration. The examples in this chapter use the default configuration files and will write the volumes to disk in your :file:`/var/lib/bareos/storage/` directory.
9
10The general flow of running Bareos is:
11
12#. Start the Database (if using |postgresql| or |mysql|)
13
14#.
15
16   :ref:`InstallChapter`
17
18#. Start the Bareos Daemons
19
20#. Start the Console program to interact with the |dir|
21
22#. Run a job
23
24#. Test recovering some files from the Volume just written to ensure the backup is good and that you know how to recover. Better test before disaster strikes
25
26#. Add a second client.
27
28Each of these steps is described in more detail below.
29
30Starting the Database
31---------------------
32
33If you are using |postgresql| or |mysql| as the Bareos database, you should start it before you install Bareos. If you are using |sqlite| you need do nothing. |sqlite| is automatically started by the |dir|.
34
35Installing Bareos
36-----------------
37
38For installing Bareos, follow the instructions from the :ref:`InstallChapter` chapter.
39
40.. _StartDaemon:
41
42Starting the Daemons
43--------------------
44
45:index:`\ <single: Starting the Daemons>`\  :index:`\ <single: Daemon; Start>`\
46
47Assuming you have installed the packages, to start the three daemons, from your installation directory, simply enter:
48
49.. code-block:: bconsole
50   :caption: start services
51
52   service bareos-dir start
53   service bareos-sd start
54   service bareos-fd start
55
56.. _section-TuturialBconsole:
57
58Using the Director to Query and Start Jobs
59------------------------------------------
60
61To communicate with the |dir| and to query the state of Bareos or run jobs, the :command:`bconsole` program can be used as a textual interface. Alternatively, for most purposes, also the :ref:`|webui| <section-webui>` can be used, but for simplicity, here we will describe only the :command:`bconsole` program.
62
63The :command:`bconsole` runs the Bareos Console program, which connects to the |dir|. Since Bareos is a network program, you can run the Console program anywhere on your network. Most frequently, however, one runs it on the same machine as the |dir|. Normally, the Console program will print something similar to the following:
64
65.. code-block:: shell-session
66   :caption: bconsole
67
68   <command>bconsole</command>
69   Connecting to Director bareos:9101
70   Enter a period to cancel a command.
71   *
72
73The asterisk is the console command prompt.
74
75Type :bcommand:`help` to see a list of available commands:
76
77.. code-block:: bconsole
78   :caption: help
79
80   *<input>help</input>
81     Command       Description
82     =======       ===========
83     add           Add media to a pool
84     autodisplay   Autodisplay console messages
85     automount     Automount after label
86     cancel        Cancel a job
87     create        Create DB Pool from resource
88     delete        Delete volume, pool or job
89     disable       Disable a job
90     enable        Enable a job
91     estimate      Performs FileSet estimate, listing gives full listing
92     exit          Terminate Bconsole session
93     export        Export volumes from normal slots to import/export slots
94     gui           Non-interactive gui mode
95     help          Print help on specific command
96     import        Import volumes from import/export slots to normal slots
97     label         Label a tape
98     list          List objects from catalog
99     llist         Full or long list like list command
100     messages      Display pending messages
101     memory        Print current memory usage
102     mount         Mount storage
103     move          Move slots in an autochanger
104     prune         Prune expired records from catalog
105     purge         Purge records from catalog
106     quit          Terminate Bconsole session
107     query         Query catalog
108     restore       Restore files
109     relabel       Relabel a tape
110     release       Release storage
111     reload        Reload conf file
112     rerun         Rerun a job
113     run           Run a job
114     status        Report status
115     setbandwidth  Sets bandwidth
116     setdebug      Sets debug level
117     setip         Sets new client address -- if authorized
118     show          Show resource records
119     sqlquery      Use SQL to query catalog
120     time          Print current time
121     trace         Turn on/off trace to file
122     unmount       Unmount storage
123     umount        Umount - for old-time Unix guys, see unmount
124     update        Update volume, pool or stats
125     use           Use specific catalog
126     var           Does variable expansion
127     version       Print Director version
128     wait          Wait until no jobs are running
129
130Details of the console program’s commands are explained in the :ref:`section-bconsole` chapter.
131
132.. _Running:
133
134Running a Job
135-------------
136
137:index:`\ <single: Job; Running a>`\  :index:`\ <single: Running a Job>`\
138
139At this point, we assume you have done the following:
140
141-  Started the Database
142
143-  Installed Bareos
144
145-  Prepared the database for Bareos
146
147-  Started Bareos Director, Storage Daemon and File Daemon
148
149-  Invoked the Console program with :command:`bconsole`
150
151Furthermore, we assume for the moment you are using the default configuration files.
152
153At this point, enter the :bcommand:`show filesets` and you should get something similar this:
154
155.. code-block:: bconsole
156   :caption: show filesets
157
158   *<input>show filesets</input>
159   ...
160   FileSet {
161     Name = "SelfTest"
162     Include {
163       Options {
164         Signature = MD5
165       }
166       File = "/usr/sbin"
167     }
168   }
169
170   FileSet {
171     Name = "Catalog"
172     Include {
173       Options {
174         Signature = MD5
175       }
176       File = "/var/lib/bareos/bareos.sql"
177       File = "/etc/bareos"
178     }
179   }
180   ...
181
182One of the FileSets is the pre-defined :config:option:`dir/fileset = SelfTest`\  FileSet that will backup the :file:`/usr/sbin` directory. For testing purposes, we have chosen a directory of moderate size (about 30 Megabytes) and complexity without being too big. The FileSet :config:option:`dir/fileset = Catalog`\  is used for backing up Bareos’s catalog and is not of interest to us for the moment. You can change what is backed up by editing the configuration and changing the :file:`File =` line in the
183:config:option:`Dir/FileSet`\  resource.
184
185Now is the time to run your first backup job. We are going to backup your Bareos source directory to a File Volume in your :file:`/var/lib/bareos/storage/` directory just to show you how easy it is. Now enter:
186
187.. code-block:: bconsole
188   :caption: status dir
189
190   *<input>status dir</input>
191   bareos-dir Version: 13.2.0 (09 April 2013) x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
192   Daemon started 23-May-13 13:17. Jobs: run=0, running=0 mode=0
193    Heap: heap=270,336 smbytes=59,285 max_bytes=59,285 bufs=239 max_bufs=239
194
195   Scheduled Jobs:
196   Level          Type     Pri  Scheduled          Name               Volume
197   ===================================================================================
198   Incremental    Backup    10  23-May-13 23:05    BackupClient1      testvol
199   Full           Backup    11  23-May-13 23:10    BackupCatalog      testvol
200   ====
201
202   Running Jobs:
203   Console connected at 23-May-13 13:34
204   No Jobs running.
205   ====
206
207where the times and the Director’s name will be different according to your setup. This shows that an Incremental job is scheduled to run for the Job :config:option:`Dir/Job = BackupClient1`\  at 1:05am and that at 1:10, a :config:option:`Dir/Job = BackupCatalog`\  is scheduled to run.
208
209Now enter:
210
211.. code-block:: bconsole
212   :caption: status client
213
214   *<input>status client</input>
215   Automatically selected Client: bareos-fd
216   Connecting to Client bareos-fd at bareos:9102
217
218   bareos-fd Version: 13.2.0 (09 April 2013)  x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
219   Daemon started 23-May-13 13:17. Jobs: run=0 running=0.
220    Heap: heap=135,168 smbytes=26,000 max_bytes=26,147 bufs=65 max_bufs=66
221    Sizeof: boffset_t=8 size_t=8 debug=0 trace=0 bwlimit=0kB/s
222
223   Running Jobs:
224   Director connected at: 23-May-13 13:58
225   No Jobs running.
226   ====
227
228In this case, the client is named :config:option:`Dir/Client = bareos-fd`\  your name might be different, but the line beginning with :file:`bareos-fd Version` is printed by your |fd|, so we are now sure it is up and running.
229
230Finally do the same for your |sd| with:
231
232.. code-block:: bconsole
233   :caption: status storage
234
235   *<input>status storage</input>
236   Automatically selected Storage: File
237   Connecting to Storage daemon File at bareos:9103
238
239   bareos-sd Version: 13.2.0 (09 April 2013) x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
240   Daemon started 23-May-13 13:17. Jobs: run=0, running=0.
241    Heap: heap=241,664 smbytes=28,574 max_bytes=88,969 bufs=73 max_bufs=74
242    Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0 bwlimit=0kB/s
243
244   Running Jobs:
245   No Jobs running.
246   ====
247
248   Device status:
249
250   Device "FileStorage" (/var/lib/bareos/storage) is not open.
251   ==
252   ====
253
254   Used Volume status:
255   ====
256
257   ====
258
259You will notice that the default |sd| device is named :config:option:`Dir/Storage = File`\  and that it will use device :file:`/var/lib/bareos/storage`, which is not currently open.
260
261Now, let’s actually run a job with:
262
263
264
265.. code-block:: bconsole
266   :caption: run
267
268   run
269
270
271
272you should get the following output:
273
274
275
276.. code-block:: bconsole
277   :caption: select job
278
279   Automatically selected Catalog: MyCatalog
280   Using Catalog "MyCatalog"
281   A job name must be specified.
282   The defined Job resources are:
283        1: BackupClient1
284        2: BackupCatalog
285        3: RestoreFiles
286   Select Job resource (1-3):
287
288
289
290Here, Bareos has listed the three different Jobs that you can run, and you should choose number 1 and type enter, at which point you will get:
291
292
293
294.. code-block:: bconsole
295   :caption: run job
296
297   Run Backup job
298   JobName:  BackupClient1
299   Level:    Incremental
300   Client:   bareos-fd
301   Format:   Native
302   FileSet:  SelfTest
303   Pool:     Full (From Job resource)
304   NextPool: *None* (From unknown source)
305   Storage:  File (From Job resource)
306   When:     2013-05-23 14:50:04
307   Priority: 10
308   OK to run? (yes/mod/no):
309
310
311
312At this point, take some time to look carefully at what is printed and understand it. It is asking you if it is OK to run a job named :config:option:`dir/job = BackupClient1`\  with FileSet :config:option:`dir/fileset = SelfTest`\  as an Incremental job on your Client, and to use Storage :config:option:`Dir/Storage = File`\  and Pool :config:option:`dir/pool = Full`\ , and finally, it wants to run it now (the current time should be displayed by your console).
313
314Here we have the choice to run (yes), to modify one or more of the above parameters (mod), or to not run the job (no). Please enter yes, at which point you should immediately get the command prompt (an asterisk).
315
316If you wait a few seconds, then enter the command :bcommand:`messages` you will get back something like:
317
318.. TODO: Replace bconsole output by current version of Bareos.
319
320.. code-block:: bconsole
321   :caption: run
322
323   *<input>messages</input>
324   28-Apr-2003 14:30 bareos-sd: Wrote label to prelabeled Volume
325      "TestVolume001" on device /var/lib/bareos/storage
326   28-Apr-2003 14:30 rufus-dir: Bareos 1.30 (28Apr03): 28-Apr-2003 14:30
327   JobId:                  1
328   Job:                    BackupClient1.2003-04-28_14.22.33
329   FileSet:                Full Set
330   Backup Level:           Full
331   Client:                 bareos-fd
332   Start time:             28-Apr-2003 14:22
333   End time:               28-Apr-2003 14:30
334   Files Written:          1,444
335   Bytes Written:          38,988,877
336   Rate:                   81.2 KB/s
337   Software Compression:   None
338   Volume names(s):        TestVolume001
339   Volume Session Id:      1
340   Volume Session Time:    1051531381
341   Last Volume Bytes:      39,072,359
342   FD termination status:  OK
343   SD termination status:  OK
344   Termination:            Backup OK
345   28-Apr-2003 14:30 rufus-dir: Begin pruning Jobs.
346   28-Apr-2003 14:30 rufus-dir: No Jobs found to prune.
347   28-Apr-2003 14:30 rufus-dir: Begin pruning Files.
348   28-Apr-2003 14:30 rufus-dir: No Files found to prune.
349   28-Apr-2003 14:30 rufus-dir: End auto prune.
350
351If you don’t see the output immediately, you can keep entering :bcommand:`messages` until the job terminates.
352
353Instead of typing :bcommand:`messages` multiple times, you can also ask bconsole to wait, until a specific job is finished:
354
355.. code-block:: bconsole
356   :caption: wait
357
358   *<input>wait jobid=1</input>
359
360or just :bcommand:`wait`, which waits for all running jobs to finish.
361
362Another useful command is :bcommand:`autodisplay on`. With autodisplay activated, messages will automatically be displayed as soon as they are ready.
363
364If you do an :command:`ls -l` of your :file:`/var/lib/bareos/storage` directory, you will see that you have the following item:
365
366
367
368.. code-block:: bconsole
369   :caption: volume
370
371   -rw-r-----    1 bareos bareos   39072153 Apr 28 14:30 Full-001
372
373
374
375This is the file Volume that you just wrote and it contains all the data of the job just run. If you run additional jobs, they will be appended to this Volume unless you specify otherwise.
376
377If you would like to stop here, you can simply enter :bcommand:`quit` in the Console program.
378
379If you would like to try restoring the files that you just backed up, read the following section.
380
381.. _restoring:
382
383
384
385Restoring Your Files
386--------------------
387
388:index:`\ <single: Files; Restoring Your>`\  :index:`\ <single: Restoring Your Files>`\
389
390If you have run the default configuration and run the job as demonstrated above, you can restore the backed up files in the Console program by entering:
391
392.. code-block:: bconsole
393   :caption: restore
394
395   *<input>restore all</input>
396   First you select one or more JobIds that contain files
397   to be restored. You will be presented several methods
398   of specifying the JobIds. Then you will be allowed to
399   select which files from those JobIds are to be restored.
400
401   To select the JobIds, you have the following choices:
402        1: List last 20 Jobs run
403        2: List Jobs where a given File is saved
404        3: Enter list of comma separated JobIds to select
405        4: Enter SQL list command
406        5: Select the most recent backup for a client
407        6: Select backup for a client before a specified time
408        7: Enter a list of files to restore
409        8: Enter a list of files to restore before a specified time
410        9: Find the JobIds of the most recent backup for a client
411       10: Find the JobIds for a backup for a client before a specified time
412       11: Enter a list of directories to restore for found JobIds
413       12: Select full restore to a specified Job date
414       13: Cancel
415   Select item:  (1-13):
416
417As you can see, there are a number of options, but for the current demonstration, please enter 5 to do a restore of the last backup you did, and you will get the following output:
418
419
420
421.. code-block:: bconsole
422   :caption: select resource
423
424   Automatically selected Client: bareos-fd
425   The defined FileSet resources are:
426        1: Catalog
427        2: Full Set
428   Select FileSet resource (1-2):
429
430
431
432As you can see, Bareos knows what client you have, and since there was only one, it selected it automatically. Select 2, because you want to restore files from the file set.
433
434
435
436.. code-block:: bconsole
437   :caption: restore filesystem
438
439   +-------+-------+----------+------------+---------------------+---------------+
440   | jobid | level | jobfiles | jobbytes   | starttime           | volumename    |
441   +-------+-------+----------+------------+---------------------+---------------+
442   |     1 | F     |      166 | 19,069,526 | 2013-05-05 23:05:02 | TestVolume001 |
443   +-------+-------+----------+------------+---------------------+---------------+
444   You have selected the following JobIds: 1
445
446   Building directory tree for JobId(s) 1 ...  +++++++++++++++++++++++++++++++++++++++++
447   165 files inserted into the tree and marked for extraction.
448
449   You are now entering file selection mode where you add (mark) and
450   remove (unmark) files to be restored. No files are initially added, unless
451   you used the "all" keyword on the command line.
452   Enter "done" to leave this mode.
453
454   cwd is: /
455   $
456
457
458
459where I have truncated the listing on the right side to make it more readable.
460
461Then Bareos produced a listing containing all the jobs that form the current backup, in this case, there is only one, and the Storage daemon was also automatically chosen. Bareos then took all the files that were in Job number 1 and entered them into a directory tree (a sort of in memory representation of your filesystem). At this point, you can use the :bcommand:`cd` and :bcommand:`ls` or :bcommand:`dir` commands to walk up and down the directory tree
462and view what files will be restored. For example, if you enter :bcommand:`cd /usr/sbin` and then enter :bcommand:`dir` you will get a listing of all the files in the :file:`/usr/sbin/` directory. On your system, the path might be somewhat different. For more information on this, please refer to the :ref:`Restore Command Chapter <RestoreChapter>` of this manual for more details.
463
464To exit this mode, simply enter:
465
466
467
468.. code-block:: bconsole
469   :caption: done
470
471   done
472
473
474
475and you will get the following output:
476
477
478
479.. code-block:: bconsole
480   :caption: job report
481
482   Bootstrap records written to
483      /home/user/bareos/testbin/working/restore.bsr
484   The restore job will require the following Volumes:
485
486      TestVolume001
487   1444 files selected to restore.
488   Run Restore job
489   JobName:         RestoreFiles
490   Bootstrap:      /home/user/bareos/testbin/working/restore.bsr
491   Where:          /tmp/bareos-restores
492   Replace:        always
493   FileSet:        Full Set
494   Backup Client:  rufus-fd
495   Restore Client: rufus-fd
496   Storage:        File
497   JobId:          *None*
498   When:           2005-04-28 14:53:54
499   OK to run? (yes/mod/no):
500   Bootstrap records written to /var/lib/bareos/bareos-dir.restore.1.bsr
501
502   The job will require the following
503      Volume(s)                 Storage(s)                SD Device(s)
504   ===========================================================================
505
506       TestVolume001             File                      FileStorage
507
508   Volumes marked with "*" are online.
509
510
511   166 files selected to be restored.
512
513   Run Restore job
514   JobName:         RestoreFiles
515   Bootstrap:       /var/lib/bareos/bareos-dir.restore.1.bsr
516   Where:           /tmp/bareos-restores
517   Replace:         Always
518   FileSet:         Full Set
519   Backup Client:   bareos-fd
520   Restore Client:  bareos-fd
521   Format:          Native
522   Storage:         File
523   When:            2013-05-23 15:56:53
524   Catalog:         MyCatalog
525   Priority:        10
526   Plugin Options:  *None*
527   OK to run? (yes/mod/no):
528
529
530
531If you answer yes your files will be restored to :file:`/tmp/bareos-restores`. If you want to restore the files to their original locations, you must use the mod option and explicitly set Where: to nothing (or to /). We recommend you go ahead and answer yes and after a brief moment, enter :bcommand:`messages`, at which point you should get a listing of all the files that were restored as well as a summary of the job that looks similar to this:
532
533
534
535.. code-block:: bconsole
536   :caption: job report
537
538   23-May 15:24 bareos-dir JobId 2: Start Restore Job RestoreFiles.2013-05-23_15.24.01_10
539   23-May 15:24 bareos-dir JobId 2: Using Device "FileStorage" to read.
540   23-May 15:24 bareos-sd JobId 2: Ready to read from volume "TestVolume001" on device "FileStorage" (/var/lib/bareos/storage).
541   23-May 15:24 bareos-sd JobId 2: Forward spacing Volume "TestVolume001" to file:block 0:194.
542   23-May 15:58 bareos-dir JobId 3: Bareos bareos-dir 13.2.0 (09Apr13):
543     Build OS:               x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
544     JobId:                  2
545     Job:                    RestoreFiles.2013-05-23_15.58.48_11
546     Restore Client:         bareos-fd
547     Start time:             23-May-2013 15:58:50
548     End time:               23-May-2013 15:58:52
549     Files Expected:         166
550     Files Restored:         166
551     Bytes Restored:         19,069,526
552     Rate:                   9534.8 KB/s
553     FD Errors:              0
554     FD termination status:  OK
555     SD termination status:  OK
556     Termination:            Restore OK
557
558
559
560After exiting the Console program, you can examine the files in :file:`/tmp/bareos-restores`, which will contain a small directory tree with all the files. Be sure to clean up at the end with:
561
562.. code-block:: shell-session
563   :caption: remove restore directory
564
565   <command>rm</command> -rf /tmp/bareos-restore
566
567Quitting the Console Program
568----------------------------
569
570:index:`\ <single: Program; Quitting the Console>`\  :index:`\ <single: Quitting the Console Program>`\
571
572Simply enter the command :bcommand:`quit`.
573
574.. _SecondClient:
575
576.. _section-AddAClient:
577
578Adding a Client
579---------------
580
581:index:`\ <single: Client; Adding a Second>`
582:index:`\ <single: Adding a Client>`
583
584If you have gotten the example shown above to work on your system, you may be ready to add a second Client (|fd|). That is you have a second machine that you would like backed up. Lets assume, following settings about the machine you want to add to your backup environment:
585
586Hostname (FQDN)
587   :strong:`client2.example.com`
588
589IP Address
590   192.168.0.2
591
592OS
593   Linux (otherwise the paths may differ)
594
595For this you have to make changes on the server side (|dir|) and the client side.
596
597Client: install package
598~~~~~~~~~~~~~~~~~~~~~~~
599
600See :ref:`InstallChapter` about how to add the Bareos repository. The only part you need installed on the other machine is the **bareos-filedaemon**.
601
602Director: configure client
603~~~~~~~~~~~~~~~~~~~~~~~~~~
604
605Bareos :sinceVersion:`16.2.4: configure add` offers the :ref:`configure add command <section-bcommandConfigure>` to add resources to the |dir|.
606
607Start the :command:`bconsole` and use the :bcommand:`configure add client` command. Address must be a DNS resolvable name or an IP address.
608
609.. code-block:: bconsole
610   :caption: add a client
611
612   *<input>configure add client name=client2-fd address=192.168.0.2 password=secret</input>
613   Created resource config file "/etc/bareos/bareos-dir.d/client/client2-fd.conf":
614   Client {
615     Name = client2-fd
616     Address = 192.168.0.2
617     Password = secret
618   }
619
620This creates two resource configuration files:
621
622-
623
624   :file:`/etc/bareos/bareos-dir.d/client/client2-fd.conf`
625
626-  :file:`/etc/bareos/bareos-dir-export/client/client2-fd/bareos-fd.d/director/bareos-dir.conf` (assuming your director resource is named **bareos-dir**)
627
628The :file:`/etc/bareos/bareos-dir-export/client/client2-fd/bareos-fd.d/director/bareos-dir.conf` is the required resource needed on the |fd|. You can copy it to the destination:
629
630.. code-block:: shell-session
631   :caption: Copy the bareos-fd director resource to the new client
632
633   scp /etc/bareos/bareos-dir-export/client/client2-fd/bareos-fd.d/director/bareos-dir.conf root@client2.example.com:/etc/bareos/bareos-fd.d/director/
634
635Manual configuration
636^^^^^^^^^^^^^^^^^^^^
637
638Alternatively you can configure your resources manually. On the |dir| create the file
639
640.. code-block:: bareosconfig
641   :caption: bareos-dir.d/client/client2-fd.conf
642
643   Client {
644     Name = client2-fd
645     Address = 192.168.0.2
646     Password = secret
647   }
648
649Reload or restart your |dir|:
650
651.. code-block:: bconsole
652   :caption: reload the Director configuration
653
654   *<input>reload</input>
655   reloaded
656
657The corresponding |fd| director resource can be created directly on the client, see below.
658
659Client: configure
660~~~~~~~~~~~~~~~~~
661
662The package **bareos-filedaemon** :sinceVersion:`16.2.4: Client resource files` brings several configuration files:
663
664-
665
666   :file:`/etc/bareos/bareos-fd.d/client/myself.conf`
667
668-
669
670   :file:`/etc/bareos/bareos-fd.d/director/bareos-dir.conf`
671
672-
673
674   :file:`/etc/bareos/bareos-fd.d/director/bareos-mon.conf`
675
676-
677
678   :file:`/etc/bareos/bareos-fd.d/messages/Standard.conf`
679
680In detail:
681
682:file:`client/myself.conf`
683   defines the name of the client. The default is :file:`<hostname>-fd`. Changes are only required, if you want to use another name or en- or disable special |fd| features. See :ref:`ClientResourceClient`.
684
685:file:`director/bareos-dir.conf`
686   gives the |dir| **bareos-dir** full access to this |fd|. During installation, the :config:option:`fd/director/Password`\  is set to a random default. Adapt the name and/or the password to your |dir|. (The name **bareos-dir** is the default |dir| name since Bareos :sinceVersion:`16.2.4: bareos-dir is the default |dir| name`.)
687
688:file:`director/bareos-mon.conf`
689   gives the |dir| **bareos-mon** restricted access to this |fd|. During installation, the :config:option:`fd/director/Password`\  is set to a random value. This resource is intended to be used by the local **bareos-tray-monitor**.
690
691:file:`messages/Standard.conf`
692   defines, how messages should be handled. The default sends all relevant messages to the |dir|.
693
694If your |dir| is named **bareos-dir**, the :file:`/etc/bareos/bareos-fd.d/director/bareos-dir.conf` may already be overwritten by the file you copied from the |dir|. If your Director has another name, an addition resource file will exists. You can define an arbitrary number of |dir|’s in your |fd| configuration. However, normally you will only have one :config:option:`Fd/Director`\  with
695full control of your |fd| and optional one :config:option:`Fd/Director`\  for monitoring (used by the |traymonitor|).
696
697Anyhow, the resource will look similar to this:
698
699.. code-block:: bareosconfig
700   :caption: bareos-fd.d/director/bareos-dir.conf
701
702   Director {
703     Name = bareos-dir
704     Password = "[md5]5ebe2294ecd0e0f08eab7690d2a6ee69"
705   }
706
707After a restart of the |fd| to reload the configuration this resource allows the access for a |dir| with name **bareos-dir** and password **secret** (stored in MD5 format).
708
709.. code-block:: shell-session
710   :caption: restart bareos-fd
711
712   service bareos-fd restart
713
714
715Manual configuration
716^^^^^^^^^^^^^^^^^^^^
717
718If you have not created the :config:option:`Fd/Director`\  by :bcommand:`configure`, you can create it also manually. If your |dir| is also named **bareos-dir**, modify or create the file :file:`/etc/bareos/bareos-fd.d/director/bareos-dir.conf`:
719
720.. code-block:: bareosconfig
721   :caption: bareos-fd.d/director/bareos-dir.conf
722
723   Director {
724     Name = "bareos-dir"   # Name of your Bareos Director
725     Password = "secret"   # Password (cleartext or MD5) must be identical
726                           # to the password of your client reosurce in the Direcotr
727                           # (bareos-dir.d/client/client2-fd.conf)
728   }
729
730See the relation between resource names and password of the different Bareos components in :ref:`section-resource-relation`.
731
732If your are not using the :ref:`section-SubdirectoryConfigurationScheme`, make sure that this resource file gets included in your |fd| configuration. You can verify this by
733
734.. code-block:: shell-session
735   :caption: show how bareos-fd would read the current configuration files
736
737   bareos-fd -xc
738
739After modifying the file, you have to restart the |fd|:
740
741.. code-block:: shell-session
742   :caption: restart bareos-fd
743
744   service bareos-fd restart
745
746Director: test client, add a job
747~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
748
749The following example show how to
750
751-  Verify the network connection from |dir| to the |fd|.
752
753-  Add a job resource.
754
755-  Dry-run the job (:bcommand:`estimate listing`).
756
757-  Run the job.
758
759-  Wait for the job to finish.
760
761-  Verify the job.
762
763.. code-block:: bconsole
764   :caption: test the client and add a job resource
765
766   *<input>status client=client2-fd</input>
767   ...
768   *<input>configure add job name=client2-job client=client2-fd jobdefs=DefaultJob</input>
769   Created resource config file "/etc/bareos/bareos-dir.d/job/client2-job.conf":
770   Job {
771     Name = client2-job
772     Client = client2-fd
773     JobDefs = DefaultJob
774   }
775   *<input>estimate listing job=client2-job</input>
776   ...
777   *<input>run job=client2-job</input>
778   ...
779   *<input>wait jobid=...</input>
780   ...
781   *<input>list joblog jobid=...</input>
782   ...
783   *<input>list files jobid=...</input>
784   ...
785   *<input>list volumes</input>
786   ...
787
788Patience When Starting Daemons or Mounting Blank Tapes
789------------------------------------------------------
790
791When you start the Bareos daemons, the Storage daemon attempts to open all defined storage devices and verify the currently mounted Volume (if configured). Until all the storage devices are verified, the Storage daemon will not accept connections from the Console program. If a tape was previously used, it will be rewound, and on some devices this can take several minutes. As a consequence, you may need to have a bit of patience when first contacting the Storage daemon after starting the daemons.
792If you can see your tape drive, once the lights stop flashing, the drive will be ready to be used.
793
794The same considerations apply if you have just mounted a blank tape in a drive. It can take a minute or two before the drive properly recognizes that the tape is blank. If you attempt to :bcommand:`mount` the tape with the Console program during this recognition period, it is quite possible that you will hang your SCSI driver. As a consequence, you are again urged to have patience when inserting blank tapes. Let the device settle down before attempting to access it.
795
796.. _Pool:
797
798Pools
799-----
800
801:index:`\ <single: Pool; Overview>`\
802
803Creating the Pool is automatically done when the |dir| starts, so if you understand Pools, you can skip to the next section.
804
805When you run a backup job, one of the things that Bareos must know is what Volumes to use. Instead of specifying a Volume (tape) directly, you specify which Pool of Volumes you want Bareos to consult when it wants a Volume for writing backups. Bareos will select the first available Volume from the Pool that is appropriate for the :config:option:`dir/job/Storage`\  you have specified for the Job being run. When a volume has filled up with data, Bareos will change its
806**VolStatus** from **Append** to **Full**, and then Bareos will use the next volume and so on. If no appendable Volume exists in the Pool, the Director will attempt to recycle an old Volume. For details, please read the :ref:`RecyclingChapter` chapter.
807
808If there are still no appendable Volumes available, Bareos will send a message requesting the operator to create an appropriate Volume.
809
810Bareos keeps track of the Pool name, the volumes contained in the Pool, and a number of attributes of each of those Volumes.
811
812When Bareos starts, it ensures that all Pool resource definitions have been recorded in the catalog. You can verify this by entering:
813
814.. code-block:: bconsole
815   :caption: list pools
816
817   *<input>list pools</input>
818   +--------+--------------+---------+---------+----------+---------------+
819   | PoolId | Name         | NumVols | MaxVols | PoolType | LabelFormat   |
820   +--------+--------------+---------+---------+----------+---------------+
821   | 1      | Full         | 1       | 100     | Backup   | Full-         |
822   | 2      | Differential | 0       | 100     | Backup   | Differential- |
823   | 3      | Incremental  | 1       | 100     | Backup   | Incremental-  |
824   | 4      | Scratch      | 0       | 0       | Backup   | *             |
825   +--------+--------------+---------+---------+----------+---------------+
826
827Other Useful Console Commands
828-----------------------------
829
830:index:`\ <single: Console; Commands; Useful>`\
831
832help
833   Show the list all all available commands.
834
835help list
836   Show detail information about a specific command, in this case the command :bcommand:`list`.
837
838status dir
839   :index:`\ <single: Console; Command; status dir>`\  Print a status of all running jobs and jobs scheduled in the next 24 hours.
840
841status
842   :index:`\ <single: Console; Command; status>`\  The console program will prompt you to select a daemon type, then will request the daemon’s status.
843
844status jobid=nn
845   :index:`\ <single: Console; Command; status jobid>`\  Print a status of JobId nn if it is running. The Storage daemon is contacted and requested to print a current status of the job as well.
846
847list pools
848   :index:`\ <single: Console; Command; list pools>`\  List the pools defined in the Catalog (normally only Default is used).
849
850list volumes
851   :index:`\ <single: Console; Command; list volumes>`\  Lists all the media defined in the Catalog.
852
853list jobs
854   :index:`\ <single: Console; Command; list jobs>`\  Lists all jobs in the Catalog that have run.
855
856list jobid=nn
857   :index:`\ <single: Console; Command; list jobid>`\  Lists JobId nn from the Catalog.
858
859list jobtotals
860   :index:`\ <single: Console; Command; list jobtotals>`\  Lists totals for all jobs in the Catalog.
861
862list files jobid=nn
863   :index:`\ <single: Console; Command; list files jobid>`\  List the files that were saved for JobId nn.
864
865list jobmedia
866   :index:`\ <single: Console; Command; list jobmedia>`\  List the media information for each Job run.
867
868messages
869   :index:`\ <single: Console; Command; messages>`\  Prints any messages that have been directed to the console.
870
871quit
872   :index:`\ <single: Console; Command; quit>`\  Exit or quit the console program.
873
874Most of the commands given above, with the exception of list, will prompt you for the necessary arguments if you simply enter the command name.
875
876The full list of commands is shown in the chapter :ref:`section-ConsoleCommands`.
877
878