>_Backup com Bacula – Primeiro backup – 1.5

Entendendo um pouco da estrutura de backup do Bacula.

Neste tutorial, pretendo abordar o primeiro job de backup que será realizado no servidor director.

Antes de iniciar o job de backup, pretendo falar um pouco mais sobre alguns aspectos do Bacula.

Local dos logs do Bacula.

# /var/log/bacula.log

Caso queira alterar o local dos logs, basta editar o arquivo bacula-dir.conf.

# vim /etc/bacula/bacula-dir.conf
270 # Message delivery for daemon messages (no job).
271 Messages {
272   Name = Daemon
273   mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
274   mail = root@localhost = all, !skipped
275   console = all, !skipped, !saved
276   append = "/var/log/bacula.log" = all, !skipped
277 }

Local do binários.

/usr/sbin/bacula/

Scripts de inicialização.

/etc/init.d/

Diretório dos scripts de trabalho.

/usr/libexec/bacula/

Alguns scripts importantes.

update_bacula_table – usado para quando for atualizar o Bacula.
mtx-changer – script importante – responsável pelo robô de fitas.

Primeiro job de backup do próprio servidor Bacula.

Para rodar um backup, sempre utilize o comando run após chamar o comando bconsole.

Padrão de jobs default.

A job name must be specified.
The defined Job resources are:
     1: BackupClient1
     2: BackupCatalog
     3: RestoreFiles
Select Job resource (1-3): 

o Bacula vem configurado com 3 job’s por default.

BackupClient1 – É o job de backup do próprio Bacula.

BackupCatalog – É o job de backup do banco de dados.

RestoreFiles – É o job de restore.

Dicas.
O primeiro backup sempre será o backup full.

Sempre é bom verificar o caminho do armazenamento do Storage, geralmente em compilações o caminho padrão é o /tmp (sd).

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

Em Archive Device é possível especificar o ponto de montagem, sendo possível o diretório ou o device.

No caso de robôs de fitas, a configuração é um pouco diferente. Vejamos abaixo o exemplo de configuração com 2 drivers.

Em Device é possível configurar os endereços dos drivers.

#
#Autochanger {
#  Name = Autochanger
#  Device = Drive-1
#  Device = Drive-2
#  Changer Command = "/usr/libexec/bacula/mtx-changer %c %o %S %a %d"
#  Changer Device = /dev/sg0
#}

#Device {
#  Name = Drive-1                      #
#  Drive Index = 0
#  Media Type = DLT-8000
#  Archive Device = /dev/nst0
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
#  AutoChanger = yes
#  #
#  # Enable the Alert command only if you have the mtx package loaded
#  # Note, apparently on some systems, tapeinfo resets the SCSI controller
#  #  thus if you turn this on, make sure it does not reset your SCSI 
#  #  controller.  I have never had any problems, and smartctl does
#  #  not seem to cause such problems.
#  #
#  Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

Caso não tenha um robô de fitas, é possível criar a configuração dos drivers manuais.
A opção AutoChanger = yes – é a opção que permitir que utilizemos um robô de fitas.

#Device {
#  Name = LTO-2
#  Media Type = LTO-2
#  Archive Device = /dev/nst0
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
#  Maximum File Size = 3GB
## Changer Command = "/usr/libexec/bacula/mtx-changer %c %o %S %a %d"
## Changer Device = /dev/sg0
## AutoChanger = yes
#  # Enable the Alert command only if you have the mtx package loaded
## Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo 
## Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

Pré configurações que precisam ser feitas antes de gerar o primeiro job de backup.

Configuração do ambiente.
Configuração do diretório/device do (sd) Storage Backup.
Reinicialização do daemon bacula-sd (sd).

Primeiro backup com o Bacula.

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:   bacula-fd
FileSet:  Full Set
Pool:     File (From Job resource)
Storage:  File (From Job resource)
When:     2015-04-09 14:39:30
Priority: 10
OK to run? (yes/mod/no):yes
OK to run? (yes/mod/no): yes
Job queued. JobId=1
You have messages.
*m
09-Abr 14:46 bacula-dir JobId 1: No prior Full backup Job record found.
09-Abr 14:46 bacula-dir JobId 1: No prior or suitable Full backup found in catalog. Doing FULL backup.
*m
09-Abr 14:46 bacula-dir JobId 1: Start Backup JobId 1, Job=BackupClient1.2015-04-09_14.46.26_04
09-Abr 14:46 bacula-dir JobId 1: Using Device "FileStorage"
09-Abr 14:46 bacula-sd JobId 1: Job BackupClient1.2015-04-09_14.46.26_04 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
*

