Tutorial
This 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 /var/lib/bareos/storage/
directory.
The general flow of running Bareos is:
Start the Database
Start the Bareos Daemons
Start the Console program to interact with the Bareos Director
Run a job
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
Add a second client.
Each of these steps is described in more detail below.
Installing Bareos
For installing Bareos, follow the instructions from the Installing the Bareos Server chapter.
Starting the Daemons
Assuming you have installed the packages, to start the three daemons, from your installation directory, simply enter:
service bareos-dir start
service bareos-sd start
service bareos-fd start
Using the Director to Query and Start Jobs
To communicate with the Bareos Director and to query the state of Bareos or run jobs, the bconsole program can be used as a textual interface. Alternatively, for most purposes, also the |webui| can be used, but for simplicity, here we will describe only the bconsole program.
The bconsole runs the Bareos Console program, which connects to the Bareos Director. 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 Bareos Director. Normally, the Console program will print something similar to the following:
root@host:~# bconsole
Connecting to Director bareos:9101
Enter a period to cancel a command.
*
The asterisk is the console command prompt.
Type help to see a list of available commands:
*help
Command Description
======= ===========
add Add media to a pool
autodisplay Autodisplay console messages
automount Automount after label
cancel Cancel a job
create Create DB Pool from resource
delete Delete volume, pool or job
disable Disable a job
enable Enable a job
estimate Performs FileSet estimate, listing gives full listing
exit Terminate Bconsole session
export Export volumes from normal slots to import/export slots
gui Non-interactive gui mode
help Print help on specific command
import Import volumes from import/export slots to normal slots
label Label a tape
list List objects from catalog
llist Full or long list like list command
messages Display pending messages
memory Print current memory usage
mount Mount storage
move Move slots in an autochanger
prune Prune expired records from catalog
purge Purge records from catalog
quit Terminate Bconsole session
query Query catalog
restore Restore files
relabel Relabel a tape
release Release storage
reload Reload conf file
rerun Rerun a job
run Run a job
status Report status
setbandwidth Sets bandwidth
setdebug Sets debug level
setip Sets new client address -- if authorized
show Show resource records
sqlquery Use SQL to query catalog
time Print current time
trace Turn on/off trace to file
unmount Unmount storage
umount Umount - for old-time Unix guys, see unmount
update Update volume, pool or stats
use Use specific catalog
var Does variable expansion
version Print Director version
wait Wait until no jobs are running
Details of the console program’s commands are explained in the Bareos Console chapter.
Running a Job
At this point, we assume you have done the following:
Started the Database
Installed Bareos
Prepared the database for Bareos
Started Bareos Director, Storage Daemon and File Daemon
Invoked the Console program with bconsole
Furthermore, we assume for the moment you are using the default configuration files.
At this point, enter the show filesets and you should get something similar this:
*show filesets
...
FileSet {
Name = "SelfTest"
Include {
Options {
Signature = MD5
}
File = "/usr/sbin"
}
}
FileSet {
Name = "Catalog"
Include {
Options {
Signature = MD5
}
File = "/var/lib/bareos/bareos.sql"
File = "/etc/bareos"
}
}
...
One of the FileSets is the pre-defined SelfTest (Dir->Fileset)
FileSet that will backup the /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 Catalog (Dir->Fileset)
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 =
line in the
Fileset (Dir)
resource.
Now is the time to run your first backup job. We are going to backup your Bareos source directory to a File Volume in your /var/lib/bareos/storage/
directory just to show you how easy it is. Now enter:
*status dir
bareos-dir Version: 13.2.0 (09 April 2013) x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
Daemon started 23-May-13 13:17. Jobs: run=0, running=0 mode=0
Heap: heap=270,336 smbytes=59,285 max_bytes=59,285 bufs=239 max_bufs=239
Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 23-May-13 23:05 BackupClient1 testvol
Full Backup 11 23-May-13 23:10 BackupCatalog testvol
====
Running Jobs:
Console connected at 23-May-13 13:34
No Jobs running.
====
where 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 BackupClient1 (Dir->Job)
at 1:05am and that at 1:10, a BackupCatalog (Dir->Job)
is scheduled to run.
Now enter:
*status client
Automatically selected Client: bareos-fd
Connecting to Client bareos-fd at bareos:9102
bareos-fd Version: 13.2.0 (09 April 2013) x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
Daemon started 23-May-13 13:17. Jobs: run=0 running=0.
Heap: heap=135,168 smbytes=26,000 max_bytes=26,147 bufs=65 max_bufs=66
Sizeof: boffset_t=8 size_t=8 debug=0 trace=0 bwlimit=0kB/s
Running Jobs:
Director connected at: 23-May-13 13:58
No Jobs running.
====
In this case, the client is named bareos-fd (Dir->Client)
your name might be different, but the line beginning with bareos-fd Version
is printed by your Bareos File Daemon, so we are now sure it is up and running.
Finally do the same for your Bareos Storage Daemon with:
*status storage
Automatically selected Storage: File
Connecting to Storage daemon File at bareos:9103
bareos-sd Version: 13.2.0 (09 April 2013) x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
Daemon started 23-May-13 13:17. Jobs: run=0, running=0.
Heap: heap=241,664 smbytes=28,574 max_bytes=88,969 bufs=73 max_bufs=74
Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0 bwlimit=0kB/s
Running Jobs:
No Jobs running.
====
Device status:
Device "FileStorage" (/var/lib/bareos/storage) is not open.
==
====
Used Volume status:
====
====
You will notice that the default Bareos Storage Daemon device is named File (Dir->Storage)
and that it will use device /var/lib/bareos/storage
, which is not currently open.
Now, let’s actually run a job with:
run
you should get the following output:
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
1: BackupClient1
2: BackupCatalog
3: RestoreFiles
Select Job resource (1-3):
Here, 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:
Run Backup job
JobName: BackupClient1
Level: Incremental
Client: bareos-fd
Format: Native
FileSet: SelfTest
Pool: Full (From Job resource)
NextPool: *None* (From unknown source)
Storage: File (From Job resource)
When: 2013-05-23 14:50:04
Priority: 10
OK to run? (yes/mod/no):
At 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 BackupClient1 (Dir->Job)
with FileSet SelfTest (Dir->Fileset)
as an Incremental job on your Client, and to use Storage File (Dir->Storage)
and Pool Full (Dir->Pool)
, and finally, it wants to run it now (the current time should be displayed by your console).
Here 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).
If you wait a few seconds, then enter the command messages you will get back something like:
*messages
28-Apr-2003 14:30 bareos-sd: Wrote label to prelabeled Volume
"TestVolume001" on device /var/lib/bareos/storage
28-Apr-2003 14:30 rufus-dir: Bareos 1.30 (28Apr03): 28-Apr-2003 14:30
JobId: 1
Job: BackupClient1.2003-04-28_14.22.33
FileSet: Full Set
Backup Level: Full
Client: bareos-fd
Start time: 28-Apr-2003 14:22
End time: 28-Apr-2003 14:30
Files Written: 1,444
Bytes Written: 38,988,877
Rate: 81.2 KB/s
Software Compression: None
Volume names(s): TestVolume001
Volume Session Id: 1
Volume Session Time: 1051531381
Last Volume Bytes: 39,072,359
FD termination status: OK
SD termination status: OK
Termination: Backup OK
28-Apr-2003 14:30 rufus-dir: Begin pruning Jobs.
28-Apr-2003 14:30 rufus-dir: No Jobs found to prune.
28-Apr-2003 14:30 rufus-dir: Begin pruning Files.
28-Apr-2003 14:30 rufus-dir: No Files found to prune.
28-Apr-2003 14:30 rufus-dir: End auto prune.
If you don’t see the output immediately, you can keep entering messages until the job terminates.
Instead of typing messages multiple times, you can also ask bconsole to wait, until a specific job is finished:
*wait jobid=1
or just wait, which waits for all running jobs to finish.
Another useful command is autodisplay on. With autodisplay activated, messages will automatically be displayed as soon as they are ready.
If you do an ls -l of your /var/lib/bareos/storage
directory, you will see that you have the following item:
-rw-r----- 1 bareos bareos 39072153 Apr 28 14:30 Full-001
This 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.
If you would like to stop here, you can simply enter quit in the Console program.
If you would like to try restoring the files that you just backed up, read the following section.
Restoring Your Files
If 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:
*restore all
First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.
To select the JobIds, you have the following choices:
1: List last 20 Jobs run
2: List Jobs where a given File is saved
3: Enter list of comma separated JobIds to select
4: Enter SQL list command
5: Select the most recent backup for a client
6: Select backup for a client before a specified time
7: Enter a list of files to restore
8: Enter a list of files to restore before a specified time
9: Find the JobIds of the most recent backup for a client
10: Find the JobIds for a backup for a client before a specified time
11: Enter a list of directories to restore for found JobIds
12: Select full restore to a specified Job date
13: Cancel
Select item: (1-13):
As 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:
Automatically selected Client: bareos-fd
The defined FileSet resources are:
1: Catalog
2: Full Set
Select FileSet resource (1-2):
As 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.
+-------+-------+----------+------------+---------------------+---------------+
| jobid | level | jobfiles | jobbytes | starttime | volumename |
+-------+-------+----------+------------+---------------------+---------------+
| 1 | F | 166 | 19,069,526 | 2013-05-05 23:05:02 | TestVolume001 |
+-------+-------+----------+------------+---------------------+---------------+
You have selected the following JobIds: 1
Building directory tree for JobId(s) 1 ... +++++++++++++++++++++++++++++++++++++++++
165 files inserted into the tree and marked for extraction.
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
cwd is: /
$
where I have truncated the listing on the right side to make it more readable.
Then 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 cd and ls or dir commands to walk up and down the directory tree
and view what files will be restored. For example, if you enter cd /usr/sbin and then enter dir you will get a listing of all the files in the /usr/sbin/
directory. On your system, the path might be somewhat different. For more information on this, please refer to the Restore Command Chapter of this manual for more details.
To exit this mode, simply enter:
done
and you will get the following output:
Bootstrap records written to
/home/user/bareos/testbin/working/restore.bsr
The restore job will require the following Volumes:
TestVolume001
1444 files selected to restore.
Run Restore job
JobName: RestoreFiles
Bootstrap: /home/user/bareos/testbin/working/restore.bsr
Where: /tmp/bareos-restores
Replace: always
FileSet: Full Set
Backup Client: rufus-fd
Restore Client: rufus-fd
Storage: File
JobId: *None*
When: 2005-04-28 14:53:54
OK to run? (yes/mod/no):
Bootstrap records written to /var/lib/bareos/bareos-dir.restore.1.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
TestVolume001 File FileStorage
Volumes marked with "*" are online.
166 files selected to be restored.
Run Restore job
JobName: RestoreFiles
Bootstrap: /var/lib/bareos/bareos-dir.restore.1.bsr
Where: /tmp/bareos-restores
Replace: Always
FileSet: Full Set
Backup Client: bareos-fd
Restore Client: bareos-fd
Format: Native
Storage: File
When: 2013-05-23 15:56:53
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no):
If you answer yes your files will be restored to /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 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:
23-May 15:24 bareos-dir JobId 2: Start Restore Job RestoreFiles.2013-05-23_15.24.01_10
23-May 15:24 bareos-dir JobId 2: Using Device "FileStorage" to read.
23-May 15:24 bareos-sd JobId 2: Ready to read from volume "TestVolume001" on device "FileStorage" (/var/lib/bareos/storage).
23-May 15:24 bareos-sd JobId 2: Forward spacing Volume "TestVolume001" to file:block 0:194.
23-May 15:58 bareos-dir JobId 3: Bareos bareos-dir 13.2.0 (09Apr13):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 6.0 (squeeze)
JobId: 2
Job: RestoreFiles.2013-05-23_15.58.48_11
Restore Client: bareos-fd
Start time: 23-May-2013 15:58:50
End time: 23-May-2013 15:58:52
Files Expected: 166
Files Restored: 166
Bytes Restored: 19,069,526
Rate: 9534.8 KB/s
FD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Restore OK
After exiting the Console program, you can examine the files in /tmp/bareos-restores
, which will contain a small directory tree with all the files. Be sure to clean up at the end with:
root@host:~# rm -rf /tmp/bareos-restore
Quitting the Console Program
Simply enter the command quit.
Adding a Client
If you have gotten the example shown above to work on your system, you may be ready to add a second Client (Bareos File Daemon). 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:
- Hostname (FQDN)
client2.example.com
- IP Address
192.168.0.2
- OS
Linux (otherwise the paths may differ)
For this you have to make changes on the server side (Bareos Director) and the client side.
Client: install package
See Installing the Bareos Server about how to add the Bareos repository. The only part you need installed on the other machine is the bareos-filedaemon.
Director: configure client
Bareos Version >= 16.2.4 offers the configure add command to add resources to the Bareos Director.
Start the bconsole and use the configure add client command. Address must be a DNS resolvable name or an IP address.
*configure add client name=client2-fd address=192.168.0.2 password=secret
Created resource config file "/etc/bareos/bareos-dir.d/client/client2-fd.conf":
Client {
Name = client2-fd
Address = 192.168.0.2
Password = secret
}
This creates two resource configuration files:
/etc/bareos/bareos-dir.d/client/client2-fd.conf
/etc/bareos/bareos-dir-export/client/client2-fd/bareos-fd.d/director/bareos-dir.conf
(assuming your director resource is named bareos-dir)
The /etc/bareos/bareos-dir-export/client/client2-fd/bareos-fd.d/director/bareos-dir.conf
is the required resource needed on the Bareos File Daemon. You can copy it to the destination:
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/
Manual configuration of client
Alternatively you can configure your resources manually. On the Bareos Director create the file
Reload or restart your Bareos Director:
*reload
reloaded
The corresponding Bareos File Daemon director resource can be created directly on the client, see below.
Client: configure
The package bareos-filedaemon Version >= 16.2.4 brings several configuration files:
/etc/bareos/bareos-fd.d/client/myself.conf
/etc/bareos/bareos-fd.d/director/bareos-dir.conf
/etc/bareos/bareos-fd.d/director/bareos-mon.conf
/etc/bareos/bareos-fd.d/messages/Standard.conf
In detail:
client/myself.conf
defines the name of the client. The default is
<hostname>-fd
. Changes are only required, if you want to use another name or en- or disable special Bareos File Daemon features. See Client Resource.director/bareos-dir.conf
gives the Bareos Director bareos-dir full access to this Bareos File Daemon. During installation, the
Password (Fd->Director)
is set to a random default. Adapt the name and/or the password to your Bareos Director. (The name bareos-dir is the default Bareos Director name since Bareos Version >= 16.2.4.)director/bareos-mon.conf
gives the Bareos Director bareos-mon restricted access to this Bareos File Daemon. During installation, the
Password (Fd->Director)
is set to a random value. This resource is intended to be used by the local bareos-tray-monitor.messages/Standard.conf
defines, how messages should be handled. The default sends all relevant messages to the Bareos Director.
If your Bareos Director is named bareos-dir, the /etc/bareos/bareos-fd.d/director/bareos-dir.conf
may already be overwritten by the file you copied from the Bareos Director. If your Director has another name, an addition resource file will exists. You can define an arbitrary number of Bareos Director’s in your Bareos File Daemon configuration. However, normally you will only have one Director (Fd)
with
full control of your Bareos File Daemon and optional one Director (Fd)
for monitoring (used by the Bareos Traymonitor).
Anyhow, the resource will look similar to this:
After a restart of the Bareos File Daemon to reload the configuration this resource allows the access for a Bareos Director with name bareos-dir and password secret (stored in MD5 format).
service bareos-fd restart
Manual configuration
If you have not created the Director (Fd)
by configure, you can create it also manually. If your Bareos Director is also named bareos-dir, modify or create the file /etc/bareos/bareos-fd.d/director/bareos-dir.conf
:
See the relation between resource names and password of the different Bareos components in Relation between resource names and passwords.
If your are not using the Subdirectory Configuration Scheme, make sure that this resource file gets included in your Bareos File Daemon configuration. You can verify this by
bareos-fd --export-config
After modifying the file, you have to restart the Bareos File Daemon:
service bareos-fd restart
Director: test client, add a job
The following example show how to
Verify the network connection from Bareos Director to the Bareos File Daemon.
Add a job resource.
Dry-run the job (estimate listing).
Run the job.
Wait for the job to finish.
Verify the job.
*status client=client2-fd
...
*configure add job name=client2-job client=client2-fd jobdefs=DefaultJob
Created resource config file "/etc/bareos/bareos-dir.d/job/client2-job.conf":
Job {
Name = client2-job
Client = client2-fd
JobDefs = DefaultJob
}
*estimate listing job=client2-job
...
*run job=client2-job
...
*wait jobid=...
...
*list joblog jobid=...
...
*list files jobid=...
...
*list volumes
...
Patience When Starting Daemons or Mounting Blank Tapes
When 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. If you can see your tape drive, once the lights stop flashing, the drive will be ready to be used.
The 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 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.
Pools
Creating the Pool is automatically done when the Bareos Director starts, so if you understand Pools, you can skip to the next section.
When 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 Storage (Dir->Job)
you have specified for the Job being run. When a volume has filled up with data, Bareos will change its
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 Automatic Volume Recycling chapter.
If there are still no appendable Volumes available, Bareos will send a message requesting the operator to create an appropriate Volume.
Bareos keeps track of the Pool name, the volumes contained in the Pool, and a number of attributes of each of those Volumes.
When Bareos starts, it ensures that all Pool resource definitions have been recorded in the catalog. You can verify this by entering:
*list pools
+--------+--------------+---------+---------+----------+---------------+
| PoolId | Name | NumVols | MaxVols | PoolType | LabelFormat |
+--------+--------------+---------+---------+----------+---------------+
| 1 | Full | 1 | 100 | Backup | Full- |
| 2 | Differential | 0 | 100 | Backup | Differential- |
| 3 | Incremental | 1 | 100 | Backup | Incremental- |
| 4 | Scratch | 0 | 0 | Backup | * |
+--------+--------------+---------+---------+----------+---------------+
Other Useful Console Commands
- help
Show the list all all available commands.
- help list
Show detail information about a specific command, in this case the command list.
- status dir
Print a status of all running jobs and jobs scheduled in the next 24 hours.
- status
The console program will prompt you to select a daemon type, then will request the daemon’s status.
- status jobid=nn
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.
- list pools
List the pools defined in the Catalog (normally only Default is used).
- list volumes
Lists all the media defined in the Catalog.
- list jobs
Lists all jobs in the Catalog that have run.
- list jobid=nn
Lists JobId nn from the Catalog.
- list jobtotals
Lists totals for all jobs in the Catalog.
- list files jobid=nn
List the files that were saved for JobId nn.
- list jobmedia
List the media information for each Job run.
- messages
Prints any messages that have been directed to the console.
- quit
Exit or quit the console program.
Most of the commands given above, with the exception of list, will prompt you for the necessary arguments if you simply enter the command name.
The full list of commands is shown in the chapter Console Commands.