= Bacula Lab = In this lab, you will backup and restore files using a Bacula. For this practical we need 2 Machines, Bacula Server and a Bacula Client. Download '''Bacula_VM''' from below link. We will use Existing Machine from previous sessions of this workshop as client. == Install Bacula Server in Bacula_VM == A Bacula server, which we will also refer to as the “backup server”, has these components: '''Bacula Director (DIR):''' Software that controls the backup and restore operations that are performed by the File and Storage daemons [[BR]] '''Storage Daemon (SD):''' Software that performs reads and writes on the storage devices used for backups[[BR]] '''Catalog:''' Services that maintain a database of files that are backed up. The database is stored in an SQL database such as MySQL or PostgreSQL[[BR]] '''Bacula Console:''' A command-line interface that allows the backup administrator to interact with, and control, Bacula Director '''Install postgresql Database''' {{{ sudo apt-get update -y sudo apt install postgresql }}} '''Install Bacula''' {{{ sudo apt-get install bacula -y }}} While installing Bacula, you will be asked to configure Postfix.Pick "No configuration" under 'General Type of Mail Configuration. If prompted for ''''Configure database for bacula-director-postgresql with dbconfig-common?'''' Enter "Yes." For ''''Password of the database's administrative user,'''set the password as 1234. == Create Backup Directory and assign permission== {{{ sudo mkdir -p /bacula/backup sudo chown -R bacula:bacula /bacula sudo chmod -R 700 /bacula }}} == Install Bacula Client in Client Machine == A Bacula client, i.e. a server that will be backed up, runs the '''File Daemon (FD)''' component. The File Daemon is software that provides the Bacula server (the Director, specifically) access to the data that will be backed up. We will also refer to these servers as “backup clients” or “clients”. '''Install and Configure Bacula Client''' {{{ sudo apt-get update sudo apt-get install bacula-client }}} you can verify your installation by executing {{{ sudo systemctl status bacula-fd }}} if the service is not running {{{ sudo systemctl start bacula-fd sudo systemctl enable bacula-fd }}} == Configure Client == Before configuring the client File Daemon, you will want to look up the following information, which will be used throughout the remainder of this practical: '''Client hostname:''' Our example will use '''“!ClientHost”'''[[BR]] '''Client Private FQDN:''' We’ll refer to this as “client_private_FQDN”, which may look like clienthost.private.example.com or '''private IP address'''[[BR]] '''Bacula Server hostname:''' Our example will use '''“!BackupServer”''' '''Note:-'''Your actual setup will vary from the example, so be sure to make substitutions where appropriate. '''Open the File Daemon configuration:''' {{{ sudo vi /etc/bacula/bacula-fd.conf }}} We need to change a few items and save some information that we will need for our server configuration. change the '''“Name”''' parameter to the '''hostname''' of your backup server followed by '''“-dir”.''' {{{ Director { Name = BackupServer-dir Password = "IrIK4BHRA2o5JUvw2C_YNmBX_70oqfaUi" } }}} You also need to copy the '''Password,''' which is the automatically generated password used for connections to File Daemon, and save it for future reference. This will be used in the '''Backup Server’s Director configuration''', which we will set in an upcoming step, to connect to your Client’s File Daemon. Next, we need to adjust one parameter in the '''!FileDaemon''' resource. We will change the '''FDAddress''' parameter to match the '''private FQDN of our client machine'''. The Name parameter should already be populated correctly with the client file daemon name. The resource should looks something like this '''(substitute the actual FQDN or IP address):''' {{{ FileDaemon { # this is me Name = ClientHost-fd FDport = 9102 # where we listen for the director WorkingDirectory = /var/lib/bacula Pid Directory = /var/run/bacula Maximum Concurrent Jobs = 20 FDAddress = client_private_FQDN / Private IP } }}} We also need to configure this daemon to pass its log messages to the Backup Server. Find the Messages resource and change the '''director parameter''' to match your backup server’s hostname with a '''“-dir”''' suffix. It should look something like this: {{{ Messages { Name = Standard director = BackupServer-dir = all, !skipped, !restored } }}} Save the file and exit. Your File Daemon (Bacula Client) is now configured to listen for connections over the private network. Check that your configuration file has the correct syntax with the following command: {{{ sudo bacula-fd -tc /etc/bacula/bacula-fd.conf }}} If the command returns no output, the configuration file has valid syntax. Restart the file daemon to use the new settings: {{{ sudo service bacula-fd restart }}} Let’s set up a directory that the Bacula Server can restore files to. Create the file structure and lock down the permissions and ownership for security with the following commands: {{{ sudo mkdir -p /bacula/restore sudo chown -R bacula:bacula /bacula sudo chmod -R 700 /bacula }}} == Configure Bacula Director== Bacula has several components that must be configured independently in order to function correctly. The configuration files can all be found in the '''/etc/bacula''' directory. We’ll start with the Bacula Director. Open the Bacula Director configuration file in your favorite text editor. We’ll use vi: {{{ sudo vi /etc/bacula/bacula-dir.conf }}}