Un autre avantage de Bacula est qu'il sait piloter et utiliser des périphériques de stockage professionnels, tels que les robots à bandes. Disponible sur de nombreuses plate-formes, ce logiciel est assez largement utilisé dans l'industrie, l'éducation et même dans le milieu bancaire. (source Wikipedia)
Les services Catalogue ont pour tâche de maintenir à jour la base de données des index de fichiers et volumes pour tous les fichiers sauvegardés. Les services Catalogue permettent à l'administrateur système ou à l'utilisateur de localiser rapidement et restaurer n'importe quel fichier. Les services Catalogue de Bacula le placent dans une catégorie différente de programmes tels que tar et bru, puisque le catalogue Bacula maintient un enregistrement de chaque volume utilisé, chaque job exécuté et chaque fichier sauvegardé ce qui permet des restaurations et une gestion de volumes efficaces.
Installer le paquet Debian pour une utilisation avec Mysql :
aptitude install bacula-director-mysql
Créer la base et le user Mysql :
CREATE DATABASE bacula; GRANT ALL PRIVILEGES ON bacula.* TO'bacula'@'localhost' IDENTIFIED BY 'Pa$$w0rd'; FLUSH PRIVILEGES;
Injecter le script de création des tables pour la base Bacula (commenter les 1ères lignes du script) :
mysql bacula < /usr/share/bacula-director/make_mysql_tables -p
Pour des questions de lisibilité, j'ai décidé de découper le fichier de configuration principale (bacula-dir.conf) en plusieurs parties comme ci-dessous :
Ces fichiers seront stockés /etc/bacula/conf.d/ (Dossier à créer)
######################### # # # CONF BACULA DIRECTOR # # # ######################### # Default Bacula Director Configuration file # The only thing that MUST be changed is to add one or more # file or directory names in the Include directive of the # FileSet resource. # For Bacula release 5.0.2 (28 April 2010) -- debian squeeze/sid # You might also want to change the default email address # from root to your address. See the "mail" and "operator" # directives in the Messages resource. Director { # define myself Name = srv-bacula.test.local-dir DIRport = 9101 # where we listen for UA connections QueryFile = "/etc/bacula/scripts/query.sql" WorkingDirectory = "/var/lib/bacula" PidDirectory = "/var/run/bacula" Maximum Concurrent Jobs = 1 Password = "PASSWORD_DIRECTOR" # Console password Messages = Daemon DirAddress = 192.168.1.100 } # Inclusion de tous les fichiers de configuration présents dans "/etc/bacula/conf.d/" @|"sh -c 'for FILE in /etc/bacula/conf.d/*.conf ; do echo @${FILE} ; done'" # Generic catalog service Catalog { Name = MyCatalog # Uncomment the following line if you want the dbi driver # dbdriver = "dbi:sqlite3"; dbaddress = 127.0.0.1; dbport = dbname = "bacula"; DB Address = "127.0.0.1"; dbuser = "bacula"; dbpassword = "Pa$$w0rd" } # Restricted console used by tray-monitor to get the status of the director Console { Name = srv-bacula.test.local-mon Password = "PASSWORD_TRAYMONITOR" CommandACL = status, .status }
Le fichier principal final est beaucoup plus lisible. Ne pas oublier d'indiquer de charger tous fichiers *.conf dans le dossier conf.d
######################### # # # CLIENT LOCALHOST # # # ######################### Client { Name = srv-bacula.test.local-fd Address = 127.0.0.1 FDPort = 9102 Catalog = MyCatalog Password = "PASSWORD_LOCALHOST_FD" # password for FileDae File Retention = 30 days # 30 days Job Retention = 6 months # six months AutoPrune = yes # Prune expired Jobs/Files } ######################### # # # CLIENT DISTANT # # # ######################### Client { Name = srv-client.test.local-fd Address = 192.168.1.200 FDPort = 9102 Catalog = MyCatalog Password = "PASSWORD_CLIENT_FD" # password for FileDaem File Retention = 30 days # 30 days Job Retention = 6 months # six months AutoPrune = yes # Prune expired Jobs/Files }
La déclaration des clients fait correspondre les passwords déclarés dans la conf du director avec celles des FileDaemon sur les clients.
########################################### # # # FILESET POUR BACKUP /data DE CLIENT # # # ########################################### # Nom de notre FileSet qui sera appelé dans les jobs. FileSet { Name = "Datas" # Fichiers à sauvegarder ainsi que quelques options. Include { Options { # Tous les fichiers seront chiffrés en SHA1. signature = SHA1 # Compression des fichiers. compression = GZIP9 # Permet de sauvegarder plusieurs systèmes de fichiers. onefs = yes # Sauvegarde des ACL. aclsupport = yes } # Tous les fichiers depuis "/data" seront sauvegardés. File = /data } # Fichier qui seront exclus de la sauvegarde. Exclude { File = /data/lost+found } } ############################################### # # # FILESET POUR BACKUP BDD CATALOGUE # # # ############################################### FileSet { Name = "Catalog" Include { Options { # Tous les fichiers seront chiffrés en SHA1. signature = SHA1 } File = /var/lib/bacula/bacula.sql } }
Le fileset permet de définir ce qu'on sauvegarde ou pas.
########################################### # # # JOB POUR BACKUP DU CLIENT # # # ########################################### Job { Name = BackupClient JobDefs = def-client Client = srv-client.test.local-fd } JobDefs { Name = def-client Type = Backup Level = Incremental FileSet = Datas Pool = default Full Backup Pool = pool-full Incremental Backup Pool = pool-inc Schedule = WeeklyCycle Storage = datastorage Messages = Standard Priority = 10 Write Bootstrap = "/var/lib/bacula/srv-client.test.local.bsr" } ##################################### # # # JOB POUR BACKUP DU CATALOGUE # # # ##################################### Job { Name = BackupCatalog JobDefs = def-catalog Client = srv-bacula.test.local-fd } JobDefs { Name = def-catalog Type = Backup Level = Full FileSet = Catalog Pool = catalogue Schedule = WeeklyCycleAfterBackup Storage = datastorage Messages = Standard Priority = 15 RunBeforeJob = "/etc/bacula/scripts/make_catalog_backup bacula bacula Pa$$w0rd localhost" RunAfterJob = "/etc/bacula/scripts/delete_catalog_backup" Write Bootstrap = "/var/lib/bacula/BackupCatalog.bsr" } ############################ # # # RESTORE CATALOGUE # # # ############################ Job { Name = Restore Catalogue Type = Restore Client = "srv-bacula.test.local-fd" FileSet = Catalog Storage = datastorage Pool = catalogue Messages = "Standard" Where = /tmp } ############################ # # # RESTORE CLIENT # # # ############################ Job { Name = Restore client Type = Restore Client = "srv-client.test.local-fd" FileSet = Datas Storage = datastorage Pool = default Full Backup Pool = pool-full Incremental Backup Pool = pool-inc Messages = "Standard" Where = /tmp }
La définition des Jobs permet de définir un pool par défaut qui sera surchargé ensuite par les valeurs de pool selon le type de sauvegarde (totale / incrémentale / différentielle)
################################################## # # # CONFIGURATION DES LOGS ET ENVOI DES MAILS # # # ################################################## 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/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@test.local = all, !skipped operator = root@srv-bacula.test.local = 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 } # # 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@test.local = all, !skipped console = all, !skipped, !saved append = "/var/lib/bacula/log" = all, !skipped } #Reisonnable message delivery -- send most everything to email address # and to the console
Ce fichier permet de recevoir les résultats des tâches exécutées par mail.
###################### # # # Pool Default # # # ###################### Pool { Name = "default" Pool Type = "Backup" Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 6 months # 6 mois Maximum Volume Jobs = 1 } ################### # # # Pool Full # # # ################### Pool { Name = "pool-full" Pool Type = "Backup" Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 6 months # one year #Maximum Volume Bytes = 50G # Limit Volume size to something reasonable Maximum Volume Jobs = 1 Maximum Volumes = 100 # Limit number of Volumes in Pool Label Format = "Full_${Day:p/2/0/r}-${Month:p/2/0/r}-${Year}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" } ############################ # # # Pool Incrementale # # # ############################ Pool { Name = "pool-inc" Pool Type = "Backup" Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 3 months # one year Maximum Volume Jobs = 1 #Maximum Volume Bytes = 50G # Limit Volume size to something reasonable Maximum Volumes = 100 # Limit number of Volumes in Pool Label Format = "Inc_${Day:p/2/0/r}-${Month:p/2/0/r}-${Year}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" } ######################### # # # Pool Catalogue # # # ######################### Pool { Name = "catalogue" Pool Type = "Backup" Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 3 months # one year #Maximum Volume Bytes = 50G # Limit Volume size to something reasonable Maximum Volume Jobs = 1 Maximum Volumes = 100 # Limit number of Volumes in Pool Label Format = "Cat-${Day:p/2/0/r}-${Month:p/2/0/r}-${Year}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" } ################################ # # # Pool Scratch (secours) # # # ################################ Pool { Name = "Scratch" Pool Type = "Backup" }
Dans la définition des pools, le label permet de distinguer les différentes sauvagardes
################################ # # # SCHEDULE BACKUP CLIENT # # # ################################ # When to do the backups, full backup on first sunday of the month, # differential (i.e. incremental since full) every other sunday, # and incremental backups other days Schedule { Name = "WeeklyCycle" Run = Full sun at 1:30 #Run = Differential 2nd-5th sun at 23:05 Run = Incremental mon-sat at 2:00 } ################################ # # # SCHEDULE BACKUP CATALOGUE # # # ################################ # This schedule does the catalog. It starts after the WeeklyCycle Schedule { Name = "WeeklyCycleAfterBackup" Run = Full sun-sat at 1:00 }
Ce fichier définit le type le jour et l'heure des backups.
##################################### # # # ESPACE DE STOCKAGE DES BACKUPS # # # ##################################### Storage { Name = "datastorage" Address = "srv-bacula.test.local" # N.B. Use a fully qualified name here SDPort = "9103" Password = "PASSWORD_STORAGE" Device = "local" Media Type = "File" }
La configuration du serveur de stockage repose sur le fichier /etc/bacula/bacula-sd.conf.
aptitude install bacula-sd
######################### # # # CONF BACULA STORAGE # # # ######################### # Default Bacula Storage Daemon Configuration file # For Bacula release 5.0.2 (28 April 2010) -- debian squeeze/sid # You may need to change the name of your tape drive # on the "Archive Device" directive in the Device # resource. If you change the Name and/or the # "Media Type" in the Device resource, please ensure # that dird.conf has corresponding changes. Storage { # definition of myself Name = srv-bacula.test.local-sd SDPort = 9103 # Director's port WorkingDirectory = "/var/lib/bacula" Pid Directory = "/var/run/bacula" Maximum Concurrent Jobs = 20 SDAddress = 192.168.1.100 } # List Directors who are permitted to contact Storage daemon Director { Name = srv-bacula.test.local-dir Password = "PASSWORD_STORAGE" } # Restricted Director, used by tray-monitor to get the # status of the storage daemon Director { Name = srv-bacula.test.local-mon Password = "PASSWORD_STORAGE_TRAYMONITOR" Monitor = yes } # Note, for a list of additional Device templates please # see the directory <bacula-source>/examples/devices # Or follow the following link: # http://bacula.svn.sourceforge.net/viewvc/bacula/trunk/bacula/examples/devices/ # Devices supported by this Storage daemon # To connect, the Director's bacula-dir.conf must have the # same Name and MediaType. # Device { Name = local Media Type = File Archive Device = /data/backup/ LabelMedia = yes; # lets Bacula label unlabeled media Random Access = Yes; AutomaticMount = yes; # when device opened, read it RemovableMedia = no; AlwaysOpen = no; } Messages { Name = Standard director = srv-bacula.test.local-dir = all }
Bacula fonctionne en mode client/serveur, maintenant la partie serveur est configurée il est nécessaire de configurer les clients.
Pour se faire il est nécessaire d'installer le “Filer Daemon” sur le client.
aptitude install bacula-fd
########################## # # # CONF BACULA FILEDAEMON # # # ########################## # Default Bacula File Daemon Configuration file # For Bacula release 5.0.2 (28 April 2010) -- debian squeeze/sid # There is not much to change here except perhaps the # File daemon Name to # List Directors who are permitted to contact this File daemon Director { Name = srv-bacula.test.local-dir Password = "PASSWORD_LOCALHOST_FD" } # Restricted Director, used by tray-monitor to get the # status of the file daemon Director { Name = srv-bacula.test.local-mon Password = "PASSWORD_CLIENT_TRAYMONITOR" Monitor = yes } # "Global" File daemon configuration specifications FileDaemon { # this is me Name = srv-bacula.test.local-fd FDport = 9102 # where we listen for the director WorkingDirectory = /var/lib/bacula Pid Directory = /var/run/bacula Maximum Concurrent Jobs = 20 FDAddress = 127.0.0.1 } # Send all messages except skipped files back to Director Messages { Name = Standard director = srv-bacula.test.local-dir = all, !skipped, !restored }
La configuration est la même pour un client windows.
Télécharger l’exécutable pour Windows.
Installer le FileDaemon sur le poste Windows (Doc officielle)
Pour relancer le daemon : services.msc
La console Bacula permet d'administrer Bacula à distance.
Il est possible d'agir sur les volumes, les jobs, l'historique et intègre nativement la fonction restore.
aptitude install bacula-console
####################### # # # CONF CONSOLE BACULA # # # ####################### # Bacula User Agent (or Console) Configuration File Director { Name = srv-bacula.test.local-dir DIRport = 9101 address = 192.168.1.100 Password = "PASSWORD_DIRECTOR" }
La console de monitoring de Bacula permet de voir l'état des backups en se connectant sur les différentes machines renseignés dans la configuration. Le traymonitor ne permet pas de lancer des jobs comme la bconsole…
aptitude install bacula-traymonitor
Cette console d'administration nécessite une interface graphique !
########################### # # # CONF BACULA TRAYMONITOR # # # ########################### # Bacula Tray Monitor Configuration File Monitor { Name = srv-bacula.test.local-mon Password = "PASSWORD_DIRECTOR_TRAYMONITOR" RefreshInterval = 5 seconds } Client { Name = srv-client.test.local-mon Address = 192.168.1.200 FDPort = 9102 Password = "PASSWORD_CLIENT_TRAYMONITOR" } Storage { Name = srv-bacula.test.local-mon Address = 127.0.0.1 SDPort = 9103 Password = "PASSWORD_STORAGE_TRAYMONITOR" }