>_Backup com Bacula – Instalação no Debian 7.8 – 1.3

Entendendo um pouco da estrutura de backup do Bacula.

Módulos do Bacula:

Director Daemon
Console Manager
File Daemon
Storage Daemon
Catalogo

Monitor

Bacula Director (bacula-dir.conf):

Gerenciador; Núcleo do programa; é responsável por supervisionar todas as operações de backup, restauração, controle e verificação de arquivos.

Bacula Storage:

Responsável pelo armazenamento, leitura e escrita em fita, disco ou outros dispositivos. Deve ser instalado onde os arquivos serão armazenados, podendo ser instalado em mais de uma máquina.

Bacula File Daemon:

Este é o cliente do Bacula. Deve ser instalado em todas as máquinas onde serão realizados os backups.

Instalação/Configuração no Debian 7.8 64bits.

debian

Locais dos arquivos de configurações:

Scripts de inicialização

/etc/init.d/

Arquivos de configuração

# cd /etc/bacula/
# ls
bacula-dir.conf  bacula-fd.conf  bacula-sd.conf  bat.conf  bconsole.conf  common_default_passwords  scripts

Observações:

O arquivo bat.conf e bconsole.conf – podem serem iguais se forem conectados no mesmo Director.
As autenticação da console com os daemon são todos através de nome e senha.

Arquivos binários

/usr/sbin/bacula-*

Principal arquivo de configuração

bacula-dir.conf

Pacotes necessários para o Debian.
Neste exemplo, irei utilizar o banco de dados MySQL.

# apt-get install bacula-director-mysql bacula-sd-mysql bacula-fd bacula-console bacula-console-qt bacula-common-mysql postfix

Bconsole:

O Bconsole é o console do bacula, um programa responsável por permitir que o administrador possa interagir com o Director enquanto o serviço está em execução. Através dele é possível visualizar o status de um job, examinar conteúdos do catálogo, examinar os arquivos de backup, restaurar backup, rodar um backup, manipular storages e clientes.

Acessando o bconsole.

root@ba-vm-bkp-02:/etc/bacula# bconsole 
Connecting to Director localhost:9101
1000 OK: ba-vm-bkp-02.dtd.intranet-dir Version: 5.2.6 (21 February 2012)
Enter a period to cancel a command.

Executando o comando run para criar o primeiro job de backup local.

*run 
A job name must be specified.
The defined Job resources are:
     1: BackupClient1
     2: BackupCatalog
     3: RestoreFiles
Select Job resource (1-3): 1
Run Backup job
JobName:  BackupClient1
Level:    Incremental
Client:   ba-vm-bkp-02.dtd.intranet-fd
FileSet:  Full Set
Pool:     File (From Job resource)
Storage:  File (From Job resource)
When:     2015-04-07 15:02:57
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=4
You have messages.

Verificando o status do job criado com o comando m

*m
07-Abr 15:02 ba-vm-bkp-02.dtd.intranet-dir JobId 4: No prior Full backup Job record found.
07-Abr 15:02 ba-vm-bkp-02.dtd.intranet-dir JobId 4: No prior or suitable Full backup found in catalog. Doing FULL backup.
*

Novamente com o comando m é possível ver o log detalhadamente.
Observação: Perceba que existe um erro no log

*m
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-dir JobId 4: Start Backup JobId 4, Job=BackupClient1.2015-04-07_15.02.59_09
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Error: dev.c:120 Unable to stat device /nonexistant/path/to/file/archive/dir: ERR=Arquivo ou diret�rio n�o encontrado
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Warning: 
     Device "FileStorage" requested by DIR could not be opened or does not exist.
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Error: dev.c:120 Unable to stat device /nonexistant/path/to/file/archive/dir: ERR=Arquivo ou diret�rio n�o encontrado
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Warning: 
     Device "FileStorage" requested by DIR could not be opened or does not exist.
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Error: dev.c:120 Unable to stat device /nonexistant/path/to/file/archive/dir: ERR=Arquivo ou diret�rio n�o encontrado
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Warning: 
     Device "FileStorage" requested by DIR could not be opened or does not exist.
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Fatal error: Device reservation failed for JobId=4: Jmsg Job=BackupClient1.2015-04-07_15.02.59_09 type=5 level=1428429781 ba-vm-bkp-02.dtd.intranet-sd JobId 4: Warning: 
     Device "FileStorage" requested by DIR could not be opened or does not exist.

