Bacula网络备份软件安装配置

Bacula : Install

 

MariaDB 10.3 : Install

2019/10/31

 

 

Install MariaDB to configure Database Server.

[1]

Install MariaDB.

 

[root@www ~]# 

dnf module -y install mariadb:10.3

[root@www ~]# 

vi /etc/my.cnf.d/charaset.cnf

# create new

 

# set default charaset

 

# if not set, default is [latin1]

 

# for the case of 4 bytes UTF-8, specify [utf8mb4]


 

[mysqld]

character-set-server = utf8mb4

 

[client]

default-character-set = utf8mb4

 

[root@www ~]# 

systemctl enable --now mariadb

 

[2]

If Firewalld is running and also you allow to access MariaDB Server from remote Hosts, allow service. MariaDB uses [3306/TCP].

 

[root@www ~]# 

firewall-cmd --add-service=mysql --permanent


success
[root@www ~]# 

firewall-cmd --reload


success

 

[3]

Initial Settings for MariaDB.

 

[root@www ~]# 

mysql_secure_installation


 

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

 

# set root password

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

# remove anonymous users

Remove anonymous users? [Y/n] y

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

# disallow root login remotely

Disallow root login remotely? [Y/n] y

 ... Success!

 

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

# remove test database

Remove test database and access to it? [Y/n] y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

# reload privilege tables

Reload privilege tables now? [Y/n] y

 ... Success!

 

Cleaning up...

 

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB!

 

# connect to MariaDB with root


[root@www ~]# 

mysql -u root -p


Enter password:     

# password you set


 

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 17

Server version: 10.3.11-MariaDB MariaDB Server

 

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

# show user list

MariaDB [(none)]> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |

| root | 127.0.0.1 | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |

| root | ::1       | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |

+------+-----------+-------------------------------------------+

3 rows in set (0.000 sec)

 

# show database list

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

 

# create test database

MariaDB [(none)]> create database test_database;

Query OK, 1 row affected (0.000 sec)

 

# create test table on test database

MariaDB [(none)]> create table test_database.test_table (id int, name varchar(50), address varchar(50), primary key (id));

Query OK, 0 rows affected (0.108 sec)

 

# insert data to test table

MariaDB [(none)]> insert into test_database.test_table(id, name, address) values("001", "CentOS", "Hiroshima");

Query OK, 1 row affected (0.036 sec)

 

# show test table

MariaDB [(none)]> select * from test_database.test_table;

+----+--------+-----------+

| id | name   | address   |

+----+--------+-----------+

|  1 | CentOS | Hiroshima |

+----+--------+-----------+

1 row in set (0.000 sec)

 

# delete test database

MariaDB [(none)]> drop database test_database;

Query OK, 1 row affected (0.111 sec)

 

MariaDB [(none)]> exit

Bye

 

 

[2]

Install Bacula components.

 

[root@dlp ~]# 

dnf -y install bacula-director bacula-storage bacula-console bacula-client

 

[3]

Add a User and Database on MariaDB for Bacula.

 

# change default to MariaDB


[root@dlp ~]# 

alternatives --config libbaccats.so


 

 

There are 3 programs which provide 'libbaccats.so'.

 

  Selection    Command

-----------------------------------------------

   1           /usr/lib64/libbaccats-mysql.so

   2           /usr/lib64/libbaccats-sqlite3.so

*+ 3           /usr/lib64/libbaccats-postgresql.so

 

Enter to keep the current selection[+], or type selection number: 1

 

# create database for bacula


[root@dlp ~]# 

mysql -u root -p


 

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 16

Server version: 10.3.17-MariaDB MariaDB Server

 

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> create database bacula;

Query OK, 1 row affected (0.00 sec)

 

# replace [password] to your own password

MariaDB [(none)]> grant all privileges on bacula.* to bacula@'localhost' identified by 'password';

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> grant all privileges on bacula.* to bacula@'%' identified by 'password';

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> exit

Bye

 

# create tables


[root@dlp ~]# 

/usr/libexec/bacula/make_mysql_tables -p


Enter password:   

# MariaDB root password


Creation of Bacula MySQL tables succeeded.

 

 

[1]

Configure Bacula Director.

 

[root@dlp ~]# 

vi /etc/bacula/bacula-dir.conf

Director {                      # define myself

  Name = bacula-dir

  DIRport = 9101                # where we listen for UA connections

  QueryFile = "/etc/bacula/query.sql"

  WorkingDirectory = "/var/spool/bacula"

  PidDirectory = "/var/run"

  Maximum Concurrent Jobs = 20

  # line 25: set password for Director daemon

  Password = "password"         # Console password

  Messages = Daemon

}

 

.....

.....

 

FileSet {

  Name = "Full Set"

  Include {

    Options {

      signature = MD5

      # line 110: add (enable GZIP compress)

      Compression = GZIP

    }

 

.....

.....

 

    # line 126: specify backup target directory

    File = /home

  }

 

.....

.....

 

Client {

  Name = bacula-fd

  Address = localhost

  FDPort = 9102

  Catalog = MyCatalog

  # line 178: password for File daemon

  Password = "password"          # password for FileDaemon

  File Retention = 60 days            # 60 days

  Job Retention = 6 months            # six months

  AutoPrune = yes                     # Prune expired Jobs/Files

}

 

.....

.....

 

Autochanger {

  Name = File1

# Do not use "localhost" here

  # line 204: change to FQDN of your host according to the note

  Address = dlp.srv.world             # N.B. Use a fully qualified name here

  SDPort = 9103

  # line 206: password for Storage daemon

  Password = "password"

  Device = FileChgr1

  Media Type = File1

  Maximum Concurrent Jobs = 10        # run up to 10 jobs a the same time

  Autochanger = File1                 # point to ourself

}

 

.....

.....

 

Catalog {

  Name = MyCatalog

  # line 243: password of MariaDB bacula user

  dbname = "bacula"; dbuser = "bacula"; dbpassword = "password"

}

 

.....

.....

 

Pool {

  Name = File

  Pool Type = Backup

  Recycle = yes                       # Bacula can automatically recycle Volumes

  AutoPrune = yes                     # Prune expired volumes

  # line 304: volume retenstion term

  Volume Retention = 365 days         # one year

  # max volume size

  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable

  # max volume number

  Maximum Volumes = 100               # Limit number of Volumes in Pool

  # prefix for volume files

  Label Format = "Vol-"               # Auto label

}

 

.....

.....

 

# line 320: comment out now

#Console {

#  Name = bacula-mon

#  Password = "@@MON_DIR_PASSWORD@@"

#  CommandACL = status, .status

#}

 

[root@dlp ~]# 

vi /etc/bacula/bconsole.conf

Director {

  Name = bacula-dir

  DIRport = 9101

  address = localhost

  # password for Director

  Password = "password"

}

~

[root@dlp ~]# 

systemctl enable --now bacula-dir

 

[2]

Configure Bacula Storage.

 

[root@dlp ~]# 

vi /etc/bacula/bacula-sd.conf

Director {

  Name = bacula-dir

  # line 31: set password for Storage daemon

  Password = "password"

}

 

.....

.....

 

# line 38: comment out now

#Director {

#  Name = bacula-mon

#  Password = "@@MON_SD_PASSWORD@@"

#  Monitor = yes

#}

 

[root@dlp ~]# 

systemctl enable --now bacula-sd

 

[3]

Configure Bacula File.

 

[root@dlp ~]# 

vi /etc/bacula/bacula-fd.conf

Director {

  Name = bacula-dir

  # line 19: set password for File daemon

  Password = "password"

}

 

.....

.....

 

# line 26: comment out now

#Director {

#  Name = bacula-mon

#  Password = "@@MON_FD_PASSWORD@@"

#  Monitor = yes

#}

 

[root@dlp ~]# 

systemctl enable --now bacula-fd

 

 

 

[1]

Run Backup on Bacula console.

 

[root@dlp ~]# 

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.

# set backup volume and so on

*label

Automatically selected Catalog: MyCatalog

Using Catalog "MyCatalog"

# select resource for backup

# follows are default and they have the same settings, backup data saved under [/tmp]

The defined Storage resources are:

     1: File1

     2: File2

Select Storage resource (1-2): 1

Enter autochanger drive[0]:

# input any volume name

Enter new Volume name: Vol-20200213

Enter slot (0 or Enter for none):

# select a pool

Defined Pools:

     1: Default

     2: File

     3: Scratch

Select the Pool (1-3): 2

Connecting to Storage daemon File1 at dlp.srv.world:9103 ...

Sending label command for Volume "Vol-20200213" Slot 0 ...

3000 OK label. VolBytes=227 VolABytes=0 VolType=1 Volume="Vol-20200213" Device="FileChgr1-Dev1" (/tmp)

Catalog record for Volume "Vol-20200213", Slot 0  successfully created.

Requesting to mount FileChgr1 ...

3906 File device ""FileChgr1-Dev1" (/tmp)" is always mounted.

# run backup job

*run

A job name must be specified.

# select job (follows are default)

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:  File1 (From Job resource)

When:     2020-02-12 19:35:47

Priority: 10

OK to run? (yes/mod/no): yes

Job queued. JobId=1

You have messages.

# show messages (log)

*messages

12-Feb 19:35 bacula-dir JobId 1: No prior Full backup Job record found.

12-Feb 19:35 bacula-dir JobId 1: No prior or suitable Full backup found in catalog. Doing FULL backup.

12-Feb 19:35 bacula-dir JobId 1: Start Backup JobId 1, Job=BackupClient1.2020-02-12_19.35.53_05

12-Feb 19:35 bacula-dir JobId 1: Using Device "FileChgr1-Dev1" to write.

12-Feb 19:35 bacula-sd JobId 1: Wrote label to prelabeled Volume "Vol-20200213" on File device "FileChgr1-Dev1" (/tmp)

12-Feb 19:35 bacula-sd JobId 1: Elapsed time=00:00:01, Transfer rate=952  Bytes/second

12-Feb 19:35 bacula-sd JobId 1: Sending spooled attrs to the Director. Despooling 1,098 bytes ...

12-Feb 19:35 bacula-dir JobId 1: Bacula bacula-dir 9.0.6 (20Nov17):

  Build OS:               x86_64-redhat-linux-gnu redhat (Core)

  JobId:                  1

  Job:                    BackupClient1.2020-02-13_13.35.53_05

  Backup Level:           Full (upgraded from Incremental)

  Client:                 "bacula-fd" 9.0.6 (20Nov17) x86_64-redhat-linux-gnu,redhat,(Core)

  FileSet:                "Full Set" 2020-02-12 19:35:53

  Pool:                   "File" (From Job resource)

  Catalog:                "MyCatalog" (From Client resource)

  Storage:                "File1" (From Job resource)

  Scheduled time:         12-Feb-2020 19:35:47

  Start time:             12-Feb-2020 19:35:56

  End time:               12-Feb-2020 19:35:56

  Elapsed time:           1 sec

  Priority:               10

  FD Files Written:       6

  SD Files Written:       6

  FD Bytes Written:       394 (394 B)

  SD Bytes Written:       952 (952 B)

  Rate:                   0.4 KB/s

  Software Compression:   None

  Comm Line Compression:  1.8% 1.0:1

  Snapshot/VSS:           no

  Encryption:             no

  Accurate:               no

  Volume name(s):         Vol-20200213

  Volume Session Id:      1

  Volume Session Time:    1581567347

  Last Volume Bytes:      1,747 (1.747 KB)

  Non-fatal FD errors:    0

  SD Errors:              0

  FD termination status:  OK

  SD termination status:  OK

  Termination:            Backup OK

 

12-Feb 19:35 bacula-dir JobId 1: Begin pruning Jobs older than 6 months .

12-Feb 19:35 bacula-dir JobId 1: No Jobs found to prune.

12-Feb 19:35 bacula-dir JobId 1: Begin pruning Files.

12-Feb 19:35 bacula-dir JobId 1: No Files found to prune.

12-Feb 19:35 bacula-dir JobId 1: End auto prune.

 

*exit

 

[root@dlp ~]# 

ll /tmp


 

total 4

drwx------. 3 root   root   17 Feb 12 10:23 systemd-private-e3923256cb724d9fa8091054d65cbf15-chronyd.service-U4XZcS

drwx------. 3 root   root   17 Feb 12 11:29 systemd-private-e3923256cb724d9fa8091054d65cbf15-mariadb.service-HLzEZb

-rw-r-----. 1 bacula tape 1747 Feb 12 19:35 Vol-20200213

# backup data just saved

 

 

 

[1]

Run Restore on Bacula console.

 

[root@dlp ~]# 

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.

# start restore task

*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.

 

# select restore job

# select latest backup job (#5) on this example

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     |        6 |      394 | 2020-02-12 19:35:56 | Vol-20200213 |

+-------+-------+----------+----------+---------------------+--------------+

You have selected the following JobId: 1

 

Building directory tree for JobId(s) 1 ...

4 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: /

# show backup data

$ ls

home/

# mark data you'd like to restore

$ mark home

6 files marked.

# show marked file list

$ lsmark

*home/

  *cent/

    *.bash_logout

    *.bash_profile

    *.bashrc

  *testfile.txt

# finish restore setting

$ done

Bootstrap records written to /var/spool/bacula/bacula-dir.restore.3.bsr

 

The Job will require the following (*=>InChanger):

   Volume(s)                 Storage(s)                SD Device(s)

===========================================================================

 

    Vol-20200213              File1                     FileChgr1

 

Volumes marked with "*" are in the Autochanger.

 

 

6 files selected to be restored.

 

Using Catalog "MyCatalog"

Run Restore job

JobName:         RestoreFiles

Bootstrap:       /var/spool/bacula/bacula-dir.restore.3.bsr

Where:           /tmp/bacula-restores

Replace:         Always

FileSet:         Full Set

Backup Client:   bacula-fd

Restore Client:  bacula-fd

Storage:         File1

When:            2020-02-12 19:47:30

Catalog:         MyCatalog

Priority:        10

Plugin Options:  *None*

# run restore job

OK to run? (yes/mod/no): yes

Job queued. JobId=4

# show messages (log)

*messages

12-Feb 19:47 bacula-dir JobId 4: Start Restore Job RestoreFiles.2020-02-12_19.47.32_13

12-Feb 19:47 bacula-dir JobId 4: Using Device "FileChgr1-Dev2" to read.

12-Feb 19:47 bacula-sd JobId 4: Ready to read from volume "Vol-20200213" on File device "FileChgr1-Dev2" (/tmp).

12-Feb 19:47 bacula-sd JobId 4: Forward spacing Volume "Vol-20200213" to addr=227

12-Feb 19:47 bacula-sd JobId 4: End of Volume "Vol-20200213" at addr=1747 on device "FileChgr1-Dev2" (/tmp).

12-Feb 19:47 bacula-sd JobId 4: Elapsed time=00:00:01, Transfer rate=952  Bytes/second

12-Feb 19:47 bacula-dir JobId 4: Bacula bacula-dir 9.0.6 (20Nov17):

  Build OS:               x86_64-redhat-linux-gnu redhat (Core)

  JobId:                  4

  Job:                    RestoreFiles.2020-02-12_19.47.32_13

  Restore Client:         bacula-fd

  Start time:             12-Feb-2020 19:47:34

  End time:               12-Feb-2020 19:47:35

  Files Expected:         6

  Files Restored:         6

  Bytes Restored:         490

  Rate:                   0.5 KB/s

  FD Errors:              0

  FD termination status:  OK

  SD termination status:  OK

  Termination:            Restore OK

 

12-Feb 19:47 bacula-dir JobId 4: Begin pruning Jobs older than 6 months .

12-Feb 19:47 bacula-dir JobId 4: No Jobs found to prune.

12-Feb 19:47 bacula-dir JobId 4: Begin pruning Files.

12-Feb 19:47 bacula-dir JobId 4: No Files found to prune.

12-Feb 19:47 bacula-dir JobId 4: End auto prune.

 

*exit

 

[root@dlp ~]# 

ll /tmp/bacula-restores/home


 

total 4

drwx------. 2 cent cent 62 Oct 12 22:39 cent

-rw-r--r--. 1 root root 19 Feb 12 19:28 testfile.txt

# backup data restored

 

[2]

If SELinux is enabled, change policy because restore job fails.

 

[root@dlp ~]# 

vi baculafd.te

# create new


 

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;

 

[root@dlp ~]# 

checkmodule -m -M -o baculafd.mod baculafd.te


checkmodule: loading policy configuration from baculafd.te
checkmodule: policy configuration loaded
checkmodule: writing binary representation (version 19) to baculafd.mod
[root@dlp ~]# 

semodule_package --outfile baculafd.pp --module baculafd.mod


[root@dlp ~]# 

semodule -i baculafd.pp

 

 

 

Bacula : Add remote Clients

2020/02/17

 

 

It's possible to add remote Hosts as backup target Clients.
This example is based on the environment like follows.

+----------------------+          |          +----------------------+

| [   Bacula Server  ] |10.0.0.30 | 10.0.0.51| [   Bacula Client  ] |

|    Bacula Director   +----------+----------+    (Backup Target)   |

|    Bacula Storage    |                     |  Bacula File Daemon  |

|  Bacula File Daemon  |                     |                      |

|       Maria DB       |                     |                      |

+----------------------+                     +----------------------+

 

[1]

Configure basic Bacula Server, refer to here.

[2]

Install File component on new remote Bacula client Host.

 

[root@node01 ~]# 

dnf -y install bacula-client bacula-console

 

[3]

On Bacula Server, if Firewalld is running, allow service.

 

[root@dlp ~]# 

firewall-cmd --add-service=bacula --permanent


success
[root@dlp ~]# 

firewall-cmd --reload


success

 

[4]

On Bacula Client, if Firewalld is running, allow service.

 

[root@node01 ~]# 

firewall-cmd --add-service=bacula-client --permanent


success
[root@node01 ~]# 

firewall-cmd --reload


success

 

[5]

Configure Bacula Server.

 

[root@dlp ~]# 

vi /etc/bacula/bacula-dir.conf

# add to the end


 

# define job

JobDefs {

  Name = "Job-node01"

  Type = Backup

  Level = Incremental

  # specify [Name] value in [Client] section

  Client = node01

  # specify [Name] value in [FileSet] section

  FileSet = "Node01 Set"

  Schedule = "WeeklyCycle"

  Storage = File1

  Messages = Standard

  Pool = File

  SpoolAttributes = yes

  Priority = 10

  Write Bootstrap = "/var/spool/bacula/%c.bsr"

}

 

# define backup job

Job {

  Name = "node01-BackupClient"

  # specify [Name] value in [Client] section

  Client = node01

  # specify [Name] value in [JobDefs] section

  JobDefs = "Job-node01"

}

 

# define File Set

FileSet {

  Name = "Node01 Set"

  Include {

    Options {

      signature = MD5

      Compression = GZIP

    }

      # backup target directory

      File = /etc

  }

}

 

# define client

Client {

  Name = node01

  # client hostname or IP address

  Address = node01.srv.world

  FDPort = 9102

  Catalog = MyCatalog

  # password for File daemon

  Password = "password"

  File Retention = 60 days

  Job Retention = 6 months

  AutoPrune = yes

}

 

[root@dlp ~]# 

systemctl restart bacula-dir

 

[6]

Configure Bacula Client.

 

[root@node01 ~]# 

vi /etc/bacula/bacula-fd.conf

Director {

  Name = bacula-dir

  # line 19: password for File daemon

  Password = "password"

}

 

.....

.....

 

# line 26: comment out now

#Director {

#  Name = bacula-mon

#  Password = "@@MON_FD_PASSWORD@@"

#  Monitor = yes

#}

 

[root@node01 ~]# 

vi /etc/bacula/bconsole.conf

Director {

  Name = bacula-dir

  DIRport = 9101

  # hostname or IP address of Director daemon

  address = dlp.srv.world

  # password which is set in Director

  Password = "password"

}

 

[root@node01 ~]# 

systemctl enable --now bacula-fd

 

[7]

That's OK.
It's possible to run backup and restore operation on both Server or Client.
For example, run backup and restore on Client Host.

 

# backup


[root@node01 ~]# 

bconsole


 

Connecting to Director dlp.srv.world: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

Enter autochanger drive[0]:

Enter new Volume name: Vol_node01-etc_20200214

Enter slot (0 or Enter for none):

Defined Pools:

     1: Default

     2: File

     3: Scratch

Select the Pool (1-3): 2

Connecting to Storage daemon File1 at dlp.srv.world:9103 ...

Sending label command for Volume "Vol_node01-etc_20200214" Slot 0 ...

3000 OK label. VolBytes=238 VolABytes=0 VolType=1 Volume="Vol_node01-etc_20200214" Device="FileChgr1-Dev1" (/tmp)

Catalog record for Volume "Vol_node01-etc_20200214", 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: node01-BackupClient

Select Job resource (1-4): 4

Run Backup job

JobName:  node01-BackupClient

Level:    Incremental

Client:   node01

FileSet:  Node01 Set

Pool:     File (From Job resource)

Storage:  File1 (From Job resource)

When:     2020-02-13 21:20:50

Priority: 10

OK to run? (yes/mod/no): yes

Job queued. JobId=15

*exit

 

# restore


[root@node01 ~]# 

bconsole


 

Connecting to Director dlp.srv.world: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: node01

Select the Client (1-2): 2

The defined FileSet resources are:

     1: Full Set

     2: Node01 Set

Select FileSet resource (1-2): 2

+-------+-------+----------+-----------+---------------------+------------------+

| JobId | Level | JobFiles | JobBytes  | StartTime           | VolumeName       |

+-------+-------+----------+-----------+---------------------+------------------+

|    12 | F     |      702 | 5,357,084 | 2020-02-13 21:07:10 | Vol-20200214_etc |

+-------+-------+----------+-----------+---------------------+------------------+

You have selected the following JobId: 12

 

Building directory tree for JobId(s) 12 ...  ++++++++++++++++++++++++++++++++++++++

581 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

702 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-20200214_etc          File1                     FileChgr1

 

Volumes marked with "*" are in the Autochanger.

 

 

702 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:   node01

Restore Client:  node01

Storage:         File1

When:            2020-02-13 21:22:33

Catalog:         MyCatalog

Priority:        10

Plugin Options:  *None*

OK to run? (yes/mod/no): yes

Job queued. JobId=16

*exit

 

[root@node01 ~]# 

ll /tmp/bacula-restores/etc


 

total 1060

-rw-r--r--.  1 root root       16 Oct 12 22:39 adjtime

-rw-r--r--.  1 root root     1518 Sep 10  2018 aliases

drwxr-xr-x.  2 root root      129 Jan 16 09:30 alternatives

-rw-r--r--.  1 root root      541 Nov  9 01:47 anacrontab

drwxr-x---.  4 root root      100 Oct 12 22:40 audit

drwxr-xr-x.  3 root root       46 Nov  9 01:29 authselect

drwxr-xr-x.  2 root root       49 Feb 13 16:58 bacula

.....

.....

# restored

 

猜你喜欢

转载自blog.csdn.net/allway2/article/details/107449673
今日推荐