You are on page 1of 23

1

Bacula (backup + Drcula)


Server Director (dir)
[Servidor gerenciador, daemon principal]
Pacotes necessrios:
mysql-server
bacula-director-mysql
bacula-console

1. Instalar Mysql
#apt-get install mysql-server
Testar:
#mysql u root p
>show databases;
>create database roger;
>uses roger;
>show tables;
2. Instalar pacotes Bacula
#apt-get install bacula-director-mysql bacula-console

3. Editar arquivo de configurao


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

Director {
Name = config_roger-dir
DIRport = 9101
QueryFile = "/etc/bacula/scripts/query.sql"
WorkingDirectory = "/var/lib/bacula"
PidDirectory = "/var/run/bacula"
Maximum Concurrent Jobs = 9
Password = "senai127"
Messages = Daemon
DirAddress = 10.0.2.1
}

# define myself
# where we listen for UA connections

# Numero de seguranca
# senha para File Daemon (FD)
# ip Director

2
#######################################
######## ONDE GRAVAR O BACKUP #########
########## STORAGE DOMAIN #############
#######################################
storage {
Name = config-roger-sd
Address = 10.0.2.2
SDPort = 9103
Password = "senai127"
Device = FileStorage
Media Type = File

# Armazenado em arquivo no storage

}
######################################
###### DEFINICAO CLIENTE LINUX ######
######################################
Client {
Name = Linux-fd
Address = 10.0.2.3
FDPort = 9102
Catalog = MyCatalog
Password = "senai127"
File Retention = 30 days
Job Retention = 6 months
Autoprune = yes
}
# **** DEFINICAO DOS TRABALHOS DE BACKUP ****
Job {
Name = Linux-fd
Type = Backup
Level = Incremental
Client = Linux-fd
FileSet = Linux-fd
Schedule = Linux-fd
Storage = config-roger-sd
Pool = Linux-fd
Messages = Standard
Priority = 1
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}

# limpeza Fita ou Pool

3
FileSet {
Name = Linux-fd
Include {
Options {
Signature = MD5
}
File = "/etc"
File = "/home"
}
}

Schedule {
Name = Linux-fd
Run = Full 1st sun at 22:00
Run = Differential 2nd-5th sun at 22:00
Run = Incremental mon-sat at 22:00
}

# gerar hash comparar envio/recepcao


# Diretrios que sero feitos
# o backup

# GFS (Grand father, father e son)

Pool {
Name = Linux-fd
Pool Type = Backup
Recycle = yes
Autoprune = yes
Volume Retention = 5 days
}

Job {
Name = restore-linux-fd
Type = Restore
Client = Linux-fd
FileSet = Linux-fd
Storage = config-roger-sd
Pool = Linux-fd
Messages = Standard
Where = /restore
}

# Diretrio onde ser feita restaurao


# de dados

4
# **** FIM DEFINICAO CLIENTE LINUX *****
########################################
###### DEFINICAO CLIENTE WINDOWS ######
########################################
Client {
Name = Windows-fd
Address = 10.0.2.4
FDPort = 9102
Catalog = MyCatalog
Password = "senai127"
File Retention = 30 days
Job Retention = 6 months
Autoprune = yes
}

# limpeza Fita ou Pool

# **** DEFINICAO DOS TRABALHOS DE BACKUP ****

Job {
Name = Windows-fd
Type = Backup
Level = Incremental
Client = Windows-fd
FileSet = Windows-fd
Schedule = Windows-fd
Storage = config-roger-sd
Pool = Windows-fd
Messages = Standard
Priority = 1
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}

FileSet {
Name = Windows-fd
Include {
Options {
Signature = MD5
}
File = "c:/Program Files (x86)"
File = "c:/Users"
}
}

# gerar hash comparar envio/recepcao


# VERIFICAR NOME CORRETO
# PELO TERMINAL CONSOLE DO WIN

Schedule {
Name = Windows-fd
Run = Full 1st sun at 22:00
Run = Differential 2nd-5th sun at 22:00
Run = Incremental mon-sat at 22:00
}

# GFS (Grand father, father e son)

Pool {
Name = Windows-fd
Pool Type = Backup
Recycle = yes
Autoprune = yes
Volume Retention = 5 days
}

Job {
Name = restore-windows-fd
Type = Restore
Client = Windows-fd
FileSet = Windows-fd
Storage = config-roger-sd
Pool = Windows-fd
Messages = Standard
Where = "c:/restore"
}

# ONDE SER RECUPERADO O BACKUP

# ********************** FIM DEFINICAO CLIENTE WINDOWS ********************


###########################################################################

6
# Generic catalog servisse
Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = "dbi:sqlite3"; dbaddress = 127.0.0.1; dbport =
# String de conexao MySQL
dbname = bacula; DB Address = "127.0.0.1"; dbuser = "bacula"; dbpassword = "123"
}

###########################################################################

