You are on page 1of 19

How Install Bacula Backup Server and Client on CentOS

Backup Computer Key In Blue For Archiving And Storage

Introduction:
Bacula is an open source network backup program enabling you to backup, restore, and verify
data across your network. There are Bacula clients for Linux, Windows, and Mac making it a
cross-platform network wide solution. It is very flexible and robust, which makes it, while
slightly cumbersome to configure, suitable for backups in many situations. A backup system is
an important component in most server infrastructures, as recovering from data loss is often a
critical part of disaster recovery plans. In this tutorial, we will show you how to install and
configure the server components of Bacula on a Centos 7 server.
1. Prerequisites:
You must have super user (sudo) access on a Centos 7 server. Also, the server will
require adequate disk space for all of the backups that you plan on retaining at any
given time. You should enable Private Networking on your Bacula server, and all of
your client servers that are in the same datacenter region. This will allow your servers
to use private networking when performing backups, reducing network overhead.

1. Overview:
Bacula is made up of several components and services used to manage which
files to backup and backup locations:

1. Bacula Director: a service that controls all backup, restore, verify, and archive
operations.

2. Bacula Console: an application allowing communication with the Director.


There are three versions of the Console:

 Text based command line version.

 Gnome based GTK+ Graphical User Interface (GUI) interface.

 wxWidgets GUI interface.

3. Bacula File: also known as the Bacula Client program. This application is


installed on machines to be backed up, and is responsible for the data
requested by the Director.

4. Bacula Storage: it is programs that performs the storage and recovery of data
to the physical media.

5. Bacula Catalog: is responsible for maintaining the file indexes and volume
databases for all files backed up, enabling quick location and restoration of
archived files. The Catalog supports three different databases MySQL,
PostgreSQL, and SQLite.

o Installation:
Bacula uses an SQL database, such as MySQL or Mariadb, to manage its
backups catalog. We will use Mariadb. First we will login as root user.

#su

Then install Bacual and mysql server using command:

# yum  -y install bacula-director-mysql bacula-console bacula-client bacula-storage-mysql


mysql-server mysql-devel

- Advertisement -

# yum –y install mariadb-server.86_64 mariadb

Once the installation is complete, we need to start MySQL service and configure it to
automatically start on system reboot with the following command:

# sudo systemctl start mariadb.service#sudo systemctl enable mariadb.service


Now create root password for mysql.

Note:  i am using password as “centos” wherever i need to setup password. create your own
password.

# mysqladmin -u root password centos

Next run the following commands one by one to create database and necessary tables for
Bacula. Here “-u root” means that login with root account and “-p” means prompt for mysql
root password in my case is “centos”.

# /usr/libexec/bacula/grant_mysql_privileges -u root -p

# /usr/libexec/bacula/create_mysql_database -u root -p

# /usr/libexec/bacula/make_mysql_tables -u root -p

Next, we want to run a simple security script that will remove some dangerous defaults and
lock down access to our database system a little bit.

# sudo mysql_secure_installation

The prompt will ask you for your current root password. Enter the password. For the rest of
the questions, you should simply hit the Enter key through each prompt to accept the default
values. This will remove some sample users and databases, disable remote root logins, and
load these new rules so that MySQL immediately respects the changes we have made.

It will look like this

Now we need to set the password for the Bacula database user.

Enter the MySQL console, as the root MySQL user:

# mysql -u root –p

Enter the MySQL root password.

Now set the password for the Bacula database user. Use this command, but replace “centos”
with strong password:

# Mariadb [(none)]> UPDATE mysql.user SET password=PASSWORD("centos") WHERE


user='bacula';Mariadb [(none)]> FLUSH PRIVILEGES;
 

Once you’re done here, exit the MySQL prompt:

# Mariadb [(none)]> exit

Enable MariaDB to start on boot. Use the following command to do so:

# sudo systemctl enable mariadb

Set Bacula to Use MySQL Library

By default, Bacula is set to use the PostgreSQL library. Because we are using MySQL, we need
to set it to use the MySQL library instead.

Run this command:

# sudo alternatives --config libbaccats.s

You will see the following prompt.

Enter 1 (MySQL):

OutputThere are 3 programs which provide 'libbaccats.so'.

 Selection    Command

-----------------------------------------------

1           /usr/lib64/libbaccats-mysql.so

2           /usr/lib64/libbaccats-sqlite3.so*+

3           /usr/lib64/libbaccats-postgresql.so 

Enter to keep the current selection[+], or type selection number: 1

