[5] Bacula – Zdalny klient

22 marca 2022 Wyłączono przez Adam [zicherka] Nogły

Możliwe jest dodanie zdalnych hostów jako kopii zapasowych klientów docelowych.

Ten przykład jest oparty na środowisku, jak poniżej.

[1] Skonfiguruj podstawowy Bacula Server, patrz tutaj.

[2] Zainstaluj komponent File na nowym zdalnym hoście klienta Bacula.

[root@vlsr02 ~]# dnf install bacula-client bacula-console

[3] Na serwerze Bacula, jeśli Firewalld jest uruchomiony, zezwól na usługę.

[root@vlsr01 ~]# firewall-cmd --add-service=bacula --permanent
[root@vlsr01 ~]# firewall-cmd –reload

[4] Na kliencie Bacula, jeśli Firewalld jest uruchomiony, zezwól na usługę.

[root@vlsr02 ~]# firewall-cmd --add-service=bacula-client --permanent
[root@vlsr02 ~]# firewall-cmd –reload

[5] Skonfiguruj serwer Bacula.

[root@vlsr01 ~]# mcedit /etc/bacula/bacula-dir.conf
# dodaj na końcu
# zdefiniuj zadanie
JobDefs {
Name = "Job-vlsr02"
Type = Backup
Level = Full
# wpisz [Name] w sekcji [Client]
Client = vlsr02
# wpisz [Name] w sekcji [FileSet]
FileSet = "VLSR02 Set"
Schedule = "WeeklyCycle"
Storage = File1
Messages = Standard
Pool = File
SpoolAttributes = yes
Priority = 10
Write Bootstrap = "/var/spool/bacula/%c.bsr"
}
# zdefiniuj zadanie kopii zapasowej
Job {
Name = "vlsr02-BackupClient"
# wpisz [Name] w sekcji [Client]
Client = vlsr02
# wpisz [Name] w sekcji [JobDefs]
JobDefs = "Job-vlsr02"
}
# zdefiniuj zestaw File
FileSet {
Name = "VLSR02 Set"
Include {
Options {
signature = MD5
Compression = GZIP
}
# docelowy katalog do bakupu
File = /etc
}
}
# zdefiniuj klienta
Client {
Name = vlsr02
# hostname lub adres IP klienta
Address = vlsr02.zicher.lab
FDPort = 9102
Catalog = MyCatalog
# hasło demona File
Password = "TajneHasło"
File Retention = 60 days
Job Retention = 6 months
AutoPrune = yes
}

[root@vlsr01 ~]# systemctl restart bacula-dir

[6] Skonfiguruj klienta Bacula.

[root@vlsr02 ~]# mcedit /etc/bacula/bacula-fd.conf
Director {
Name = bacula-dir
# linia 19: hasło demona File
Password = "TajneHasło"
}
. . . . .
# linia 28: hasło tray-monitor’a
Director {
Name = bacula-mon
Password = "TajneHasło"
Monitor = yes
}

[root@vlsr02 ~]# mcedit /etc/bacula/bconsole.conf
Director {
Name = bacula-dir
DIRport = 9101
# hostname lub adres  IP demona Director
address = vlsr01.zicher.lab
# hasło demona Director
Password = "TajneHasło"
}

[root@vlsr02 user01]# systemctl enable --now bacula-fd

[7] W porządku. Możliwe jest uruchomienie operacji tworzenia kopii zapasowej i przywracania zarówno na serwerze, jak i na kliencie.

Dla przykładu uruchom tworzenie kopii zapasowej i przywracanie na hoście klienta.

# BACKUP
[root@vlsr02 ~]# bconsole
Connecting to Director vlsr01.zicher.lab:9101
1000 OK: 103 bacula-dir Version: 9.0.6 (20 November 2017)
Enter a period to cancel a command.
*label
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
The defined Storage resources are:
     1: File1
     2: File2
Select Storage resource (1-2): 1
Connecting to Storage daemon File1 at vlsr01.zicher.lab:9103 ...
Enter autochanger drive[0]: # Enter
Enter new Volume name: Vol_vlsr02-etc_20220321-666
Enter slot (0 or Enter for none): # Enter
Defined Pools:
     1: Default
     2: File
     3: Scratch