Messages {
Name = Standard
mailcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c
%l\" %r"
operatorcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula:
Intervention needed for %j\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
catalog = all
}

###########################################################################

# Message delivery for daemon messages (no job).


Messages {
Name = Daemon
mailcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon
message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}

4. Reinicializar servio Bacula

#/etc/init.d/bacula-director restart

5. Editar arquivo bconsole


#vi /etc/bacula/bconsole.conf

#
# Bacula User Agent (or Console) Configuration File
#
Director {
Name = config_roger-dir
DIRport = 9101
address = 10.0.2.1
Password = "senai127"
}

# ATENO AO IP DO DIRECTOR

Testando bconsole:
#bconsole

*help

# * (asterisco o prompt)

*list jobs

# Para listar servios em andamento

*list pool

#Listar pool

*m

# Messages

* status dir

# Estado do backup (run or stop)

OBS: Querendo cancelar uma operao digitar . (ponto)

Storage Daemon (sd)


[Servidor de backup, onde ficam os pools]
Pacote necessrio:
bacula-sd-mysql

6. Instalar pacote bacula-sd


#apt-get install bacula-sd-mysql

7. Editar bacula-sd.conf

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

Storage {

# definition of myself

Name = config-roger-sd
SDPort = 9103
WorkingDirectory = "/var/lib/bacula"
Pid Directory = "/var/run/bacula"
Maximum Concurrent Jobs = 20
SDAddress = 10.0.2.2
}

Director {
Name = config_roger-dir
Password = "senai127"
}

# Director's port

Device {
Name = FileStorage
Media Type = File
Archive Device = /backup

# onde backup serao salvos

LabelMedia = yes;

# lets Bacula label unlabeled media

Random Access = Yes;


AutomaticMount = yes;

# when device opened, read it

RemovableMedia = no;
AlwaysOpen = no;
}

8. Criar diretrio para receber pools /backup e mudar dono e grupo para bacula

#mkdir /backup

#chown R bacula:bacula /backup

9. Reinicializar servio Bacula

#/etc/init.d/bacula-sd restart

10

File Daemon (fd)


[Cliente Linux]
Pacote necessrio:
bacula-fd

10. Instalar pacote bacula-sd


#apt-get install bacula-fd

11. Configurar arquivo bacula-fd

Director {
Name = config_roger-dir
Password = "senai127"
}
FileDaemon {

# this is me

Name = Linux-fd
FDport = 9102
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run/bacula
Maximum Concurrent Jobs = 20
FDAddress = 10.0.2.3
}
Messages {
Name = Standard
director = LabHard-dir = all, !skipped, !restored
}

12. Reinicializar servio Bacula

#/etc/init.d/bacula-fd restart

# where we listen for the director

11

CRIANDO UM VOLUME DE BACKUP

Esta a ltima etapa da configurao, onde, a partir do Servidor Director se cria um


volume no Storage Daemon, para permitir que os pools possam ser armazenados.

13. No Storage Director

#bconsole
*label
Dar um nome qualquer ao volume, por exemplo, LinuxBkp;
Escolher o pool, neste caso, Linux-fd;
A figura 1 mostra os passos acima.

Figura 1 Criando um volume de backup para Cliente Linux (File Daemon)

12

Ao final, no Storage Daemon, dentro do diretrio /backup, ser criando um arquivo


chamado LinuxBkp, referente ao pool do File Daemon Linux (Cliente Linux) conforme ilustra
a figura 2.

Figura 2 Verificando volume criando no Storage Daemon

FORANDO BACKUP
A partir desse momento, tudo est configurado e o backup dever ocorrer conforme
ajustado no schedule do Job do Cliente Linux.

Schedule {
Name = Linux-fd
Run = Full 1st sun at 22:00
Run = Differential 2nd-5th sun at 22:00
Run = Incremental mon-sat at 22:00
}

# GFS (Grand father, father and son)

Porm, podemos usar o bconsole para forar um backup ou restore de um Job, como
segue:

14. Forar Backup

#bconsole

*run

13

Escolher o tipo de Job configurado e confirmar conforme mostra a figura 3.

Figura 3 Job de backup File Daemon Linux

A figura 4 em comparao figura 2, mostra que o no Storage Daemon, o volume


LinuxBkp ficou com tamanho maior aps o backup force.

Figura 4 Viso volume LinuxBkp aps backup force

14

15. Forar Restore

#bconsole

*restore

Escolher a opo 5 para restaurar o backup mais recente, na sequncia o cliente (File
Daemon) que ter a restaurao do backup. A figura 5 ilustra esses procedimentos.

Figura 5 - Etapa inicial de restore

Aps escolher o cliente Linux-fd, ser aberto um prompt de navegao semelhante ao


terminal bash do Linux, onde, por meio dos comandos ls e cd, identificamos os arquivos
ou diretrios que desejamos restaurar conforme mostra a figura 6.

