Install Bacula Backup Server on Ubuntu 20.04
Bacula is an open-source backup tool that can be used to backup and restore data across the network. It is simple and easy to use tool, and offers many advanced storage management features that help you to backup and recover your lost files easily. It supports Linux, Windows and macOS backup client and also supports a wide range of backup devices. Bacula is made from several components including, Bacula directory, Bacula, console, Bacula storage, Bacula file and Bacula catalog. Each components are responsible for managing specific jobs.
In this tutorial, we will show you how to install and configure Backup backup system on Ubuntu 20.04.
Prerequisites
- A server running Ubuntu 20.04 with minimum 2 GB RAM.
- A root password is configured the server.
Getting Started
First, you will need to update your system to the latest stable version. You can update it with the following command:
apt-get update -y
Once all the packages are updated, you can proceed to the next step.
Install Bacula
By default, Bacula package is available in the Ubuntu 20.04 default repository. You can install it easily using the following command:
apt-get install bacula -y
During the installation, you will be asked to select the mail server as shown below:
Select your desired mail server and click on the Ok button. You will be asked to provide your system mail name as shown below:
Provide your system mail name and click on the Ok button. You will be asked to configure a database for bacula as shown below:
Click on the Yes button. You will be asked to select the host of the PostgreSQL server as shown below:
Select localhost and click on the Ok button. You will be asked to provide PostgreSQL password as shown below:
Provide your desired password and click on the Ok button to continue the installation.
Once the Bacula package is installed, you can proceed to the next step.
Configure Bacula Storage
Before starting, create a directory to store the backup files. You can create it with the following command:
mkdir /backup
Next, change the ownership of the bacula directory to bacula user and group with the following command:
chown -R bacula:bacula /backup
Next, you will need to edit the bacula storage default configuration file and define the device and location of the storage.
nano /etc/bacula/bacula-sd.conf
Remove or comment out other "Device {" and "Autochanger {" section and add the following lines:
Device { Name = Local-device Media Type = File Archive Device = /backup LabelMedia = yes; # lets Bacula label unlabeled media Random Access = Yes; AutomaticMount = yes; # when device opened, read it RemovableMedia = no; AlwaysOpen = no; Maximum Concurrent Jobs = 5 }
Save and close the file when you are finished. Then, restart the Bacula storage service using the following command:
systemctl restart bacula-sd.service
You can now verify the status of the Bacula storage with the following command:
systemctl status bacula-sd
You should get the following output:
? bacula-sd.service - Bacula Storage Daemon service Loaded: loaded (/lib/systemd/system/bacula-sd.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-10-06 09:32:43 UTC; 8s ago Docs: man:bacula-sd(8) Process: 10687 ExecStartPre=/usr/sbin/bacula-sd -t -c $CONFIG (code=exited, status=0/SUCCESS) Main PID: 10688 (bacula-sd) Tasks: 2 (limit: 4691) Memory: 1.0M CGroup: /system.slice/bacula-sd.service ??10688 /usr/sbin/bacula-sd -fP -c /etc/bacula/bacula-sd.conf Oct 06 09:32:43 ubuntu2004 systemd[1]: Starting Bacula Storage Daemon service... Oct 06 09:32:43 ubuntu2004 systemd[1]: Started Bacula Storage Daemon service.
Configure Bacula Director
Next, you will need to edit the Bacula director configuration file and provide your storage location. You can edit it with the following command:
nano /etc/bacula/bacula-dir.conf
Add the following lines, including, Device name, Storage name, password, Job, etc.
Storage { Name = ubuntu2004-sd # Must be equal to the "Name" parameter of the "Storage" section in the /etc/bacula/bacula-sd.conf file Address = 127.0.0.1 Password = "aFEH-0a3QycsbYQVcoy_VoUMhAHJQ00CD" # Password must match the password in the /etc/bacula/bacula-sd.conf Device = Local-device Media Type = File } FileSet { Name = "Local-file" Include { Options { signature = MD5 } File = /etc } } Schedule { Name = "LocalDaily" Run = Full daily at 06:00 } Job { Name = "LocalBackup" JobDefs = "DefaultJob" Enabled = yes Level = Full FileSet = "Local-file" Schedule = "LocalDaily" Storage = ubuntu2004-sd Write Bootstrap = "/var/lib/bacula/LocalhostBackup.bsr" }
Save and close the file when you are finished then restart the Bacula director service to apply the changes:
systemctl restart bacula-dir
You can also verify the status of the Bacula director service with the following command:
systemctl status bacula-dir
You should get the following output:
? bacula-director.service - Bacula Director Daemon service Loaded: loaded (/lib/systemd/system/bacula-director.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-10-06 09:32:43 UTC; 9s ago Docs: man:bacula-dir(8) Process: 10667 ExecStartPre=/usr/sbin/bacula-dir -t -c $CONFIG (code=exited, status=0/SUCCESS) Main PID: 10683 (bacula-dir) Tasks: 3 (limit: 4691) Memory: 2.1M CGroup: /system.slice/bacula-director.service ??10683 /usr/sbin/bacula-dir -fP -c /etc/bacula/bacula-dir.conf Oct 06 09:32:43 ubuntu2004 systemd[1]: Starting Bacula Director Daemon service... Oct 06 09:32:43 ubuntu2004 systemd[1]: Started Bacula Director Daemon service.
Verify Backup Job
At this point, Bacula is installed and configured to run daily at 6:00. Now, let's use the Bacula Console to run our first backup job.
bconsole
Once connected, you should get the following output:
Connecting to Director localhost:9101 1000 OK: 103 ubuntu2004-dir Version: 9.4.2 (04 February 2019) Enter a period to cancel a command.
Next, run the following command to start the backup job:
*run
You will be asked to select the backup job as shown below:
Automatically selected Catalog: MyCatalog Using Catalog "MyCatalog" A job name must be specified. The defined Job resources are: 1: BackupClient1 2: LocalBackup 3: BackupCatalog 4: RestoreFiles Select Job resource (1-4): 2
Type 2 to select the LocalBackup which you have defined in the configuration file and hit Enter. You should see the following output:
Run Backup job JobName: LocalBackup Level: Full Client: ubuntu2004-fd FileSet: Local-file Pool: File (From Job resource) Storage: ubuntu2004-sd (From Job resource) When: 2020-10-06 09:50:47 Priority: 10 OK to run? (yes/mod/no): yes Job queued. JobId=3 You have messages.
At this point, the Backup job is started. You can check the status of the backup job with the following command:
*status
You will be asked to select the status of the following components:
Status available for: 1: Director 2: Storage 3: Client 4: Scheduled 5: Network 6: All Select daemon type for status (1-6): 1
Type 1 and hit Enter to check the status of the Director. You should see the following output:
ubuntu2004-dir Version: 9.4.2 (04 February 2019) x86_64-pc-linux-gnu ubuntu 20.04 Daemon started 06-Oct-20 09:50, conf reloaded 06-Oct-2020 09:50:27 Jobs: run=1, running=0 mode=0,0 Heap: heap=274,432 smbytes=106,782 max_bytes=135,168 bufs=343 max_bufs=377 Res: njobs=4 nclients=1 nstores=3 npools=3 ncats=1 nfsets=3 nscheds=3 Scheduled Jobs: Level Type Pri Scheduled Job Name Volume =================================================================================== Full Backup 10 07-Oct-20 06:00 LocalBackup Vol-0001 ==== Running Jobs: Console connected at 06-Oct-20 09:50 No Jobs running. ==== Terminated Jobs: JobId Level Files Bytes Status Finished Name ==================================================================== 1 Full 2,262 2.875 M OK 06-Oct-20 09:50 LocalBackup ====
Next, run the status command again and check the status of the Bacula storage.
*status
You should see the following output:
Status available for: 1: Director 2: Storage 3: Client 4: Scheduled 5: Network 6: All Select daemon type for status (1-6): 2 The defined Storage resources are: 1: File1 2: ubuntu2004-sd Select Storage resource (1-2): 1 Connecting to Storage daemon File1 at localhost:9103 ubuntu2004-sd Version: 9.4.2 (04 February 2019) x86_64-pc-linux-gnu ubuntu 20.04 Daemon started 06-Oct-20 09:50. Jobs: run=1, running=0. Heap: heap=106,496 smbytes=369,301 max_bytes=567,404 bufs=90 max_bufs=110 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0 newbsr=0 Res: ndevices=1 nautochgr=0 Running Jobs: No Jobs running. ==== Jobs waiting to reserve a drive: ==== Terminated Jobs: JobId Level Files Bytes Status Finished Name =================================================================== 3 Full 2,262 3.156 M OK 06-Oct-20 09:50 LocalBackup ==== Device status: Device File: "Local-device" (/backup) is not open. Available Space=93.95 GB == ==== Used Volume status: ==== Attr spooling: 0 active jobs, 454,546 bytes; 1 total jobs, 454,546 max bytes. ====
Next, exit from the Bacula console with the following command:
*exit
Next, verify the backup directory with the following command:
ls /backup/
You should see that Vol-0001 backup is created:
Vol-0001
Conclusion
Congratulations! you have successfully installed and configured Bacula backup on Ubuntu 20.04 server. You can now install Bacula client on the remote machine and backup your client system easily. Feel free to ask me if you have any questions.