Select the Pool (1-3): 2
Connecting to Storage daemon File1 at vlsr01.zicher.lab:9103 ...
Sending label command for Volume "Vol_vlsr02-etc_20220321-666" Slot 0 ...
3000 OK label. VolBytes=246 VolABytes=0 VolType=1 Volume="Vol_vlsr02-etc_20220321-666" Device="FileChgr1-Dev1" (/tmp)
Catalog record for Volume "Vol_vlsr02-etc_20220321-666", Slot 0  successfully created.
Requesting to mount FileChgr1 ...
3906 File device ""FileChgr1-Dev1" (/tmp)" is always mounted.
You have messages.
*run
A job name must be specified.
The defined Job resources are:
     1: BackupClient1
     2: BackupCatalog
     3: RestoreFiles
     4: vlsr02-BackupClient
Select Job resource (1-4): 4
Run Backup job
JobName:  vlsr02-BackupClient
Level:    Full
Client:   vlsr02
FileSet:  VLSR02 Set
Pool:     File (From Job resource)
Storage:  File1 (From Job resource)
When:     2022-03-21 16:17:55
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=11
*exit

# RESTORE
[root@vlsr02 ~]# bconsole
Connecting to Director vlsr01.zicher.lab:9101
1000 OK: 103 bacula-dir Version: 9.0.6 (20 November 2017)
Enter a period to cancel a command.
*restore
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.
To select the JobIds, you have the following choices:
     1: List last 20 Jobs run
     2: List Jobs where a given File is saved
     3: Enter list of comma separated JobIds to select
     4: Enter SQL list command
     5: Select the most recent backup for a client
     6: Select backup for a client before a specified time
     7: Enter a list of files to restore
     8: Enter a list of files to restore before a specified time
     9: Find the JobIds of the most recent backup for a client
    10: Find the JobIds for a backup for a client before a specified time
    11: Enter a list of directories to restore for found JobIds
    12: Select full restore to a specified Job date
    13: Cancel
Select item:  (1-13): 5
Defined Clients:
     1: bacula-fd
     2: vlsr02
Select the Client (1-2): 2
Automatically selected FileSet: VLSR02 Set
+-------+-------+----------+-----------+---------------------+-----------------------------+
| JobId | Level | JobFiles | JobBytes  | StartTime           | VolumeName                  |
+-------+-------+----------+-----------+---------------------+-----------------------------+
|    11 | F     |      992 | 5,964,981 | 2022-03-21 16:18:03 | Vol_vlsr02-etc_20220321-666 |
+-------+-------+----------+-----------+---------------------+-----------------------------+
You have selected the following JobId: 11
Building directory tree for JobId(s) 11 ...  +++++++++++++++++++++++++++++++++++++++++
820 files inserted into the tree.
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
cwd is: /
$ ls
etc/
$ mark etc
992 files marked.
$ done
Bootstrap records written to /var/spool/bacula/bacula-dir.restore.1.bsr
The Job will require the following (*=>InChanger):
   Volume(s)                 Storage(s)                SD Device(s)
===========================================================================
    Vol_vlsr02-etc_20220321-666 File1                     FileChgr1
Volumes marked with "*" are in the Autochanger.
992 files selected to be restored.
Using Catalog "MyCatalog"
Run Restore job
JobName:         RestoreFiles
Bootstrap:       /var/spool/bacula/bacula-dir.restore.1.bsr
Where:           /tmp/bacula-restores
Replace:         Always
FileSet:         Full Set
Backup Client:   vlsr02
Restore Client:  vlsr02
Storage:         File1
When:            2022-03-21 16:21:05
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=12
You have messages.
*exit

[root@vlsr02 ~]# ll /tmp/bacula-restores/etc
razem 1244
-rw-r--r--.  1 root  root       16 2021-02-18  adjtime
-rw-r--r--.  1 root  root     1529 2020-05-15  aliases
drwxr-xr-x.  2 root  root        6 02-02 15:07 alternatives
. . . . .
# wszystko OK – kopia przywrócona