[4] Bacula – Przywracanie kopii

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

Jest to podstawowa operacja przywracania danych kopii zapasowej.

[1] Uruchamiamy Restore na konsoli Bacula.

[root@vlsr01 ~]# bconsole
Connecting to Director localhost: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
Automatically selected Client: bacula-fd
Automatically selected FileSet: Full Set
+-------+-------+----------+-------------+---------------------+--------------+
| JobId | Level | JobFiles | JobBytes    | StartTime           | VolumeName   |
+-------+-------+----------+-------------+---------------------+--------------+
|     1 | F     |       75 | 569,906,869 | 2022-03-21 10:05:43 | Vol-20220321 |
+-------+-------+----------+-------------+---------------------+--------------+
You have selected the following JobId: 1
Building directory tree for JobId(s) 1 ...  ++++++++++++++++++++++++++++++++
64 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
home/
$ mark home
75 files marked.
$ lsmark
*home/
  *user01/
    *.bash_history
. . . . .
    *test1.txt
$ 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-20220321              File1                     FileChgr1
Volumes marked with "*" are in the Autochanger.
75 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:   bacula-fd
Restore Client:  bacula-fd
Storage:         File1
When:            2022-03-21 10:29:10
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=2
You have messages.
*messages
21-mar 10:06 bacula-sd JobId 1: Elapsed time=00:00:16, Transfer rate=35.61 M Bytes/second
21-mar 10:06 bacula-sd JobId 1: Sending spooled attrs to the Director. Despooling 15,893 bytes ...
21-mar 10:06 bacula-dir JobId 1: Bacula bacula-dir 9.0.6 (20Nov17):
  Build OS:               x86_64-redhat-linux-gnu redhat (Core)
  JobId:                  1
  Job:                    BackupClient1.2022-03-21_10.05.41_04
  Backup Level:           Full (upgraded from Incremental)
  Client:                 "bacula-fd" 9.0.6 (20Nov17) x86_64-redhat-linux-gnu,redhat,(Core)
  FileSet:                "Full Set" 2022-03-21 10:05:41
  Pool:                   "File" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "File1" (From Job resource)
  Scheduled time:         21-mar-2022 10:05:29
  Start time:             21-mar-2022 10:05:43
  End time:               21-mar-2022 10:06:02
  Elapsed time:           19 secs
  Priority:               10
  FD Files Written:       75
  SD Files Written:       75
  FD Bytes Written:       569,906,869 (569.9 MB)
  SD Bytes Written:       569,916,120 (569.9 MB)
  Rate:                   29995.1 KB/s
  Software Compression:   2.1% 1.0:1
  Comm Line Compression:  None
  Snapshot/VSS:           no
  Encryption:             no
  Accurate:               no
  Volume name(s):         Vol-20220321
  Volume Session Id:      1
  Volume Session Time:    1647851952
  Last Volume Bytes:      570,343,531 (570.3 MB)
  Non-fatal FD errors:    0
  SD Errors:              0
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Backup OK
21-mar 10:06 bacula-dir JobId 1: Begin pruning Jobs older than 6 months .
21-mar 10:06 bacula-dir JobId 1: No Jobs found to prune.
21-mar 10:06 bacula-dir JobId 1: Begin pruning Files.
21-mar 10:06 bacula-dir JobId 1: No Files found to prune.
21-mar 10:06 bacula-dir JobId 1: End auto prune.
21-mar 10:29 bacula-dir JobId 2: Start Restore Job RestoreFiles.2022-03-21_10.29.49_06
21-mar 10:29 bacula-dir JobId 2: Using Device "FileChgr1-Dev2" to read.
21-mar 10:29 bacula-sd JobId 2: Ready to read from volume "Vol-20220321" on File device "FileChgr1-Dev2" (/tmp).
21-mar 10:29 bacula-sd JobId 2: Forward spacing Volume "Vol-20220321" to addr=231
21-mar 10:29 bacula-sd JobId 2: End of Volume "Vol-20220321" at addr=570343531 on device "FileChgr1-Dev2" (/tmp).
21-mar 10:29 bacula-sd JobId 2: Elapsed time=00:00:01, Transfer rate=569.9 M Bytes/second
21-mar 10:29 bacula-dir JobId 2: Bacula bacula-dir 9.0.6 (20Nov17):
  Build OS:               x86_64-redhat-linux-gnu redhat (Core)
  JobId:                  2
  Job:                    RestoreFiles.2022-03-21_10.29.49_06
  Restore Client:         bacula-fd
  Start time:             21-mar-2022 10:29:51
  End time:               21-mar-2022 10:29:53
  Files Expected:         75
  Files Restored:         75
  Bytes Restored:         582,091,168
  Rate:                   291045.6 KB/s
  FD Errors:              0
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Restore OK
21-mar 10:29 bacula-dir JobId 2: Begin pruning Jobs older than 6 months .
21-mar 10:29 bacula-dir JobId 2: No Jobs found to prune.
21-mar 10:29 bacula-dir JobId 2: Begin pruning Files.
21-mar 10:29 bacula-dir JobId 2: No Files found to prune.
21-mar 10:29 bacula-dir JobId 2: End auto prune.
*exit

[root@vlsr01 ~]# ll /tmp/bacula-restores/home
razem 4
drwx------. 3 user01 user01   98 03-17 21:11 user01
# przywrócono dane z kopii

[2] Jeśli SELinux jest włączony, zmień zasady, ponieważ zadanie przywracania nie powiedzie się.

[root@vlsr01 ~]# mcedit baculafd.te
# stwórz nowy
module baculafd 1.0;
require {
        type bacula_t;
        type bacula_tmp_t;
        class lnk_file { create setattr };
        class capability dac_override;
}
#============= bacula_t ==============
allow bacula_t bacula_tmp_t:lnk_file { create setattr };
allow bacula_t self:capability dac_override;

# jeśli nie masz zainstalowanego checkpolicy, zainstaluj go [dnf install checkpolicy]
[root@vlsr01 ~]# checkmodule -m -M -o baculafd.mod baculafd.te
[root@vlsr01 ~]# semodule_package --outfile baculafd.pp --module baculafd.mod
[root@vlsr01 ~]# semodule -i baculafd.pp