Create Backup and Restore Directories

Bacula needs a backup directory—for storing backup archives—and restore directory—where


restored files will be placed. If your system has multiple partitions, make sure to create the
directories on one that has sufficient space.

Let’s create new directories for both of these purposes:


# sudo mkdir -p /bacula/backup /bacula/restore

We need to change the file permissions so that only the bacula process (and a superuser) can
access these locations:

# sudo chown -R bacula:bacula /bacula

# sudo chmod -R 700 /bacula

Now we’re ready to configure the Bacula Director.

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 vim:

# sudo vim /etc/bacula/bacula-dir.conf

Configure Director Resource

In this file we will Update Bacula server hostname, bacula mysql user password, Bacula console
password, Bacula file daemon password etc. Be mindful that you should use a fully qualified
domain name for adding clients or simply use the IP address instead. Edit just those words
are Bold.

bacula-dir.conf — Add Director DirAddress

[…]Director {                            # define myself


Name = bacula-dir
DIRport = 9101                # where we listen for UA connections
QueryFile = “/usr/libexec/bacula/query.sql”
WorkingDirectory = “/var/spool/bacula”
PidDirectory = “/var/run”
Maximum Concurrent Jobs = 1
Password = “centos”      # Console password
Messages = Daemon

[…]

# Client (File Services) to backup

Client {
Name = bacula-fd
Address = 192.168.100.146
FDPort = 9102
Catalog = MyCatalogPassword = “centos”          # password for FileDaemon
File Retention = 30 days            # 30 days
Job Retention = 6 months            # six months
AutoPrune = yes                     # Prune expired Jobs/Files
}
[…]

# Definition of file storage device


Storage {
Name = File# Do not use “localhost” here
Address = 192.168.100.146                # N.B. Use a fully qualified name here
SDPort = 9103
Password = “centos”
Device = FileStorage
Media Type = File
}
[…]
# Generic catalog service
Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = “dbi:sqlite3”; dbaddress = 127.0.0.1; dbport =
dbname = “bacula”; dbuser = “bacula“; dbpassword = “centos”

}
[…]

Console {
Name = bacula-mon
Password = “centos”
CommandACL = status, .status
}
Now move on to the rest of the file. Now we will Update Bacula Console.

Edit file /etc/bacula/bconsole.conf

# vi /etc/bacula/bconsole.conf

Director {
Name = bacula-dir
DIRport = 9101
address = localhost
Password = “centos”
}

Update Storage Daemon

Edit file /etc/bacula/bacula-sd.conf

# vi /etc/bacula/bacula-sd.conf

Update the password, Find the red lines and delete them, do not uncomment them. Also set
your Archive device path.
Set password here.

[...]