ERROR.

Não tenho um volume de backup criado ainda.
No caso do backup em disco, é possível criar automaticamente os volumes. Porém não irei abordar neste momento.

O comando label tem como função criar um volume.

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

Após a criação do label o Bacula já começa a gravar o backup na pool label primeiro-bkp

*m
09-Abr 14:48 bacula-sd JobId 1: Wrote label to prelabeled Volume "primeiro-bkp" on device "FileStorage" (/backup)
09-Abr 14:48 bacula-sd JobId 1: Job write elapsed time = 00:00:01, Transfer rate = 29.61 M Bytes/second
09-Abr 14:48 bacula-dir JobId 1: Bacula bacula-dir 5.0.0 (26Jan10): 09-Abr-2015 14:48:21
  Build OS:               x86_64-redhat-linux-gnu redhat 
  JobId:                  1
  Job:                    BackupClient1.2015-04-09_14.46.26_04
  Backup Level:           Full (upgraded from Incremental)
  Client:                 "bacula-fd" 5.0.0 (26Jan10) x86_64-redhat-linux-gnu,redhat,
  FileSet:                "Full Set" 2015-04-09 14:46:26
  Pool:                   "File" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "File" (From Job resource)
  Scheduled time:         09-Abr-2015 14:39:30
  Start time:             09-Abr-2015 14:46:28
  End time:               09-Abr-2015 14:48:21
  Elapsed time:           1 min 53 secs
  Priority:               10
  FD Files Written:       159
  SD Files Written:       159
  FD Bytes Written:       29,597,352 (29.59 MB)
  SD Bytes Written:       29,613,626 (29.61 MB)
  Rate:                   261.9 KB/s
  Software Compression:   None
  VSS:                    no
  Encryption:             no
  Accurate:               no
  Volume name(s):         primeiro-bkp
  Volume Session Id:      1
  Volume Session Time:    1428600703
  Last Volume Bytes:      29,640,760 (29.64 MB)
  Non-fatal FD errors:    0
  SD Errors:              0
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Backup OK

09-Abr 14:48 bacula-dir JobId 1: Begin pruning Jobs older than 44 years 9 months 24 days 17 hours 48 mins 21 sec.
09-Abr 14:48 bacula-dir JobId 1: No Jobs found to prune.
09-Abr 14:48 bacula-dir JobId 1: Begin pruning Jobs.
09-Abr 14:48 bacula-dir JobId 1: No Files found to prune.
09-Abr 14:48 bacula-dir JobId 1: End auto prune.

O que o comando label faz?

Label é o nome do volume.
O comando label tem como função criar um arquivo dentro diretório /backup.

O que é um volume?

Um volume nada mais é que um arquivo. Dentro desse volume (arquivo) será armazenado diversos arquivos podendo também ser de diversos servidores.

diagrama-bacula

# cd /backup/
[root@ba-vm-bkp-01 backup]# ls -ltr
total 28948
-rw-r----- 1 root root 29640760 Abr  9 14:48 primeiro-bkp

Cada volume tem que ter um grupo que se chama POOL. Que poderá ser localizado dentro do banco de dados.

*list volume
Pool: Default
No results to list.
Pool: File
+---------+--------------+-----------+---------+------------+----------+--------------+---------+------+-----------+-----------+---------------------+
| MediaId | VolumeName   | VolStatus | Enabled | VolBytes   | VolFiles | VolRetention | Recycle | Slot | InChanger | MediaType | LastWritten         |
+---------+--------------+-----------+---------+------------+----------+--------------+---------+------+-----------+-----------+---------------------+
|       1 | primeiro-bkp | Append    |       1 | 29,640,760 |        0 |   31,536,000 |       1 |    0 |         0 | File      | 2015-04-09 14:48:21 |
+---------+--------------+-----------+---------+------------+----------+--------------+---------+------+-----------+-----------+---------------------+
Pool: Scratch
No results to list.
*list jobs
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
| JobId | Name          | StartTime           | Type | Level | JobFiles | JobBytes   | JobStatus |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
|     1 | BackupClient1 | 2015-04-09 14:46:28 | B    | F     |      159 | 29,597,352 | T         |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
*list files jobid=1
+--------------------------------------+
| Filename                             |
+--------------------------------------+
| /usr/sbin/anacron                    |
| /usr/sbin/xe-daemon                  |
| /usr/sbin/grpck                      |
| /usr/sbin/selinuxconlist             |
| /usr/sbin/capsh                      |
| /usr/sbin/tzdata-update              |
| /usr/sbin/luseradd                   |
| /usr/sbin/postfix                    |
| /usr/sbin/lid                        |
| /usr/sbin/useradd                    |
| /usr/sbin/bacula-dir.mysql           |
| /usr/sbin/smtp-source                |
| /usr/sbin/ping6                      |
| /usr/sbin/semodule                   |
| /usr/sbin/sendmail                   |
| /usr/sbin/chpasswd                   |
| /usr/sbin/cracklib-unpacker          |
| /usr/sbin/getsebool                  |
| /usr/sbin/setsebool                  |
| /usr/sbin/makedumpfile               |
| /usr/sbin/readprofile                |
| /usr/sbin/lgroupadd                  |
| /usr/sbin/btraceback                 |
| /usr/sbin/iconvconfig                |
| /usr/sbin/arping                     |
| /usr/sbin/bscan                      |
| /usr/sbin/cracklib-packer            |
| /usr/sbin/usernetctl                 |
| /usr/sbin/bwild                      |
| /usr/sbin/groupadd                   |
| /usr/sbin/vipw                       |
| /usr/sbin/cache_repair               |
| /usr/sbin/newusers                   |
| /usr/sbin/visudo                     |
| /usr/sbin/postcat                    |
| /usr/sbin/cracklib-check             |
| /usr/sbin/cache_check                |
| /usr/sbin/cracklib-format            |
| /usr/sbin/iconvconfig.x86_64         |
| /usr/sbin/togglesebool               |
| /usr/sbin/setcap                     |
| /usr/sbin/ldattach                   |
| /usr/sbin/run_init                   |
| /usr/sbin/era_invalidate             |
| /usr/sbin/cache_restore              |
| /usr/sbin/selinuxenabled             |
| /usr/sbin/crond                      |
| /usr/sbin/hwclock                    |
| /usr/sbin/mkdict                     |
| /usr/sbin/pwconv                     |
| /usr/sbin/bacula-dir                 |
| /usr/sbin/rtcwake                    |
| /usr/sbin/getcap                     |
| /usr/sbin/create-cracklib-dict       |
| /usr/sbin/era_check                  |
| /usr/sbin/lchage                     |
| /usr/sbin/postmulti                  |
| /usr/sbin/grpunconv                  |
| /usr/sbin/applygnupgdefaults         |
| /usr/sbin/efibootmgr                 |
| /usr/sbin/dbcheck.mysql              |
| /usr/sbin/adduser                    |
| /usr/sbin/grpconv                    |
| /usr/sbin/plymouth-set-default-theme |
| /usr/sbin/postqueue                  |
| /usr/sbin/vigr                       |
| /usr/sbin/packer                     |
| /usr/sbin/mksock                     |
| /usr/sbin/tunelp                     |
| /usr/sbin/testsaslauthd              |
| /usr/sbin/logrotate                  |
| /usr/sbin/dbcheck                    |
| /usr/sbin/thin_restore               |
| /usr/sbin/lgroupmod                  |
| /usr/sbin/addgnupghome               |
| /usr/sbin/bextract                   |
| /usr/sbin/zic                        |
| /usr/sbin/filefrag                   |
| /usr/sbin/bregex                     |
| /usr/sbin/avcstat                    |
| /usr/sbin/postlog                    |
| /usr/sbin/e2freefrag                 |
| /usr/sbin/postsuper                  |
| /usr/sbin/arpd                       |
| /usr/sbin/nstat                      |
| /usr/sbin/xe-update-guest-attrs      |
| /usr/sbin/saslauthd                  |
| /usr/sbin/sendmail.postfix           |
| /usr/sbin/update-alternatives        |
| /usr/sbin/thin_metadata_size         |
| /usr/sbin/usermod                    |
| /usr/sbin/bconsole                   |
| /usr/sbin/postlock                   |
| /usr/sbin/mklost+found               |
| /usr/sbin/postdrop                   |
| /usr/sbin/lnstat                     |
| /usr/sbin/fdformat                   |
| /usr/sbin/postconf                   |
| /usr/sbin/bcopy.mysql                |
| /usr/sbin/pwck                       |
| /usr/sbin/genhomedircon              |
| /usr/sbin/glibc_post_upgrade.x86_64  |
| /usr/sbin/setenforce                 |
| /usr/sbin/btape                      |
| /usr/sbin/thin_dump                  |
| /usr/sbin/rtacct                     |
| /usr/sbin/getpcaps                   |
| /usr/sbin/tracepath6                 |
| /usr/sbin/luserdel                   |
| /usr/sbin/sshd                       |
| /usr/sbin/lusermod                   |
| /usr/sbin/matchpathcon               |
| /usr/sbin/bsmtp                      |
| /usr/sbin/zdump                      |
| /usr/sbin/lnewusers                  |
| /usr/sbin/xe-linux-distribution      |
| /usr/sbin/getenforce                 |
| /usr/sbin/bacula-sd                  |
| /usr/sbin/open_init_pty              |
| /usr/sbin/pluginviewer               |
| /usr/sbin/thin_repair                |
| /usr/sbin/raid-check                 |
| /usr/sbin/pwunconv                   |
| /usr/sbin/postkick                   |
| /usr/sbin/bacula-fd                  |
| /usr/sbin/load_policy                |
| /usr/sbin/sestatus                   |
| /usr/sbin/lgroupdel                  |
| /usr/sbin/smtp-sink                  |
| /usr/sbin/thin_check                 |
| /usr/sbin/tracepath                  |
| /usr/sbin/ss                         |
| /usr/sbin/bcopy                      |
| /usr/sbin/build-locale-archive       |
| /usr/sbin/groupdel                   |
| /usr/sbin/selinuxdefcon              |
| /usr/sbin/groupmod                   |
| /usr/sbin/thin_rmap                  |
| /usr/sbin/ethtool                    |
| /usr/sbin/clockdiff                  |
| /usr/sbin/postalias                  |
| /usr/sbin/lpasswd                    |
| /usr/sbin/bls                        |
| /usr/sbin/era_dump                   |
| /usr/sbin/cache_dump                 |
| /usr/sbin/bacula                     |
| /usr/sbin/.sshd.hmac                 |
| /usr/sbin/sys-unconfig               |
| /usr/sbin/alternatives               |
| /usr/sbin/userdel                    |
| /usr/sbin/logwatch                   |
| /usr/sbin/restorecond                |
| /usr/sbin/chroot                     |
| /usr/sbin/bscan.mysql                |
| /usr/sbin/saslpasswd2                |
| /usr/sbin/groupmems                  |
| /usr/sbin/postmap                    |
| /usr/sbin/sasldblistusers2           |
| /usr/sbin/                           |
+--------------------------------------+
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
| JobId | Name          | StartTime           | Type | Level | JobFiles | JobBytes   | JobStatus |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
|     1 | BackupClient1 | 2015-04-09 14:46:28 | B    | F     |      159 | 29,597,352 | T         |
+-------+---------------+---------------------+------+-------+----------+------------+-----------+
*

Para saber o que foi backupeado, utilize o comando show fileSet.

*show fileSet
FileSet: name=Full Set
      O M
      N
      I /usr/sbin
      N
      E /var/spool/bacula
      E /tmp
      E /proc
      E /tmp
      E /.journal
      E /.fsck
      N
FileSet: name=Catalog
      O M
      N
      I /var/spool/bacula/bacula.sql
      N
*

Continua …
Fonte da pesquisa:
www.bacula.com.br

>_Backup com Bacula – Primeiro backup – 1.5
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: