📜 ⬆️ ⬇️

Step-by-step modification of the preset Bacula setting

Introduction


This is a brief step-by-step guide for beginners: how to change an already working backup system based on Bacula. This work will help you understand the relationship of bacula configuration elements.

In modern GNU / Linux distributions, the Bacula package installed from packages is often already configured to back up the OS configuration. If your bacula is not set up in advance, take the complete manual (see “Literature”).

general description


The task is to add a new one in addition to the existing storage and organize a backup to a new location. For this task, you must perform 4 steps.

  1. The “Device” section must be added to the configuration file of the bacula-sd guard daemon in order for the daemon to learn about the new storage location.
  2. In the configuration file of the daemon-manager bacula-dir (bacula-dir.conf) you need to add the section “Storage”, which will describe the new “storage” (organized on the new “device” of the storage daemon).
  3. In the bacula-dir.conf file, add the “Pool” section, which will announce the new volume set (located on the new “storage”).
  4. In the bacula-dir.conf file, add the “Job” section, which will describe the new backup task (using the new set of volumes).

In addition to creating backups, you need to configure the ability to restore files. To do this, you need to create a job for recovery - a new section “Job” with the job type “Restore”.
')
In case you need to set a new backup schedule, you will need to add the “Shedule” section to the bacula-dir.conf file and then the new schedule can be used in an existing or new task. You can also describe several sets of volumes, for example, for long-term storage of full copies and short-term - incremental archives, then create corresponding tasks with these sets of volumes.

If you change the parameters of the volume set (if the content of some already existing “Pool” section has changed), be sure to execute the update command in the bacula console. With this command, the bacula-dir daemon will update the intervals (storage time) of the previously created volumes of the modified set.

Step 1. Add a storage location (Device) in bacula-sd.conf


In the configuration of the bacula-sd storage daemon we will add a new place (“device”) for storing files - the “Device {}” section.

1.1. Create the file /etc/bacula/device/backupstorage.conf
- we copy available "in a box" /etc/bacula/device/file.conf
and change in it the path to place the files, the name and type of media. “Name” and “media type” should be unique among the “Device” descriptions - they will be used to select the storage location in the backup task.

# Definition of file storage device # iSCSI volume "iqn.2012-07.com.lenovoemc:storage.ix4-300d.ix4-300d-vol3g" # mapped to /dev/disk/by-label/backupstorage # and mounted to /srv/backup/backupstorage # Device { Name = BackupStorage Media Type = File-NAS Archive Device = "/srv/backup/backupstorage" LabelMedia = yes; Random Access = Yes; AutomaticMount = yes; RemovableMedia = no; AlwaysOpen = no; } 


1.2. Add this file to the /etc/bacula/bacula-sd.conf configuration next to the others:

 … @/etc/bacula/device/filestorage.conf @/etc/bacula/device/tapedrives.conf @/etc/bacula/device/backupstorage.conf # # Send all messages to the Director, # mount messages also are sent to the email address # Messages { Name = Standard director = labara-host = all, !skipped, !restored } 


1.3. We give the bacula-sd daemon a command to re-read the configuration.

service bacula sd reload
or
/etc/init.d/bacula-sd reload

Step 2. Add the storage in bacula-dir.conf


Now add information about the new storage location to the bacula-dir daemon configuration — insert a new section “Storage {}” into the file “bacula-dir.conf”.

2.1. Create the file /etc/bacula/storage/backupstorage.conf - you can copy the existing /etc/bacula/storage/file.conf and replace the parameters "Name", "Device" and "Media Type". Name we write new, for “Device” we use “Name” from “Step 1”, for “Media Type” - “Media Type” from “Step 1”.

 # Definition of storage instance for # iSCSI volume "iqn.2012-07.com.lenovoemc:storage.ix4-300d.ix4-300d-vol3g", # mounted to /srv/backup/backupstorage # Storage { Name = NASBackupStorage Address = "192.0.2.3" SDPort = 9103 @/etc/bacula/bacula-sd-password.conf Device = BackupStorage Media Type = File-NAS } 


2.2. We insert /etc/bacula/storage/backupstorage.conf in /etc/bacula/bacula-sd.conf next to the others:

 … @/etc/bacula/client/client1.conf @/etc/bacula/storage/file.conf @/etc/bacula/storage/example.conf @/etc/bacula/storage/backupstorage.conf @/etc/bacula/messages/standart.conf @/etc/bacula/messages/daemon.conf @/etc/bacula/pool/default.conf … 


Step 3. Add a volume pool to bacula-dir.conf


That bacula separately considered the files located on NAS, we create a pool for them. This pool is clearly not attached to the repository, it will be used in the task.
The same storage can be tied to multiple pools, for example, you can make different pools for weekly, monthly and daily backups, each with different storage times for volumes.

3.1. Create the file /etc/bacula/pool/nas.conf with the description of the Pool section. Differences from default - label format (to distinguish files with stored data) and name. It is also very desirable to limit the size of the volume, otherwise bacula will write everything into one volume and at some point the disk will overflow.

 # Default pool definition for NAS Storage Pool { Name = NAS Pool Type = Backup Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 365 days # one year LabelFormat = "bn" # Use not more Maximum Volume Bytes on disk Maximum Volume Bytes = 4G } 