07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-dir JobId 4: Fatal error: 
     Storage daemon didn't accept Device "FileStorage" because:
     3924 Device "FileStorage" not in SD Device resources.
07-Abr 15:03 ba-vm-bkp-02.dtd.intranet-dir JobId 4: Error: Bacula ba-vm-bkp-02.dtd.intranet-dir 5.2.6 (21Feb12):
  Build OS:               x86_64-pc-linux-gnu debian 7.0
  JobId:                  4
  Job:                    BackupClient1.2015-04-07_15.02.59_09
  Backup Level:           Full (upgraded from Incremental)
  Client:                 "ba-vm-bkp-02.dtd.intranet-fd" 5.2.6 (21Feb12) x86_64-pc-linux-gnu,debian,7.0
  FileSet:                "Full Set" 2015-04-07 14:59:39
  Pool:                   "File" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "File" (From Job resource)
  Scheduled time:         07-Abr-2015 15:02:57
  Start time:             07-Abr-2015 15:03:01
  End time:               07-Abr-2015 15:03:01
  Elapsed time:           0 secs
  Priority:               10
  FD Files Written:       0
  SD Files Written:       0
  FD Bytes Written:       0 (0 B)
  SD Bytes Written:       0 (0 B)
  Rate:                   0.0 KB/s
  Software Compression:   None
  VSS:                    no
  Encryption:             no
  Accurate:               no
  Volume name(s):         
  Volume Session Id:      4
  Volume Session Time:    1428428068
  Last Volume Bytes:      0 (0 B)
  Non-fatal FD errors:    1
  SD Errors:              0
  FD termination status:  
  SD termination status:  
  Termination:            *** Backup Error ***

Corrigindo o erro.

O Bacula por padrão vem com a path de Device apontando para um diretório que não existe. Para corrigir este problema é preciso alterar no arquivo /etc/bacula/bacula-sd.conf na linha 56 o caminho do Device.

root@ba-vm-bkp-02:/var/lib/bacula# cp /etc/bacula/bacula-sd.conf  /etc/bacula/bacula-sd.conf-old
root@ba-vm-bkp-02:/var/lib/bacula# vim /etc/bacula/bacula-sd.conf
 56   Archive Device = /nonexistant/path/to/file/archive/dir
para
 56   Archive Device = /backup

Após a alteração, é preciso criar o diretório que foi definido no arquivo bacula-sd.conf.
Também é necessário definir a permissão para o bacula.

root@ba-vm-bkp-02:/var/lib/bacula# chown -R bacula.bacula /backup/
root@ba-vm-bkp-02:/var/lib/bacula# /etc/init.d/bacula-sd restart
[ ok ] Stopping Bacula Storage daemon...: bacula-sd.
[ ok ] Starting Bacula Storage daemon...: bacula-sd.

Acessado novamente o bconsole e gerando o primeiro backup local.

root@ba-vm-bkp-02:/var/lib/bacula# bconsole 
Connecting to Director localhost:9101
1000 OK: ba-vm-bkp-02.dtd.intranet-dir Version: 5.2.6 (21 February 2012)
Enter a period to cancel a command.

O comando run server para realizar criar o job de backup.

*run
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
     1: BackupClient1
     2: BackupCatalog
     3: RestoreFiles
Select Job resource (1-3): 1
Run Backup job
JobName:  BackupClient1
Level:    Incremental
Client:   ba-vm-bkp-02.dtd.intranet-fd
FileSet:  Full Set
Pool:     File (From Job resource)
Storage:  File (From Job resource)
When:     2015-04-07 15:39:41
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=5
You have messages.

Verificando o status do job.

