Additional FileSet configurations (optional)
I’ve included two more examples of a FileSet configuration. For example, we can include and exclude specific files and directories. Therefore, if you wanted to take a backup of the root directory, but not directories such as /tmp, /proc or /sys, just exclude those directories in the exclude section like this.
Name = "RootBackup_FileSet"
File = /
File = /proc
File = /sys
File = /tmp
The next example shows how to backup the My Documents folder on a windows machine.
Name = “MyDocuments”
Signature = SHA1
File = “c:/My Documents”
Though its important to note that for windows machines, you need to specify a forward slash between the different directories, (so no, c:/ is not a typo). And if there are spaces in the directories, you need to include quotes. Furthermore, if the directory or file has a quote in it, you must escape it with a quote by using the backslash .
This is the Storage property, which again, is fairly self-explanatory. However, it is important to note that the Device and Media Type names must match the Device and Media Type name that we added to the Device property in the bacula-sd.conf file earlier in this article.
#Name of this storage.
Name = DataStorage
#Address of the storage daemon
Address = 192.168.248.4 # N.B. Use a fully qualified name here
SDPort = 9103
#Password required to connect.
Password = "STORAGE CONFIGURATION PASSWORD"
#This is the unique name in the storage daemon configuration file that we tackle a little further up.
#This and the one below it must match up.
Device = BackupDevice
Media Type = BackupDisk
#Number of concurrent jobs.
Maximum Concurrent Jobs = 5 # run up to 5 jobs at the same time
The messages property came pre-defined by the Bacula installation and there is no need to make any changes to that.
Name = Standard
mailcommand = "/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: %t %e of %c %l" %r"
operatorcommand = "/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: Intervention needed for %j" %r"
mail = root = all, !skipped operator = root = mount console = all, !skipped, !saved
append = "/var/log/bacula/bacula.log" = all, !skipped
catalog = all
Finally, the last property that we will look at on the server side is the Pool configuration.
#Unique name of this pool
Name = File
#The type of pool that we are defining.
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
LabelFormat = "Vol-" # Auto label
And that is it. Now save the file and exit to the terminal.
Before we move on to the client, we’ll check to make sure that there are no configuration errors:
sudo bacula-dir -tc /etc/bacula/bacula-dir.conf
If that returns without any errors, then restart the service:
sudo systemctl restart bacula-dir.service
Finally, make sure that the service restarted successfully with the new changes.
sudo systemctl status bacula-dir.service
That’s it for the server, now let’s jump over to the client and configure that.
Configuring Bacula on the client
You should already have installed the bacula-client package, and the service should be running. So, navigate to /etc/bacula directory and take a backup of the bacula-fd.conf file.
sudo cp /etc/bacula/bacula-fd.conf /etc/bacula/bacula-fd.conf.backup
Then, edit the bacula-fd.conf file and add the director setting below, making sure to set the name equal to the name of the director on the server-side configuration. Additionally, the password must equal to the password in the client configuration on the server.
Name = bacula_server-dir
Password = "MyPassword"
Name = desktop1804-fd
FDport = 9102
WorkingDirectory = /var/lib/bacula
Pid Directory = /run/bacula
Maximum Concurrent Jobs = 20
Plugin Directory = /usr/lib/bacula
FDAddress = 192.168.248.3
Finally, edit the FDAddress property and change it to the fully qualified host name or the IP address of the client.
Then, save the file and then restart the service.
sudo systemctl restart bacula-fd.service
That takes care of the configuration part on the client and it’s now time to fire up the console and run a backup job.
Backing up the client
On the server, log in to the bacula console
When successfully logged in, enter
and then select the number matching the Backup_Desktop1804 entry, in this example that is 2.
Type 2 and hit enter.
Then enter yes and hit enter. That will start the backup job.
Now that the job is running, let’s check the status of it. At the prompt enter:
Then select 1 for Director
This will give you a list of the jobs either currently executing or that has already been executed.
In the screenshot, the job has job Id 9, it was a full backup of 235 files, totaling 1.41 MB. The job executed successfully on the 3rd of April 2019 at 16:17 and the Job resource that used was Backup_Desktop1804.
Exit the console by typing quit and then look in the /backup directory. In there should be a file called Vol-0001 and this is the file where Bacula has stored the backup of our client..
Restoring files to the client
Now, we will generate some new files on the client, perform a new backup and then restore those files and validate to make sure that the restore worked.
To generate the files, you can either download some files from the internet, generate some text files or copy some files from somewhere on the hard drive. Just make sure that the files go into /home/<your username>. For this example, they will go in /home/chris.
For this example, I am will generate a couple of text files, called backmeup1.txt and backmeup2.txt. Inside those files, I will add some random text and then run a backup like we did in the previous section.
Here I have two different txt files, containing different text stored on the client’s home directory. We’ll now run the backup process that we did in the previous section, to back these new files up and then we’ll add the configuration that will enable us to perform a restore.
After you have completed the backup, you can inspect the volume file in /backup and you will see that it has grown. Bacula will append new backups to the volume until it hits the threshold defined in the Pool, in this case 50 GB.
Furthermore, if we look at the individual jobs, we can verify that the files have been backed up. Run list files job=<id> in bconsole and then do the same thing for the last job. (The job ids can be found by running list jobs)
As we can see, the first job backed up 229 files, whereas the last job backed up 231, which makes sense as we created two new files. You can scroll through the list of files and verify that it backed up the files you just recently added.
Adding restore configuration to the server
Edit the bacula-dir.conf file with sudo and add the following job configuration.
Name = "ClientRestoreFiles"
Type = Restore
Client = "Desktop1804"
Storage = File1
Pool = File
Messages = Standard
Where = /home/chris/restore
We are adding a job that will restore the backup into the directory /home/chris/restore.
Then save the file, exit and restart the service
sudo systemctl restart bacula-director.service
Initiating a restore
To start the restore, jump into the Bacula console.
And start the restore process by running the command restore.
This will give you several ways to select the backup that you want to restore, but for now, we’ll restore based on a particular job id. Select 1 from the list which will show the last 20 jobs.
Then, when we have found the job id that we need, enter 3 and proceed to enter job-id for the backup that we want, in this case we want job id 12. That will provide us with the backup we made after we generated the text files, backmeup1.txt and backmeup2.txt.
When you have entered the desired job id, you are given the option to select which files you want to restore. By default, all files and directories are marked for restore, so if you want to restore them all, you can just enter done. In this example, I just want to restore the file backmeup1.txt.
Change to the home directory
and then enter
That will unselect the directory chris and also all directories, sub-directories and files in that directory.
Then navigate the user’s home directory, in this example chris
and mark the text file backmeup1.txt to be restored.
Finally, exit the menu
From the screen shot above, Bacula gives you some information regarding the backup job and will ask what restore job to perform and which client you want to restore to. Therefore, select 2, as that is the restore job we defined in the previous section and then 2 again to target the client.
Finally, enter yes to start the restore.
When the job is complete, look in the restore directory in the home directory of the client and you should see the file backmeup1.txt restored into the subdirectory restore/home/chris.
As you can see, I did a checksum on the two files and they match as expected.
And that is it. In the next articles, we’ll look at how to configure a Windows client, how to setup a recurring job and also how to perform some off-site backups. In subsequent articles we’ll explore how to secure critical data and back them up off site at a cloud provider such as Dropbox or Amazon Web Services’ S3. Next we’ll configure the separate components of Bacula on different hosts and then we’ll look at hosting Bacula on a cloud provider, such as AWS, Vultr, Linode and Digital Ocean.
I hope I’ve given you some information to start digging in to Bacula yourself, but if you get stuck, have a question or, if there is any information or ideas you would like to see, feel free to contact me via email or post a comment in the comment section below.