Director {

Name = bacula-dir

Password = "centos"

Set archive path here .

Device {

Name = FileStorage

Media Type = File

Archive Device = /mybackup

LabelMedia = yes;                   # lets Bacula label unlabeled media

Random Access = Yes;

AutomaticMount = yes;               # when device opened, read it

RemovableMedia = no;

AlwaysOpen = no;

[...]

Delete these lines in the picture below.

Now we will Update file daemon

Edit file /etc/bacula/bacula-fd.conf,

# vi /etc/bacula/bacula-fd.conf

Update the password.


 

# List Directors who are permitted to contact this File daemon

Director {

Name = bacula-dir

Password = "centos"

Delete these line in below picture

Now we finished all passwords and address modifications. Next restart all bacula daemons and
make them to start automatically on every reboot.

# systemctl start bacula-dir

# systemctl start bacula-fd

# systemctl start bacula-sd

# systemctl enable bacula-dir

# systemctl enable bacula-fd

# systemctl enable bacula-sd

Bacula has been successfully installed and configured. You can now add clients, jobs and
volumes by updating the Bacula Config files. Alternatively you can use webmin to make the
work simpler. It is quite easier then updating the Config files manually.

Manage Bacula With Webmin

Webmin is a web-based interface for system administration for Linux/Unix. Using any modern
web browser, you can setup user accounts, Apache, DNS, file sharing and much more.

Download and install the latest version of webmin.

# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.900-1.noarch.rpm

Webmin requires some dependencies, so we will install using this command


#yum -y install perl perl-Net-SSLeay openssl perl-IO-Tty perl-Encode-Detect

# rpm -Uvh webmin-1.900-1.noarch.rpm

# systemctl start webmin

# systemctl enable webmin

Rule for Firewall.

Now we will Add rule for Firewall, If we want to access the bacula server from a remote
system, allow the webmin port “10000” and bacula ports “9101”, “9102”, “9103” through
your firewall. Open terminal and run these commands one by one.

# sudo firewall-cmd --zone=public --add-port=10000/tcp --permanent

# sudo firewall-cmd --zone=public --add-port=9101/tcp --permanent

# sudo firewall-cmd --zone=public --add-port=9102/tcp --permanent

# sudo firewall-cmd --zone=public --add-port=9103/tcp --permanent

Reload the rules:

#firewall-cmd --reload

Access Webmin

Now you can login through webmin by “//http://server-ip-address:10000” or“http://domain-


name:10000/”.

Login to webmin using your root user and its password.


If unable to login. Stop firewall (not recommended just for testing) by this command

# systemctl stop firewalld

Then try to login again if logged in then your firewall rules are need to set.

 
Click on the “Bacula Backup System” link. Initially the Bacula server won’t start automatically.
To start Bacula server click on “Module Configuration” link on the right of the “Bacula Backup
System” page.
 
That’s it. here you can schedule backups according to your desire.
Best of Luck. !!!!
Ajuste: Mejor Rendimiento y Tratamiento
de Cuellos de Botella de Respaldo
1. →
2. Backup→
3. Ajuste: Mejor Rendimiento y Tratamiento de Cuellos de Botella de Respaldo

 Publicación de la entrada:2 de septiembre de 2020


 Categoría de la entrada:Actualización 4a edición / Actualización 2a
edición / Actualización 3a edición / Actualización Libro / Backup / bacula / manual
 Comentarios de la entrada:Sin comentarios
Bacula
 Algunas empresas utilizan Antivirus para Windows e incluso para Linux.
Ponga los Daemons de Bacula como excepciones.
 Divida el FileSet en dos al realizar copias de seguridad de más de 20
millones de archivos.
Los sistemas de archivos de Windows, especialmente, no manejan bien volúmenes con
cantidades gigantescas de archivos pequeños. En este caso, lo ideal es crear múltiples
FileSets y Jobs (ej .: uno para cada Volumen o algunos directorios), con el fin de
paralelizar las operaciones de copia. Por ejemplo, un servidor con volúmenes C: y E :

Job1, FileSet1. Include, File = «C:/»


Job2, FileSet2. Include, Plugin = «alldrives: exclude=C»
Job3, FileSet3. Include, Plugin = «vss:/@SYSTEMSTATE/»
El uso de alldrives es importante para realizar copias de seguridad de todas las demás
unidades excepto C :, que ya está respaldada por Job1. Si alguien crea un nuevo
volumen en este servidor, Job2 realizará una copia de seguridad automáticamente.
Job3 sería para una copia de seguridad exclusiva del estado del sistema de Windows
(si también desea separar). Vss: es un complemento exclusivo para empresas, pero
también es posible usar scripts para generar el estado del sistema de Windows en un
volumen separado.
En algunas interfaces gráficas (como Bweb), es posible agrupar Trabajos del mismo
cliente para una mejor gestión y estadísticas.
 Disminuya el nivel de compresión GZIP (si está habilitado, siempre menos
de 6) o use LZO. No utilice la compresión a través del software Bacula para
cintas.
 Ejecute varios trabajos de copia de seguridad simultáneos (Maximum
Concurrent Jobs).
Asegúrese de habilitar la competencia en los 4 lugares:

a) Recurso Director en bacula-dir.conf

b) Recurso Storage en bacula-dir.conf

c) Recurso Storage en bacula-sd.conf

d) Recurso Device en bacula-sd.conf


 Realice copias de seguridad en varios discos, cintas o diferentes demonios
de almacenamiento simultáneamente.
 Cintas: habilite el spooling de disco SSD/NVME. Los discos HD
tradicionales pueden ser más lentos que las cintas.
 Cintas: aumente el tamaño de bloque mínimo (por ejemplo, 256 K) y máximo de
256 K a 512 K (* para LTO4. 1 M es demasiado grande y puede causar problemas.
Especificado en: bacula-sd.conf, función del dispositivo). Es necesario volver a crear
todos los volúmenes con el nuevo tamaño máximo de bloque, de lo contrario Bacula
no podrá leer los anteriores.
 Cintas: aumente el tamaño máximo de archivo de 10 GB a 20 GB (especificado
en: bacula-sd.conf, función de dispositivo).
 Deshabilite AutoPrunning para clientes y trabajos (poda de volúmenes una vez
al día a través de un trabajo de administrador).
 Active el Attribute Spooling para todos los trabajos (predeterminado para la
versión 7.0 en adelante).
 Use la inserción por lotes en la base de datos (generalmente es estándar, se
define en la compilación y debe ser respaldada por la base de datos).
Catalog (database)
a) PostgreSQL

 Evite la creación de índices adicionales.


 Use configuraciones especiales para Postgresql (postgresql.conf):
wal_buffers = 64kB
shared_buffers = 1GB # up to 8GB
work_mem = 64MB
effective_cache_size = 2GB
checkpoint_segments = 64
checkpoint_timeout = 20min
checkpoint_completion_target = 0.9
maintenance_work_mem = 256MB

synchronous_commit = on
 Realizando un vacuumdb periódico en la base de datos (postgreSQL), con el
paso del tiempo el gran cambio de registros acaba haciendo que la inserción en la
base de datos consuma más tiempo. [1]
[1] Sugerencia de Edmar Araújo.
Referencias: http://www.postgresql.org/docs/9.0/static/app-vacuumdb.html | Carlos
Eduardo Smanioto -> Otimização – Uma Ferramenta Chamada
Vacuum: http://www.devmedia.com.br/otimizacao-uma-ferramenta-chamada-
vacuum/1710
b) MySQL

 Utilice configuraciones especiales para MySQL:


sort_buffer_size = 2MB
innodb_buffer_pool_size = 128MB

innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
De forma predeterminada, innodb_flush_log_at_trx_commit sería 1, lo que
significa que el registro de transacciones se almacena en el disco en cada
confirmación en el banco y las transacciones no se perderán en caso de una falla
del sistema operativo. Dado que Bacula utiliza muchas transacciones pequeñas,
puede reducir la E/S de registro y aumentar el rendimiento de la copia de
seguridad exponencialmente configurándolo en 0, lo que significa que no habrá
almacenamiento de registro para cada transacción. Como en caso de interrupción
del trabajo sería necesario reiniciar el trabajo de respaldo de cualquier forma, por
lo que es una opción muy interesante.
 Ejecute mysqltuner (apt-get install mysql tuner) e implemente los cambios
sugeridos.
Red (SD y FD)
 Agregue más interfaces (bonding / NIC Teaming) y conmutadores más
rápidos (puede usar el comando de red de estado de Bacula o la aplicación
ethtool para verificar la velocidad de su conexión ethernet).
 Establezca el Network Buffer Size = bytes, que especifica el tamaño inicial del
búfer de red. Este tamaño se ajusta a la baja si el sistema operativo operativo no lo
acepta, a costa de muchas llamadas al sistema (no deseadas). El valor
predeterminado es 32,768 bytes. Se eligió el estándar para que sea lo
suficientemente amplio para la transmisión a través de Internet, pero en una red local
se puede aumentar para mejorar el rendimiento. Algunos usuarios han notado una
mejora de 10 veces en la transferencia de datos usando 65,536 bytes en este valor.
 Evite el tráfico a través de firewalls y enrutadores.
 Utilice Jumbo Frames.
 Personaliza el Kernel (Ref.: Https://fasterdata.es.net/host-tuning/linux/).
Ejemplo:
echo "
# allow testing with buffers up to 128MB
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
# increase Linux autotuning TCP buffer limit to 64MB
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
# recommended default congestion control is htcp
net.ipv4.tcp_congestion_control=htcp
# recommended for hosts with jumbo frames enabled
# net.ipv4.tcp_mtu_probing=1
# recommended for CentOS7+/Debian8+ hosts
net.core.default_qdisc = fq" >> /etc/sysctl.conf
reboot

Sistema Operativo
 RAM (> 8GB)
 vm.dirty_ratio = 2
 vm.dirty_background_ratio = 1
 vm.swappiness = 10
 vm.zone_reclaim_node = 0
Disk Access
 Utilice el sistema de archivos XFS, ya que sobresale en la realización de
operaciones de entrada / salida (E/S) en paralelo debido a su diseño, que se basa
en grupos de asignación (un tipo de subdivisión de los volúmenes físicos en los
que se utiliza XFS, abreviado para AG) . Debido a esto, XFS permite una
escalabilidad extrema de los subprocesos de E/S, el ancho de banda del sistema
de archivos y el tamaño de los archivos y el sistema de archivos en sí, mientras
abarca múltiples dispositivos de almacenamiento físico.
 Utilice el «deadline disk schedulere».
 Utilice RAID con un buen controlador de batería (por ejemplo, ARECA).

You might also like