You are on page 1of 7

Criando Servidor Bacula

DESABILITANDO FIREWALL
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld

DESABILITANDO SELinux
vi /etc/sysconfig/selinux
SELINUX=disabled
Salvar e reiniciar
sestatus

Mudando nome do HOST


hostnamectl status.
hostnamectl set-hostname "Seu-hostname"
hostnamectl status
cat /etc/hostname

Instalação dos componentes


sudo yum install -y bacula-director bacula-storage bacula-console bacula-client
mariadb-server

Iniciando MARIADB
sudo systemctl start mariadb

Criando usuário e tabelas


/usr/libexec/bacula/grant_mysql_privileges
/usr/libexec/bacula/create_mysql_database -u root
/usr/libexec/bacula/make_mysql_tables -u bacula

Script de Segurança
sudo mysql_secure_installation

Entrando no console SQL para configurar


mysql -u root -p

Definindo senha do SQL


UPDATE mysql.user SET Password=PASSWORD('123456') WHERE User='bacula';
FLUSH PRIVILEGES;
EXIT

Habilitar o MARIADB para iniciar com o sistema


sudo systemctl enable mariadb

Configurando o Bacula para uasr a biblioteca do MySQL


sudo alternatives --config libbaccats.so

Criando diretorios de backup e restauração


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

Dando permissoes
sudo chown -R bacula:bacula /bacula
sudo chmod -R 700 /bacula
sudo restorecon -R -v /bacula/

Configurando o Director do Bacula


sudo vi /etc/bacula/bacula-dir.conf

Configurando Recursos do Director


Director { # define myself
Name = bacula-dir
DIRport = 9101 # where we listen for UA connections
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/var/spool/bacula"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "@@DIR_PASSWORD@@" # Console password
Messages = Daemon
DirAddress = 127.0.0.1
}

Configurando trabalhos locais

Job {
Name = "BackupLocalFiles" (BackupClient1)
JobDefs = "DefaultJob"
}

Job {
Name = "RestoreLocalFiles"
Type = Restore
Client=BackupServer-fd
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /bacula/restore
}

Configurando conjunto de arquivos

FileSet {
Name = "Full Set"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /
}
Exclude {
File = /var/lib/bacula
File = /proc
File = /tmp
File = /.journal
File = /.fsck
File = /bacula
}
}

Configurando o Daemon de Armazenamento

Storage {
Name = File
# Do not use "localhost" here
Address = 192.168.4.132 # N.B. Use a fully qualified name here
SDPort = 9103
Password = "@@SD_PASSWORD@@"
Device = FileStorage
Media Type = File
}

Configurando Conexão do Catalago

# Generic catalog service


Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = "dbi:postgresql"; dbaddress = 127.0.0.1; dbport =
dbname = "bacula"; dbuser = "bacula"; dbpassword = "bacula_db_password"
}

Configurar Pool

# File Pool definition


