Bacula : Testing Bacula Backup Job

Bacula

This is a continuation of the post “Bacula Backup Systems (Server)” which can be accessed by clicking here.

In this employment the server, database and storage is hosted in one single server.

To test the backup, let us create a file named “hello.txt” in the “/data” folder in the server. This is the folder that is mentioned in the “bacula-dir.conf” file in the server as per the example used while configuring the server. The post can be accessed here.

The command to access the Bacula administration console via the server’s console is:
]# bconsole
Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 5.2.13 (19 February 2013)
Enter a period to cancel a command.

When you get the “*” prompt start using the platform by using the “label” command.
When prompted to enter a volume name, let us provide one of our choice such as “MyVolume”
You will be prompted to choose one of the defined pool, where we need to select option “2” for “File”
This will complete creating the new label.

== == == == == == == == ==
]# bconsole
Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 5.2.13 (19 February 2013)
Enter a period to cancel a command.
*label
Automatically selected Catalog: MyCatalog
Using Catalog “MyCatalog”
Automatically selected Storage: File
Enter new Volume name: MyVolume
Defined Pools:

1: Default
2: File
3: Scratch

Select the Pool (1-3): 2
Connecting to Storage daemon File at gw12-lap-bacula.gw.local:9103 …
Sending label command for Volume “MyVolume” Slot 0 …
3000 OK label. VolBytes=208 DVD=0 Volume=”MyVolume” Device=”FileStorage” (/bacula/backup)
Catalog record for Volume “MyVolume”, Slot 0 successfully created.
Requesting to mount FileStorage …
3906 File device “”FileStorage” (/bacula/backup)” is always mounted.
You have messages.

== == == == == == == == ==

The next step is to run the backup using a predefined job in the configuration file.

== * == * == * == * == * == * == * == * ==

*run
A job name must be specified.
The defined Job resources are:

1: BackupLocalFiles
2: BackupCatalog
3: RestoreLocalFiles

Select Job resource (1-3): 1
Run Backup job
JobName: BackupLocalFiles
Level: Incremental
Client: bacula-fd
FileSet: Full Set
Pool: File (From Job resource)
Storage: File (From Job resource)
When: 2020-05-26 01:33:43
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=3

== * == * == * == * == * == * == * == * ==

 

One the server runs the job, Bacula will tell you that there are messages, which are output generated by running jobs.

  • As this is the first backup, you will see lines in the message that reads:
  • No prior or suitable Full backup found in catalog. Doing FULL backup.
  • Created new Volume “myLocalhost-0001” in catalog.
  • Scheduled time: 25-May-2020 23:05:00
  • Start time: 25-May-2020 23:05:03
  • End time: 25-May-2020 23:05:06
  • SD Errors: 0
  • Termination: Backup OK

We can also check the status of jobs managed by the server by issuing the status director command in the “*” prompt.

Verify the “status” columns when you run the above command.

We can exit the Bacula console by typing the “exit” command at the “*” prompt.

Restore the files backed-up

]# bconsole
Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 5.2.13 (19 February 2013)
Enter a period to cancel a command.
*restore all
Automatically selected Catalog: MyCatalog
Using Catalog “MyCatalog”

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): 5
Automatically selected Client: bacula-fd
The defined FileSet resources are:
1: Catalog
2: Full Set
Select FileSet resource (1-2): 2
+——-+——-+———-+————+———————+——————+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |
+——-+——-+———-+————+———————+——————+
| 1 | F | 463 | 18,882,661 | 2020-05-25 23:05:03 | myLocalhost-0001 |
| 3 | I | 2 | 0 | 2020-05-26 01:33:54 | myLocalhost-0001 |
+——-+——-+———-+————+———————+——————+
You have selected the following JobIds: 1,3

Building directory tree for JobId(s) 1,3 … ++++++++++++++++++++++++++++++++++++++++++++++
462 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: /
$ done
Bootstrap records written to /var/spool/bacula/bacula-dir.restore.1.bsr

The job will require the following
Volume(s) Storage(s) SD Device(s)
===

myLocalhost-0001 File FileStorage

Volumes marked with “*” are online.
464 files selected to be restored.

Run Restore job
JobName: RestoreLocalFiles
Bootstrap: /var/spool/bacula/bacula-dir.restore.1.bsr
Where: /bacula/restore
Replace: always
FileSet: Full Set
Backup Client: bacula-fd
Restore Client: bacula-fd
Storage: File
When: 2020-05-26 02:37:40
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=4
*

Now let is see if the copy of the file is stored in the location configured for Bacula restore:

]# ls -l /bacula/restore/data/
-rw-r--r-- 1 root root 0 May 26 01:21 hello.txt

** End **