3.2. We put /etc/bacula/pool/nas.conf in /etc/bacula/bacula-sd.conf next to the others.

 … @/etc/bacula/pool/default.conf @/etc/bacula/pool/scratch.conf @/etc/bacula/pool/nas.conf … 


Step 4. Add tasks to bacula-dir.conf


Now add the task using the existing Schedule «WeeklyCycle» (see the file /etc/bacula/schedule/weeklycycle.conf). If the existing schedule does not suit us, we will have to create new schedules, in which we will specify the pools, start time and backup modes, and after they are created - new tasks.
In the existing configuration there are tasks “BackupFullSet” (server files) with priority 10 and “BackupCatalog” (base Bakula) with priority 11. We will set the same priorities for our tasks.

4.1. In order not to write the same backup parameters to the mounted NAS volume many times, create a file with the JobDefs section /etc/bacula/job/defaultnasjob.conf:
 JobDefs { Name = "NASDefaultJob" Type = Backup Level = Incremental Client = fd FileSet = "Full Set" Storage = NASBackupStorage Messages = Standard Pool = NAS Priority = 10 } 


4.2. The task for saving server files to the NAS volume, its queue is “10”. Create a job file /etc/bacula/job/baculadup.conf

 # # Define the duplicate of main backup job. This job stores backup into NAS. # Job { Name = "BackupFullSetDup" JobDefs = "NASDefaultJob" Schedule = "WeeklyCycle" Write Bootstrap = "/srv/backup/backupstorage/bacula/DUPClient1.bsr" } 


4.3. The task to save the bacula database on the NAS that needs to be performed last, queue number "11". Create the job file /etc/bacula/job/backupcatalognas.conf:

 Job { Name = "BackupCatalogNAS" JobDefs = "NASDefaultJob" Level = Full FileSet="Catalog" Schedule = "WeeklyCycleAfterBackup" # This creates an ASCII copy of the catalog RunBeforeJob = "/usr/share/bacula/scripts/make_catalog_backup" # This deletes the copy of the catalog RunAfterJob = "/usr/share/bacula/scripts/delete_catalog_backup" Write Bootstrap = "/srv/backup/backupstorage/bacula/BackupCatalogNAS.bsr" Priority = 11 # run after main backup } 


4.4. Insert new job files in /etc/bacula/bacula-sd.conf alongside others:

 … @/etc/bacula/pool/default.conf @/etc/bacula/pool/scratch.conf @/etc/bacula/pool/nas.conf @/etc/bacula/job/defaultjob.conf @/etc/bacula/job/backupcatalog.conf @/etc/bacula/job/bacula.conf @/etc/bacula/job/defaultnasjob.conf @/etc/bacula/job/baculadup.conf @/etc/bacula/job/backupcatalognas.conf 


Step 5. Check


5.1. We give the command to the bacula-dir daemon to re-read the configuration. The most reliable way to do this is with the reload command in the bacula-dir console: if the changed configuration contains an error, the daemon will show the location of the error in the console and continue working in the previous configuration.

Connect to the bacula-dir daemon using bconsole or BAT. In the console, enter the reload command (in BAT, you can use the graphical interface instead of entering the command: on the “console” line, right-click and select “Reload bacula-dir.conf” in the context menu).

If something is wrong, you will see an error message in the console, if everything is in order, there will be no messages in the console.

5.2. We perform a backup of the new task. This is most conveniently done in BAT: open the “Jobs” tab, select the name of the new task in the list of tasks (for example, “BackupFullSetDup”), right-click and select “RunJob” in the context menu.

The status of the job, see the tab "Jobs Run". In the console, see the steps to complete the task (the .message command). If the task ends with an error, you can see an error message in the console.

Step 6. Create a file recovery task


In order to quickly restore a lost (deleted or modified) file, we will prepare a task of the “Restore” type. It uses the same Pool, Storage, Fileset, and Client as in the “Backup” type task, a recovery path has been added (“Where”), the type is different, there is no schedule and level.

6.1. Add the file /etc/bacula/job/restorefromnas.conf:

 Job { Name = "RestoreFromNAS" Type = Restore Client=fd FileSet="Full Set" Storage = NASBackupStorage Pool = NAS Messages = Standard Where = /tmp/bacula-restores } 


6.2. Insert the new job file in /etc/bacula/bacula-sd.conf next to the others:

 … @/etc/bacula/job/restore.conf @/etc/bacula/job/restorefromnas.conf … 


Literature




Addition


In the default configuration, bacula creates a log file and this file grows without restrictions (the rule of rotation logrotate is usually not provided).
Also, if you do not run bconsole and do not connect using BAT, the bacula-director accumulates console messages in the `hostname`.conmsg file (in the working directory).
See /etc/bacula/messages/daemon.conf for details. (In order not to store console messages, you can disable them, although this is not ideal. And the log should be rotated using logrotate.)

Source: https://habr.com/ru/post/243719/


All Articles