*m
07-Abr 15:39 ba-vm-bkp-02.dtd.intranet-dir JobId 5: No prior Full backup Job record found.
07-Abr 15:39 ba-vm-bkp-02.dtd.intranet-dir JobId 5: No prior or suitable Full backup found in catalog. Doing FULL backup.
*m
07-Abr 15:39 ba-vm-bkp-02.dtd.intranet-dir JobId 5: Start Backup JobId 5, Job=BackupClient1.2015-04-07_15.39.42_11
07-Abr 15:39 ba-vm-bkp-02.dtd.intranet-dir JobId 5: Using Device "FileStorage"
07-Abr 15:39 ba-vm-bkp-02.dtd.intranet-sd JobId 5: Job BackupClient1.2015-04-07_15.39.42_11 is waiting. Cannot find any appendable volumes.
Please use the "label" command to create a new Volume for:
    Storage:      "FileStorage" (/backup)
    Pool:         File
    Media type:   File
*

Chamando o comando label e em seguida passando o parâmetro File.

label
Automatically selected Storage: File
Enter new Volume name: primeirobkp
Defined Pools:
     1: Default
     2: File
     3: Scratch
Select the Pool (1-3): 2
Connecting to Storage daemon File at localhost:9103 ...
Sending label command for Volume "primeirobkp" Slot 0 ...
3000 OK label. VolBytes=233 DVD=0 Volume="primeirobkp" Device="FileStorage" (/backup)
Catalog record for Volume "primeirobkp", Slot 0  successfully created.
Requesting to mount FileStorage ...
3001 OK mount requested. Device="FileStorage" (/backup)
*

Novamente com o comando m é possível verificar o log mais detalhado.

*m
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-sd JobId 5: Wrote label to prelabeled Volume "primeirobkp" on device "FileStorage" (/backup)
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-sd JobId 5: Job write elapsed time = 00:00:01, Transfer rate = 20.04 M Bytes/second
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-dir JobId 5: Bacula ba-vm-bkp-02.dtd.intranet-dir 5.2.6 (21Feb12):
  Build OS:               x86_64-pc-linux-gnu debian 7.0
  JobId:                  5
  Job:                    BackupClient1.2015-04-07_15.39.42_11
  Backup Level:           Full (upgraded from Incremental)
  Client:                 "ba-vm-bkp-02.dtd.intranet-fd" 5.2.6 (21Feb12) x86_64-pc-linux-gnu,debian,7.0
  FileSet:                "Full Set" 2015-04-07 14:59:39
  Pool:                   "File" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "File" (From Job resource)
  Scheduled time:         07-Abr-2015 15:39:41
  Start time:             07-Abr-2015 15:39:44
  End time:               07-Abr-2015 15:41:23
  Elapsed time:           1 min 39 secs
  Priority:               10
  FD Files Written:       178
  SD Files Written:       178
  FD Bytes Written:       20,027,066 (20.02 MB)
  SD Bytes Written:       20,045,701 (20.04 MB)
  Rate:                   202.3 KB/s
  Software Compression:   None
  VSS:                    no
  Encryption:             no
  Accurate:               no
  Volume name(s):         primeirobkp
  Volume Session Id:      1
  Volume Session Time:    1428431963
  Last Volume Bytes:      20,066,484 (20.06 MB)
  Non-fatal FD errors:    0
  SD Errors:              0
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Backup OK

07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-dir JobId 5: Begin pruning Jobs older than 6 months .
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-dir JobId 5: No Jobs found to prune.
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-dir JobId 5: Begin pruning Files.
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-dir JobId 5: No Files found to prune.
07-Abr 15:41 ba-vm-bkp-02.dtd.intranet-dir JobId 5: End auto prune.

Após a alteração do caminho do Device, o backup foi realizado com sucesso.

root@ba-vm-bkp-02:/var/lib/bacula# ls -l /backup/primeirobkp 
-rw-r----- 1 bacula tape 20066484 Abr  7 15:41 /backup/primeirobkp

Para verificar o que foi backupeado, basta usar o comando list files jobid