Pool {
Name = File
Pool Type = Backup
Label Format = Local-
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool

Verificar Conexão com o Diretor

sudo bacula-dir -tc /etc/bacula/bacula-dir.conf

Configurar o Daemon de armazenamento do SD

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

Configurar Recurso de armazenamento

Storage { # definition of myself


Name = BackupServer-sd
SDPort = 9103 # Director's port
WorkingDirectory = "/var/lib/bacula"
Pid Directory = "/var/run/bacula"
Maximum Concurrent Jobs = 20
SDAddress = 192.168.4.132
}

Configurar Dispositivo de Armazenamento


Device {
Name = FileStorage
Media Type = File
Archive Device = /bacula/backup
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
}

Verificar a configuração do Daemon de Armazenamento


sudo bacula-sd -tc /etc/bacula/bacula-sd.conf

Definir senhas dos componentes do Bacula


BCONSOLE
DIR_PASSWORD=`date +%s | sha256sum | base64 | head -c 33`
sudo sed -i "s/@@DIR_PASSWORD@@/${DIR_PASSWORD}/" /etc/bacula/bacula-dir.conf
sudo sed -i "s/@@DIR_PASSWORD@@/${DIR_PASSWORD}/" /etc/bacula/bconsole.conf

STORAGE DAEMON
SD_PASSWORD=`date +%s | sha256sum | base64 | head -c 33`
sudo sed -i "s/@@SD_PASSWORD@@/${SD_PASSWORD}/" /etc/bacula/bacula-sd.conf
sudo sed -i "s/@@SD_PASSWORD@@/${SD_PASSWORD}/" /etc/bacula/bacula-dir.conf

FILE DAEMON
FD_PASSWORD=`date +%s | sha256sum | base64 | head -c 33`
sudo sed -i "s/@@FD_PASSWORD@@/${FD_PASSWORD}/" /etc/bacula/bacula-dir.conf
sudo sed -i "s/@@FD_PASSWORD@@/${FD_PASSWORD}/" /etc/bacula/bacula-fd.conf

Iniciar componentes bacula


sudo systemctl start bacula-dir
sudo systemctl start bacula-sd
sudo systemctl start bacula-fd

Iniciar componentes Bacula com o sistema


sudo systemctl enable bacula-dir
sudo systemctl enable bacula-sd
sudo systemctl enable bacula-fd

Testar trabalho de backup


sudo bconsole
label

Executar Tarefa de backup Manualmente


run

Testar tarefa de restauração


sudo bconsole
restore all

CLIENT

Backup de servidor com client

Criando um diretorio para organizar os arquivos


sudo mkdir /etc/bacula/conf.d

Configurando Bacula-Dir
sudo vi /etc/bacula/bacula-dir.conf
No final da linha adicionar
@|"find /etc/bacula/conf.d -name '*.conf' -type f -exec echo @{} \;"

Adicionar Pool de arquivos remotos


sudo vi /etc/bacula/conf.d/pools.conf
Pool {
Name = RemoteFile
Pool Type = Backup
Label Format = Remote-
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
}

Testar o bacula
sudo bacula-dir -tc /etc/bacula/bacula-dir.conf

Instalar e configurar o client do bacula no HOST CLIENT


sudo yum install bacula-client

Definir senha que permitira a conxão do bacula director


date +%s | sha256sum | base64 | head -c 33 ; echo
senha:NWViYzhhYWMzZjY4OGNiMzI0YWU5OTViO

Configurar File Daemon


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

Configurar Bacula-Fd
Director {
Name = bacula-dir
Password ="
}

Configurar File Daemon

FileDaemon { # this is me
Name = BYSERVER-fd
FDAddress = 192.168.4.146
FDport = 9102 # where we listen for the director
WorkingDirectory = /var/spool/bacula
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}

Messages {
Name = Standard
director = bacula-dir = all, !skipped, !restored
}

Verificar se a sintaxe tá certa


sudo bacula-fd -tc /etc/bacula/bacula-fd.conf

Reiniciar bacula-fd
sudo systemctl restart bacula-fd
Iniciar Bacula File Automaticamente
sudo systemctl enable bacula-fd

Diretorio onde o servidor bacula pode restaurar arquivos


sudo mkdir -p /bacula/restore
sudo chown -R bacula:bacula /bacula
sudo chmod -R 700 /bacula

Adicionar conjunto de Arquivos SERVIDOR

Editando File Sets


sudo vi /etc/bacula/conf.d/filesets.conf

FileSet {
Name = "Pasta001 and Pasta002"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /Pasta001
File = /Pasta002
}
Exclude {
File = /home/bacula/not_important
}
}

Adicionar Cliente e Tarefa de Backup ao servidor Bacula


sudo vi /etc/bacula/conf.d/clients.conf

Client {
Name = BYSERVER-fd
Address = 192.168.4.146
FDPort = 9102
Catalog = MyCatalog
Password = "NmZiZTA3NzM4Mzg2MWU1NjcxMWU5YjQxN" # SENHA DO FileDaemon
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}

Criando Tarefa de Backup

Job {
Name = "BackupBYSERVER"
JobDefs = "DefaultJob"
Client = BYSERVER-fd
Pool = RemoteFile
FileSet="Pasta001 and Pasta002"
}

verificar config director


sudo bacula-dir /etc/bacula/bacula-dir.conf
Reiniciar diretor
sudo systemctl restart bacula-dir

Testar conexão do client


sudo bconsole
status client

You might also like