15
Figura 6 Etapa intermediria-1 restore

Aps escolher o arquivo ou diretrio, use o comando mark para selecion-lo


finalizando com done.

$mark etc
$ done

A figura 7 ilustra esta etapa, faltando apenas escolher qual cliente ter o Job de
restore.
Escolhendo o Job Linux-fd, solicitada apenas a confirmao conforme mostra a
figura 8.

16
Figura 7 - Etapa intermediria-2 restore

Figura 8 - Etapa final restore

17

Finalizado o restore, os arquivos e/ou diretrios recuperados devem estar no diretrio


/restore do cliente Linux (File Daemon), sendo este diretrio criando automaticamente
pelo Bacula.

Job {
Name = restore-linux-fd
Type = Restore
Client = Linux-fd
FileSet = Linux-fd
Storage = config-roger-sd
Pool = Linux-fd
Messages = Standard
Where = /restore
}

# Diretrio onde ser feita restaurao


# de dados

A figura 9 mostra o contedo do diretrio /restore aps o Job de restaurao.

Figura 9

18

File Daemon (fd)


[Cliente Windows Server 2008]
16. Configurar Director (Incluir cliente Windows)

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

########################################
###### DEFINICAO CLIENTE WINDOWS ######
########################################

Client {
Name = Windows-fd
Address = 10.0.2.4
FDPort = 9102
Catalog = MyCatalog
Password = "senai127"
File Retention = 30 days
Job Retention = 6 months
Autoprune = yes
}

# **** DEFINICAO DOS TRABALHOS DE BACKUP ****

Job {
Name = Windows-fd
Type = Backup
Level = Incremental
Client = Windows-fd
FileSet = Windows-fd
Schedule = Windows-fd
Storage = config-roger-sd
Pool = Windows-fd
Messages = Standard
Priority = 1
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}

# limpeza Fita ou Pool

19

FileSet {
Name = Windows-fd
Include {
Options {
Signature = MD5
}
File = "c:/Program Files (x86)"
File = "c:/Users"
}
}

Schedule {
Name = Windows-fd
Run = Full 1st sun at 22:00
Run = Differential 2nd-5th sun at 22:00
Run = Incremental mon-sat at 22:00
}

# gerar hash comparar envio/recepcao


# VERIFICAR NOME CORRETO
# PELO TERMINAL CONSOLE DO WIN

# GFS (Grand father, father and son)

Pool {
Name = Windows-fd
Pool Type = Backup
Recycle = yes
Autoprune = yes
Volume Retention = 5 days
}

Job {
Name = restore-windows-fd
Type = Restore
Client = Windows-fd
FileSet = Windows-fd
Storage = config-roger-sd
Pool = Windows-fd
Messages = Standard
Where = "c:/restore"
}

# ONDE SER RECUPERADO O BACKUP

# ********************** FIM DEFINICAO CLIENTE WINDOWS ********************

20

17. Configurar Windows

Instalar cliente Bacula para Windows


Win64bacula-5.0.2.exe

(verso usada)

Configurar arquivo C:\Program Files\Bacula\bacula-fd-conf

FileDaemon {

# this is me

Name = Windows-fd
FDport = 9102

# where we listen for the director

WorkingDirectory = "C:\\Program Files\\Bacula\\working"


Pid Directory = "C:\\Program Files\\Bacula\\working"
# Plugin Directory = "C:\\Program Files\\Bacula\\plugins"
Maximum Concurrent Jobs = 10
}
Director {
Name = config_roger-dir
Password = "senai127"
}
Messages {
Name = Standard
director = config_roger-dir = all, !skipped, !restored
}

Abrir porta 9102 (Firewall)

Deixar servio Bacula em automtico e reinici-lo

21

18. Configurar Regedit Windows

OBS: Essa configurao somente necessria se o backup no for de alguma


unidade (D:\, E:\, etc), ou seja, se o backup for de alguma pasta, esta configurao
necessria.

Inserir chave regedit

HKEY_LOCAL_MACHINE
SYSTEM
CurrentControlSet
services

(boto direito do mouse novo chave chamada webengine)

webengine

(boto direito do mouse novo chave chamada SystemStateBackup)

Figura 10 Inserindo nova chave no regedit

22

Dentro da rea de trabalho, boto direito do mouse:


Novo

->

Valor DWORD (32 bits)

Figura 11 Inserindo valor DWORD (32 bits)

Muda nome para: Allow SSBToAnyVolume


Clicando duas vezes sobre o novo valor, alterar:
Dados do valor = 1
Base = Hexadecimal

Figura 12 - Configurando valor DWORD (32 bits)

Reiniciar o Windows

23
Para finalizar basta repetir como no caso do cliente Linux:

CRIANDO UM VOLUME DE BACKUP

FORANDO BACKUP

FORANDO RESTORE

Repetindo os passos 13, 14 e 15 para Windows.

You might also like