*list jobs
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
| JobId | Name          | StartTime           | Type | Level | JobFiles | JobBytes   | JobStatus |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
|     1 | BackupClient1 | 2015-04-07 14:59:41 | B    | F     |        0 |          0 | f         |
|     2 | BackupClient1 | 2015-04-07 15:01:33 | B    | F     |        0 |          0 | f         |
|     3 | BackupClient1 | 2015-04-07 15:02:47 | B    | F     |        0 |          0 | f         |
|     4 | BackupClient1 | 2015-04-07 15:03:01 | B    | F     |        0 |          0 | f         |
|     5 | BackupClient1 | 2015-04-07 15:39:44 | B    | F     |      178 | 20,027,066 | T         |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
*
*list files jobid=5
+----------+
| Filename |
+----------+
| /usr/sbin/pwconv |
| /usr/sbin/reject |
| /usr/sbin/xe-daemon |
| /usr/sbin/biosdecode |
| /usr/sbin/select-default-ispell |
| /usr/sbin/mtx |
| /usr/sbin/e4defrag |
| /usr/sbin/bregex |
| /usr/sbin/postalias |
| /usr/sbin/pwunconv |
| /usr/sbin/postfix |
| /usr/sbin/qmqp-sink |
| /usr/sbin/rmt |
| /usr/sbin/bacula-dir |
| /usr/sbin/ip6tables-apply |
| /usr/sbin/nologin |
| /usr/sbin/upgrade-from-grub-legacy |
| /usr/sbin/service |
| /usr/sbin/vipw |
| /usr/sbin/qshape |
| /usr/sbin/tcpdmatch |
| /usr/sbin/groupmod |
| /usr/sbin/update-dictcommon-aspell |
| /usr/sbin/update-xmlcatalog |
| /usr/sbin/ntpdate |
| /usr/sbin/remove-default-ispell |
| /usr/sbin/postlock |
| /usr/sbin/postfix-add-policy |
| /usr/sbin/update-default-ispell |
| /usr/sbin/bat |
| /usr/sbin/dmidecode |
| /usr/sbin/acpid |
| /usr/sbin/iconvconfig |
| /usr/sbin/postfix-add-filter |
| /usr/sbin/vpddecode |
| /usr/sbin/tcpd |
| /usr/sbin/traceroute |
| /usr/sbin/tcptraceroute.db |
| /usr/sbin/update-grub |
| /usr/sbin/cupsenable |
| /usr/sbin/newusers |
| /usr/sbin/zic |
| /usr/sbin/grpck |
| /usr/sbin/dpkg-divert |
| /usr/sbin/bwild |
| /usr/sbin/update-default-aspell |
| /usr/sbin/grpconv |
| /usr/sbin/bls |
| /usr/sbin/bacula-sd |
| /usr/sbin/remove-shell |
| /usr/sbin/sendmail |
| /usr/sbin/qmqp-source |
| /usr/sbin/accessdb |
| /usr/sbin/update-locale |
| /usr/sbin/iptables-apply |
| /usr/sbin/tunelp |
| /usr/sbin/update-catalog |
| /usr/sbin/lpmove |
| /usr/sbin/update-mime |
| /usr/sbin/deluser |
| /usr/sbin/select-default-wordlist |
| /usr/sbin/rtcwake |
| /usr/sbin/postmap |
| /usr/sbin/ownership |
| /usr/sbin/validlocale |
| /usr/sbin/adduser |
| /usr/sbin/arpd |
| /usr/sbin/postsuper |
| /usr/sbin/userdel |
| /usr/sbin/rcconf |
| /usr/sbin/xe-update-guest-attrs |
| /usr/sbin/grub-mkdevicemap |
| /usr/sbin/groupadd |
| /usr/sbin/dbconfig-load-include |
| /usr/sbin/scsieject |
| /usr/sbin/groupdel |
| /usr/sbin/cupsaccept |
| /usr/sbin/dpkg-reconfigure |
| /usr/sbin/vigr |
| /usr/sbin/tzconfig |
| /usr/sbin/postconf |
| /usr/sbin/bacula-console-qt |
| /usr/sbin/mkinitramfs |
| /usr/sbin/grub-setup |
| /usr/sbin/addgroup |
| /usr/sbin/bacula-console |
| /usr/sbin/tcptraceroute |
| /usr/sbin/cupsaddsmb |
| /usr/sbin/grub-mkconfig |
| /usr/sbin/btape |
| /usr/sbin/btraceback |
| /usr/sbin/grub-mknetdir |
| /usr/sbin/logrotate |
| /usr/sbin/locale-gen |
| /usr/sbin/setvesablank |
| /usr/sbin/cron |
| /usr/sbin/postcat |
| /usr/sbin/safe_finger |
| /usr/sbin/usermod |
| /usr/sbin/ntpdate-debian |
| /usr/sbin/grub-install |
| /usr/sbin/mklost+found |
| /usr/sbin/try-from |
| /usr/sbin/postqueue |
| /usr/sbin/grub-probe |
| /usr/sbin/grub-set-default |
| /usr/sbin/chgpasswd |
| /usr/sbin/filefrag |
| /usr/sbin/chpasswd |
| /usr/sbin/smtp-source |
| /usr/sbin/useradd |
| /usr/sbin/cytune |
| /usr/sbin/cupsdisable |
| /usr/sbin/postlog |
| /usr/sbin/ldattach |
| /usr/sbin/lpinfo |
| /usr/sbin/update-grub2 |
| /usr/sbin/sshd |
| /usr/sbin/arp |
| /usr/sbin/invoke-rc.d |
| /usr/sbin/chroot |
| /usr/sbin/mysqld |
| /usr/sbin/fdformat |
| /usr/sbin/laptop-detect |
| /usr/sbin/scsitape |
| /usr/sbin/update-initramfs |
| /usr/sbin/update-rc.d |
| /usr/sbin/lpc |
| /usr/sbin/dbcheck |
| /usr/sbin/remove-default-wordlist |
| /usr/sbin/update-default-wordlist |
| /usr/sbin/cppw |
| /usr/sbin/loaderinfo |
| /usr/sbin/cupsreject |
| /usr/sbin/update-alternatives |
| /usr/sbin/accept |
| /usr/sbin/dbconfig-generate-include |
| /usr/sbin/grub-reboot |
| /usr/sbin/update-passwd |
| /usr/sbin/ispell-autobuildhash |
| /usr/sbin/cpgr |
| /usr/sbin/make-ssl-cert |
| /usr/sbin/grpunconv |
| /usr/sbin/vcstime |
| /usr/sbin/postkick |
| /usr/sbin/lpadmin |
| /usr/sbin/add-shell |
| /usr/sbin/xe-linux-distribution |
| /usr/sbin/delgroup |
| /usr/sbin/bacula-fd |
| /usr/sbin/pam-auth-update |
| /usr/sbin/bsmtp |
| /usr/sbin/rsyslogd |
| /usr/sbin/update-inetd |
| /usr/sbin/install-info |
| /usr/sbin/bconsole |
| /usr/sbin/tcpdchk |
| /usr/sbin/postdrop |
| /usr/sbin/aspell-autobuildhash |
| /usr/sbin/update-usbids |
| /usr/sbin/update-rcconf-guide |
| /usr/sbin/e2freefrag |
| /usr/sbin/bextract |
| /usr/sbin/pwck |
| /usr/sbin/rmail |
| /usr/sbin/cupsctl |
| /usr/sbin/rmt-tar |
| /usr/sbin/smtp-sink |
| /usr/sbin/tapeinfo |
| /usr/sbin/dpkg-preconfigure |
| /usr/sbin/pam_getenv |
| /usr/sbin/update-info-dir |
| /usr/sbin/install-sgmlcatalog |
| /usr/sbin/dpkg-statoverride |
| /usr/sbin/update-dictcommon-hunspell |
| /usr/sbin/readprofile |
| /usr/sbin/postmulti |
| /usr/sbin/ |
+----------+
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
| JobId | Name          | StartTime           | Type | Level | JobFiles | JobBytes   | JobStatus |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
|     5 | BackupClient1 | 2015-04-07 15:39:44 | B    | F     |      178 | 20,027,066 | T         |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+

Continua …

Fonte da pesquisa:
www.bacula.com.br
www.dicas-l.com.br
tidahora.com.br

>_Backup com Bacula – Instalação no Debian 7.8 – 1.3
Tagged on:

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

%d blogueiros gostam disto: