Vous êtes sur la page 1sur 14

Procedimento

Instalao e configurao do Bacula no CentOS

Autor: Sandro Venezuela <sandro@linux2business co! br"

### linux2business co! br $%$&

Atribuio Uso no-comercial Compartilhamento pela mesma licena 2.5 Brasil

Voc' (ode: Co(iar) distribuir) exibir e executar a obra

Sob as seguintes condi*es: Atribuio: Voc' de+e dar cr,dito ao autor original) da for!a es(ecificada (elo autor ou licenciante Uso no-comercial: Voc' no (ode utilizar esta obra co! finalidades co!erciais Compartilhamento pela mesma licena: Se +oc' alterar) transfor!ar ou criar outra obra co! base nesta) +oc' so!ente (oder- distribuir a obra resultante sob u!a licena id'ntica a esta

A re(roduo do !aterial contido neste tutorial , (er!itido desde .ue se inclua! os cr,ditos ao autor e a frase: /Reproduzido da inu!2Business " ###.linu!2business.com.br 0 e! local +is1+el

### linux2business co! br 2%$&

ndice
Verso Ob3eti+o Criao dos 4acotes 546 Instalao do Bacula Configurao do Bacula 5efer'ncias 2 & & 7 7 $&

Verso
Criado$Alterado Sandro Venezuela %ata 28%97%29$2 &erso V$ 9

### linux2business co! br 2%$&

Objetivo
A(resentar os (rocedi!entos de instalao e configurao do Bacula) al,! do (rocesso de criao dos (acotes 546 necess-rios (ara o CentOS 5 64 bits A criao dos (acotes 546 de+e ser realizada) (referencial!ente) e! outro a!biente) co!o (or exe!(lo) e! u!a instalao +irtual do CentOS 5) co! o ob3eti+o de e+itar a instalao de (acotes desnecess-rios no a!biente de (roduo

Criao dos Pacotes RPM


4ara criao dos (acotes do Bacula : 2 8 foi utilizado o ar.ui+o S4;C da +erso : 9 2 dis(on1+el no site do (ro3eto Bacula) !as co! algu!as !odifica*es O (ri!eiro (asso , co(iar o c<digo= fonte do Bacula : 2 8) a (artir do re(osit<rio do (ro3eto:
$ mkdir temp $ cd temp $ wget http://sourceforge.net/projects/bacula/files/bacula/5.2.9/bacula-5.2.9.tar.gz

;!

ar.ui+o bacula-5.2.9.tar.gz de+e ser co(iado (ara o ~/rpmbuild/SOURCES e o ar.ui+o bacula.spec de+e ser alterado nas seguintes lin>as:
$ cd ~/rpmbuild/SPECS $ cp -pv bacula.spec bacula52.spec $ vi bacula52.spec <Alterar as seguintes linhas> Linha 9: %define _version 5.2.9 Linha 249: #Patch: diff-503.patch Linha 578: Requires: mysql-server Linha 722: #%patch -p2 Linhas 868 e 869: #rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql #rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql Linhas 875 e 876: #rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql #rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql Linha 918: cp -p examples/sample-query.sql $RPM_BUILD_ROOT%{script_dir}/query.sql Linhas 945 e 946 #rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql #rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql Linhas 973 e 974: #%attr(-, root, %{daemon_group}) %{script_dir}/startmysql #%attr(-, root, %{daemon_group}) %{script_dir}/stopmysql Linhas 1378 e 1379: %{_mandir}/man8/bregex.8.%{manpage_ext} %{_mandir}/man8/bwild.8.%{manpage_ext} Linha 1438: %{_libdir}/libbac*

seguida)

diret<rio

Obs.: No estarei descrevendo os passos para criar o ambiente para gerao de pacotes RPM por!m este

### linux2business co! br &%$&

procedimento pode ser "acilmente veri"icado na re"er#ncia $ ao "inal deste documento%

4or fi!) de+e=se co!(ilar o c<digo=fonte) gerando o (acote 546 do Bacula : 2 8 (ara a base de dados M&S'(:
$ cd ~/rpmbuild/SPECS $ rpmbuild -bb --clean bacula52.spec --define "contrib_packager Sandro Venezuela <sandro@linux2business.com.br>" --define "build_centos5 1" --define "build_mysql 1"

4ara criao do (acote do BA? @ Bacula )dministration *ool = (ri!eiro de+e=se alterar o ar.ui+o bacula-bat.spec) confor!e abaixo:
$ cd ~/rpmbuild/SPECS $ cp -pv bacula-bat.spec bacula52-bat.spec $ vi bacula52-bat.spec <Alterar as seguintes linhas> Linhas 9 e 10: %define _version 5.2.9 %define depkgs_qt_version 19Jun12 Linha 13: %define qt4ver 4.7.4 Linha 105: #Patch0: diff-503.patch Linha 165: #%patch0 -p2 Linha 186: export QMAKESPEC=${qtdir}/qt-everywhere-opensource-src-%{qt4ver}/mkspecs/linux-g++/

Antes de iniciar) de+e=se co(iar o c<digo=fonte da biblioteca At) onde a +erso utilizada foi & B &:
$ cd ~/rpmbuild/SOURCES $ wget ftp://ftp.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.4.tar.gz

;! seguida) de+e ser criado o (acote depkgs-qt-19Jun12.tar.gz a (artir do (acote depkgs-qt28Jul09.tar.gz) este Clti!o utilizado (ara criao do BA? : 9 2:
$ cd ~/rpmbuild/BUILD $ tar -zxvf ../SOURCES/depkgs-qt-28Jul09.tar.gz $ cd depkgs-qt $ tar -zxvf ~/rpmbuild/SOURCES/qt-everywhere-opensource-src-4.7.4.tar.gz $ rm -rf qt-x11-opensource-src-4.3.4 $ vi Makefile <Alterar o parmetro qt4> qt4=`echo qt-everywhere*` $ vi ./qt-everywhere-opensource-src-4.7.4/configure <Alterar o parmetro COMMERCIAL_USER na linha 229> COMMERCIAL_USER=no $ cd ../.. $ tar -zcvf ../SOURCES/depkgs-qt-19Jun12.tar.gz depkgs-qt

4or fi!) de+e=se co!(ilar o c<digo=fonte) gerando o (acote 546 do BA? (ara a +erso : 2 8:
$ cd ~/rpmbuild/SPECS
$ rpmbuild -bb --clean bacula52-bat.spec --define "contrib_packager Sandro Venezuela <sandro@linux2business.com.br>" --define "build_centos5 1" --define "centos5 1"

?odos os (acotes so criados no diret<rio ~/rpmbuild/RPMS/x86_64:


$ ls -1 ~/rpmbuild/RPMS/x86_64

### linux2business co! br :%$&

bacula-bat-5.2.9-2.x86_64.rpm bacula-client-5.2.9-1.x86_64.rpm bacula-libs-5.2.9-1.x86_64.rpm bacula-mysql-5.2.9-1.x86_64.rpm bacula-updatedb-5.2.9-1.x86_64.rpm

Instalao do Bacula
Os (acotes .ue de+e! ser instalados no ser+idor de bacDu( so: bacula-libs e bacula-mysql) sendo este Clti!o) de+ido o fato de utilizar!os o banco de dados M&S'(:
# rpm -Uvh bacula-libs-5.2.9-1.x86_64.rpm bacula-mysql-5.2.9-1.x86_64.rpm

4ara ad!inistrao do Bacula) (ode=se utilizar o BA? @ Bacula )dministration *ool @ atra+,s do (acote bacula-bat:
# rpm -Uvh bacula-bat-5.2.9-1.x86_64.rpm

Obs.: +ma depend#ncia para o bacula-bat no CentOS 5 ! a biblioteca libmng%

Configurao do Bacula
Basica!ente de+e! ser alterados os ar.ui+os bacula-dir.conf e bacula-sd.conf) onde abaixo segue u! exe!(lo si!(les: Ar.ui+o /etc/bacula/bacula-dir.conf:
# # Default Bacula Director Configuration file # # For Bacula release 5.2.9 (11 June 2012) -- redhat # Director { Name = "Linux2BusinessDIR" DIRport = 9101 QueryFile = "/usr/lib64/bacula/query.sql" WorkingDirectory = "/var/lib/bacula" PidDirectory = "/var/run" Maximum Concurrent Jobs = 1 Password = "cjsmPVjgsjyjZcjogpGhbzaZSKGCn0axlmz5vfJd3HWq" Messages = Daemon } # Generic catalog service Catalog { Name = "MyCatalog" # Uncomment the following line if you want the dbi driver dbdriver = "dbi:mysql"; dbaddress = 127.0.0.1; dbport = 3306 dbname = "bacula"; dbuser = "bacula"; dbpassword = "bac123" } # Client1: Servidor Backup Client { Name = "Backup" Address = backup.linux2business.br FDPort = 9102

### linux2business co! br 7%$&

Catalog = MyCatalog Password = "TvzamthrjTBGwsF9D82tG5fj3pLL8M5SD8RUMSALEMRu" File Retention = 30 days Job Retention = 60 days AutoPrune = yes } # List of files to be backed up FileSet { Name = "BackupOS" Include { Options { signature = MD5 } File = / File = /usr File = /home File = /tmp File = /var } Exclude { File = /var/bacula File = /proc File = /media File = /.journal File = /.fsck }

# This is the backup of the catalog FileSet { Name = "Catalog" Include { Options { signature = MD5 } File = "/var/lib/bacula/bacula.sql" } } FileSet { Name = "FullSet" Include { Options { signature = MD5 } } Exclude { } } # Client2: Servidor Web #Client { # Name = "Web" # Address = www.linux2business.br # FDPort = 9102 # Catalog = MyCatalog # Password = "Ufg78dURdslMnB98w23SDWo43LkloJds76d3kJ8dD90k" # File Retention = 30 days

### linux2business co! br B%$&

# Job Retention = 60 days # AutoPrune = yes #} # # List of files to be backed up #FileSet { # Name = "WebOS" # Include { # Options { # signature = MD5 # } # File = / # File = /usr # File = /home # File = /tmp # File = /var # File = /var/www # File = /opt # } # # Exclude { # File = /proc # File = /media # File = /.journal # File = /.fsck # } #} # # When to do the backups Schedule { Name = "CycleOS" Run = Full sun at 00:05 Run = Incremental mon-sat at 00:05 } # This schedule does the catalog. It starts after the WeeklyCycle Schedule { Name = "CycleAfterBackup" Run = Full sun-sat at 23:10 } # Definition of file storage device Storage { Name = "File" Address = backup.linux2business.br SDPort = 9103 Password = "rTpXbTl1ENFlh4PvMZwnafK5Iu+ygPKoEUJyRwYTkkCr" Device = FileStorage Media Type = File } # File Pool definition Pool { Name = "PoolOS" LabelFormat = "OS-" Pool Type = Backup Recycle = yes AutoPrune = yes Volume Retention = 14 days Maximum Volume Bytes = 5G

### linux2business co! br E%$&

Maximum Volume Jobs = 1 } Pool { Name = "PoolCatalog" LabelFormat = "Catalog-" Pool Type = Backup Recycle = Yes AutoPrune = Yes Volume Retention = 5 days Maximum Volume Jobs = 5 Maximum Volumes = 2 Recycle Oldest Volume = Yes } # Default pool definition Pool { Name = "Default" Pool Type = Backup Recycle = yes AutoPrune = yes Volume Retention = 365 days } # Scratch pool definition Pool { Name = "Scratch" Pool Type = Backup } JobDefs { Name = "DefaultJob" Type = Backup Storage = File Messages = Standard Priority = 10 Write Bootstrap = "/var/lib/bacula/%c.bsr" } Job { Name = "Client1" JobDefs = "DefaultJob" Client = Backup Pool = PoolOS Schedule = CycleOS FileSet = BackupOS } #Job { # Name = "Client2" # JobDefs = "DefaultJob" # Client = Web # Pool = PoolOS # Schedule = CycleOS # FileSet = WebOS #} # Backup the catalog database Job { Name = "BackupCatalog" JobDefs = DefaultJob

# Bacula can automatically recycle Volumes # Prune expired volumes

### linux2business co! br 8%$&

Client = Backup Level = Full FileSet= Catalog Schedule = CycleAfterBackup # This creates an ASCII copy of the catalog # Arguments to make_catalog_backup.pl are: # make_catalog_backup.pl <catalog-name> RunBeforeJob = "/usr/lib64/bacula/make_catalog_backup.pl MyCatalog" # This deletes the copy of the catalog RunAfterJob = "/usr/lib64/bacula/delete_catalog_backup" Write Bootstrap = "/var/lib/bacula/%n.bsr" Priority = 11 # run after main backup Pool = PoolCatalog } # # Standard Restore template, to be changed by Console program # Only one such job is needed for all Jobs/Clients/Storage ... # Job { Name = "RestoreFiles" Type = Restore Client= Backup FileSet= FullSet Storage = File Pool = Default Messages = Standard Where = /var/bacula/restorations } # Reasonable message delivery -- send most everything to email address # and to the console Messages { Name = "Standard" # # NOTE! If you send to two email or more email addresses, you will need # to replace the %r in the from field (-f part) with a single valid # email address in both the mailcommand and the operatorcommand. # What this does is, it sets the email address that emails would display # in the FROM field, which is by default the same email as they're being # sent to. However, if you send email to more than one address, then # you'll have to set the FROM address manually, to a single address. # for example, a 'no-reply@mydomain.com', is better since that tends to # tell (most) people that its coming from an automated source. # mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" operatorcommand = "/usr/sbin/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 # # WARNING! the following will create a file that you must cycle from # time to time as it will grow indefinitely. However, it will # also keep all your messages if they scroll off the console. # append = "/var/lib/bacula/log" = all, !skipped catalog = all }

### linux2business co! br $9%$&

# # Message delivery for daemon messages (no job). Messages { Name = "Daemon" mailcommand = "/usr/sbin/bsmtp -h localhost -s \"Bacula daemon message\" %r" mail = root@localhost = all, !skipped console = all, !skipped, !saved append = "/var/lib/bacula/log" = all, !skipped }

-f

\"\(Bacula\)

\<%r\>\"

# # Restricted console used by tray-monitor to get the status of the director # Console { Name = "Linux2BusinessMON" Password = "Elw32R5yjXug76PM7IjOpP5I4EqtSlRe8GpGvDDTmdld" CommandACL = status, .status }

Ar.ui+o /etc/bacula/bacula-sd.conf:
# # Bacula Storage Daemon Configuration file # # For Bacula release 5.2.9 (11 June 2012) -- redhat # Storage { Name = "Linux2BusinessSD" SDPort = 9103 WorkingDirectory = "/var/lib/bacula" Pid Directory = "/var/run" Maximum Concurrent Jobs = 20 } # # List Directors who are permitted to contact Storage daemon # Director { Name = "Linux2BusinessDIR" Password = "rTpXbTl1ENFlh4PvMZwnafK5Iu+ygPKoEUJyRwYTkkCr" } # # Restricted Director, used by tray-monitor to get the # status of the storage daemon # Director { Name = "Linux2BusinessMON" Password = "um0vIBe6m8A/htP+H0UxXbU/rShvqEfN4i/9QRpt1DsQ" Monitor = yes } # # Devices supported by this Storage daemon # To connect, the Director's bacula-dir.conf must have the # same Name and MediaType. # Device {

### linux2business co! br $$%$&

Name = FileStorage Media Type = File Archive Device = /var/bacula/backups LabelMedia = Yes; Random Access = Yes; AutomaticMount = Yes; RemovableMedia = no; AlwaysOpen = no;

# # Send all messages to the Director, # mount messages also are sent to the email address # Messages { Name = "Standard" director = Linux2BusinessDIR = all }

Os ar.ui+os aci!a configura! o Bacula (ara realizar bacDu( do (r<(rio ser+idor de bacDu() !enos os diret<rios onde os bacDu(s so realizados) 3- .ue os bacDu(s so ar!azenados e! disco 4ara adicionar no+os clientes) basta incluir no ar.ui+o bacula-dir.conf no+os (arF!etros Client e os ,ileSet de cada no+o cliente) al,! do -ob .ue ser- executado de acordo co! a agenda GSc.eduleH O ar.ui+o bacula-fd.conf de+e ser configurado se +oc' dese3a realizar bacDu( do (r<(rio ser+idor de bacDu() co!o , o caso do nosso exe!(lo) e os ar.ui+o bconsole.conf e bat.conf de+e! ser configurados (ara (er!itir gerenciar o Bacula a (artir da interface texto ou gr-fica) direta!ente do (r<(rio ser+idor de bacDu(: Ar.ui+o /etc/bacula/bacula-fd.conf:
# # Bacula File Daemon Configuration file # # For Bacula release 5.2.9 (11 June 2012) -- redhat # # # List Directors who are permitted to contact this File daemon # Director { Name = "Linux2BusinessDIR" Password = "TvzamthrjTBGwsF9D82tG5fj3pLL8M5SD8RUMSALEMRu" } # # Restricted Director, used by tray-monitor to get the # status of the file daemon # Director { Name = "Linux2BusinessMON" Password = "ry+geSTqtetcb/H7vO9IiqTG9p+bgYN1D6F23EDaGGeL" Monitor = yes } # # "Global" File daemon configuration specifications #

### linux2business co! br $2%$&

FileDaemon { Name = "BackupFD" FDport = 9102 WorkingDirectory = /var/lib/bacula Pid Directory = /var/run Maximum Concurrent Jobs = 20 } # Send all messages except skipped files back to Director Messages { Name = "Standard" director = Linux2BusinessDIR = all, !skipped, !restored }

Ar.ui+o /etc/bacula/bconsole.conf:
# # Bacula User Agent (or Console) Configuration File # Director { Name = "Linux2BusinessDIR" DIRport = 9101 address = backup.linux2business.br Password = "cjsmPVjgsjyjZcjogpGhbzaZSKGCn0axlmz5vfJd3HWq" }

Ar.ui+o /etc/bacula/bat.conf:
# # Bacula Administration Tool (bat) configuration file # Director { Name = "Linux2BusinessDIR" DIRport = 9101 address = backup.linux2business.br Password = "cjsmPVjgsjyjZcjogpGhbzaZSKGCn0axlmz5vfJd3HWq" }

I (oss1+el gerenciar o Bacula a (artir) tanto do (r<(rio ser+idor .uanto de u!a estao de trabal>o Jinux) atra+,s do co!ando bconsole ou grafica!ente atra+,s do co!ando bat) onde a!bos exige! o usu-rio root
Obs.: Min.a recomendao ! utili/ar o comando sudo%

Ko de!ais clientes) basta instalar so!ente o (acote bacula-client-5.2.9-1.x86_64.rpm, configurando o ar.ui+o bacula-fd.conf) de !aneira si!ilar ao a(resentado aci!a) alterando basica!ente a sen>a GPass0ordH
Obs.: O pacote bacula-client "oi criado e1clusivamente para clientes com o sistema CentOS 5 64 bits por!m este pacote pode ser "acilmente criado para outras distribui2es%

4or fi!) de+e=se criar o diret<rio onde os bacDu(s sero ar!azenados e recu(erados) le!brando .ue , (oss1+el recu(erar direta!ente (ara o ser+idor destino:
# # # # cd /var mkdir -p bacula/backups mkdir bacula/restorations chown -R bacula.disk bacula

### linux2business co! br $2%$&

# chmod -R 770 bacula

;! seguida) de+e=se iniciar o M&S'() configurando u!a sen>a (ara acesso co! o usu-rios ad!inistrador GrootH:
# service mysqld start # mysqladmin -u root password 'senha_forte'

O (asso seguinte consiste na criao da base de dados do Bacula !ais o usu-rio de acesso) onde utilizare!os os scri(ts 3- (rontos do (r<(rio Bacula:
# # < # < # < cd /usr/lib64/bacula ./create_bacula_database mysql -p Informar senha do administrador do MySQL> ./make_bacula_tables mysql -p Informar senha do administrador do MySQL> ./grant_bacula_privileges mysql -p Informar senha do administrador do MySQL>

Le+e=se agora configurar a sen>a do usu-rio bacula no M&S'(:


# mysql -u root -p < Informar senha do administrador do MySQL> mysql> SET PASSWORD FOR bacula=PASSWORD('senha de acesso do Bacula'); mysql> SET PASSWORD FOR bacula@localhost=PASSWORD('senha de acesso do Bacula'); mysql> quit

A sen>a aci!a de+e ser a !es!a do cat-logo do Bacula) localizada no ar.ui+o de configurao
bacula-dir.conf

Referncias
'. (et Up an RP) Build *n+ironment under Cent,( .ttp3440i5i%centos%org46o0*os4SetupRpmBuild7nvironment 2. -o# to create an RP) pac.a/e .ttp344"edorapro8ect%org40i5i46o09to9create9an9RPM9pac5age 0. %o#nload 1t ibrar2 .ttp344:t%no5ia%com4do0nloads4do0nloads;:t<lib 3. Compilando e instalando o bacula no Centos .ttp344diorgenes%0ordpress%com4=>$>4>?4>@4compilando<e<instalando<o<bacula<no<centos4 5. 4nstallin/ and con5i/urin/ Bacula in Cent,( .ttp344nimdas&s%0ordpress%com4=>$$4>=4$A4installing<and<con"iguring<bacula<in<centos4

### linux2business co! br $&%$&

Vous aimerez peut-être aussi