Centos6.3 deployment of Bacula for Remote Backup Recovery

Source: Internet
Author: User
Tags bacula

Bacula is an open-source cross-platform network backup tool that provides an enterprise-class CS-based backup solution. You can back up, restore, and verify data integrity.

Features: Full backup, Incremental backup, and differential backup are supported. Multiple recovery methods are supported, including ext3, ext2, reiserfs, xfs, jfs, smbfs, iso9660, and ntfs) supports a variety of backup media support a variety of operating systems powerful internal functions a complete bacula backup system, consists of the following five parts Director Daemon: monitors all backup, recovery, verification, archiving transactions, and custom backup and recovery file plans, and records the operating status of the entire system in one database file. Its configuration file is bacula-dir.conf. Storage Daemon (SD): it is mainly responsible for backing up data to the Storage medium, and transmitting data from the Storage medium during data recovery. Its configuration file is bacula-sd.conf. File Daemon (FD): a Daemon installed on the machine on which data is backed up. When backing up data, the Daemon is responsible for transferring files out, receives and recovers data when restoring data. The configuration file is bacula-fd.conf. Console: The management Console. You can use this console to connect to Director Daemon for backup and recovery management. Monitor: Process Monitoring end. Workflow: 1. Connect to ctor through the console and start the Backup recovery operation. 2. Director transfers record information from your own database to coordinate the storage SD and client FD tasks. 3. The client FD is responsible for verifying the operation permission of ctor. If the verification is successful, it is allowed to connect to the storage-side SD4. The client FD connects to the SD according to the request sent by Director, back up data on the FD end to the storage medium specified by the SD end, or transmit data on the SD end storage medium back to the specified position of the FD on the client end to complete the backup and recovery process.

I personally feel that Bacula seems to be rarely used in domestic production environments, and I do not know how many people have used this backup tool. However, I personally think this backup tool is still very good, if you like Bacula or study Bacula, contact me to learn more about this backup tool!

1. Install the Bacula master

1.1. Introduction

This document describes how to install Bacula from the source program using simple commands.

If you are using another Linux release version of Fedroa, Redhat, or Centos, refer to this document. The command name and path may vary depending on the release package or operating system. Therefore, you may need to work out the installation documents.

If you are using another Linux or other system, or want to learn more, you can find it on the official Wikipedia (http://wiki.bacula.org.

The following is a configured file, where the content after # is watched. (In some cases, Bacula has an English note, which means I have nothing to do with English)

Director {# define the global configuration of Bacula

Name = chenyi-dir

DIRport = 9101

QueryFile = "/usr/local // bacula/bin/query. SQL"

WorkingDirectory = "/usr/local // bacula/bin/working"

PidDirectory = "/usr/local // bacula/bin/working"

Maximum Concurrent Jobs = 1 # define the Maximum number of Concurrent tasks that can be processed at a time


# Verify the password. The password must be the same as the Director logical segment password in the bconsole. conf file.

Password = "kl1h6gcOxkzFAWFUb1bl7bvtyiwW702QsypPHPgcuTdK"


# Define the log output mode. "Daemon" is defined in the following Messages logical section.

Messages = Daemon

}

JobDefs {

Name = "Client1"

Type = Backup

Level = Incremental

Client = dbfd # If the local machine needs to be backed up, define dbfd as the local machine.

FileSet = "dbfs"

Schedule = "dbscd"

Storage = dbsd

Messages = Standard

Pool = dbpool

Priority = 10

Write Bootstrap = "/usr/local // bacula/bin/working/% c. bsr"

}


Job {# customize a Backup Task

Name = "wanquanbeifen" # Backup Task Name

Client = dbfd1 # specify the Client host to be backed up. "dbfd" is defined in the following Client logical section.

Level = Full # defines the backup Level. Incremental indicates Incremental backup. Level value # can be Full (Full backup), Incremental (Incremental Backup), and Differential (Differential backup). If the first # Full backup is not performed, then, execute Incremental after completing the backup.

Type = Backup # define the Job Type. "backup" is a Backup task. The optional types include restore and verify.

FileSet = "dbfs" # specify the client data to be backed up. "dbfs" is defined in the subsequent FileSet logical segments.

Schedule = "dbscd" # specify the execution time policy of the backup task. "dbscd" is defined in the Schedule logical section.

Storage = dbsd # specify the Storage path and media for the backup data. "dbsd" is specified in the subsequent Storage logical segments.

Messages = Standard

Pool = dbpool # specifies the pool attribute used for backup. "dbpool" is defined in the following Pool logical segment.

Write Bootstrap = "/usr/local // bacula/working/Client2.bsr" # specify the backup boot path

}

Job {

Name = "Client1"

Client = dbfd

Level = Incremental

Type = Backup

FileSet = "dbfs"

Schedule = "dbscd"

Storage = dbsd

Messages = Standard

Pool = dbpool

Write Bootstrap = "/usr/local // bacula/working/Client2.bsr"

}

Job {# define a differential Backup Task named Client

Name = "Client"

Type = Backup

FileSet = "dbfs"

Schedule = "dbscd"

Storage = dbsd

Messages = Standard

Pool = dbpool

Client = dbfd

Level = Differential # specify the backup Level as Differential backup

Write Bootstrap = "/usr/local // bacula/working/Client1.bsr"

}

Job {# define a restore task

Name = "RestoreFiles"

Type = Restore # define the Job Type as "Restore", that is, Restore Data

Client = dbfd1

FileSet = dbfs

Storage = dbsd

Pool = dbpool

Messages = Standard

Where =/tmp/bacula-restores # specify to restore data to this path by default

}


FileSet {# defines a backup resource named dbfs, that is, specifying the data to be backed up and the data to be excluded. You can specify multiple filesets.

Name = "dbfs"

Include {

Options {

Signature = MD5; Compression = GZIP;} # indicates using the MD5 signature and compressing

File =/boot # specify the File directory to be backed up by the FD Client

}

Exclude {# Exclude is used to Exclude files or directories that do not need to be backed up. You can modify the file or directory according to the actual situation.

File =/usr/local // bacula/working

File =/tmp

File =/proc

File =/tmp

File =/. journal

File =/. fsck

}

}

Schedule {# define a Backup Task Scheduling Policy named dbscd

Name = dbscd

Run = Full 1st sun at # complete backup at on Sunday of week 1

Run = Differential 2nd-5th sun at # 2nd ~ Differential backup at on Sunday of week 5

Run = Incremental mon-sat at # Incremental backup for all Monday to Saturday

}


FileSet {

Name = "Catalog"

Include {

Options {

Signature = MD5

}

File =/usr/local // bacula/bin/working/bacula. SQL

}

}


Client {# Client is used to define which Client FD data is backed up

Name = dbfd # Name OF Clinet, which can be called in the previous Job

Address = 192.168.1.210 # IP Address of the client FD host to be backed up

FDPort = 9102 # port for communication with the FD Client

Catalog = MyCatalog # Which database is used to store information, and "MyCatalog" is defined in the following MyCatalog logical section.

Password = "XqJ0aC66ZHt3REH1sFj6wfnTZGdQSd8oqOv + W9cJ + zkh" # verify Password for the FD ctor end and the client FD, which must be the same as the Password in the client FD profile bacula-fd.conf

File Retention = 30 days # specify how often the records stored in the database are cyclically repeated. This is 30 days, which only affects data & gt; the records in the data warehouse do not affect the backup files.

Job Retention = 6 months # specify the Job Retention period, which should be greater than the value specified by File Retention

AutoPrune = yes # Whether to automatically delete records in the database when the specified retention period is reached. yes indicates automatic clearing> expired Job

}

Client {

Name = dbfd1

Address = 192.168.1.210

FDPort = 9102

Catalog = MyCatalog

Password = "XqJ0aC66ZHt3REH1sFj6wfnTZGdQSd8oqOv + W9cJ + zkh2"

File Retention = 30 days

Job Retention = 6 months

AutoPrune = yes

}


Storage {# Storage is used to define the Storage device on which the client data is backed up

Name = dbsd

Address = 192.168.1.220 # specify the IP Address of the storage device SD

SDPort = 9103 # specify the storage terminal SD Communication Port

Password = "u1nxynwrinyi?sulvmkp/uGTYiy2C5OY7wnSqkz2voU" # verify Password for ctor and storage-side SD, which must be the same as the Director logical segment Password in the storage-side SD profile bacula-sd.conf

Device = FileStorage # specifies the storage medium for the data backup, which must be the same as the Name of the Device logical segment in the bacula-sd.conf configuration file on the storage side (here it is 192.168.1.220)

Media Type = File # specifies the category of the storage medium, which must be the same as the Media Type item name for the Device logical segment in the bacula-sd.conf configuration File of the storage side SD (here it is 192.168.1.220)

}

Catalog {# The Catalog logical segment is used to define log and database settings.

Name = MyCatalog

Dbname = "bacula"; dbuser = "bacula"; dbpassword = "" # specify the database name, user name, and password

}


The Messages {# Messages logical section is used to set how the ctor end saves logs and the log storage format. You can send the log information to the Administrator's mailbox, provided that the sendmail service is enabled.

Name = Standard

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 = dba.gao@gmail.com = all ,! Skipped

Operator = itchenyi@gmail.com = mount

Console = all ,! Skipped ,! Saved

Append = "/usr/local // bacula/bin/working/log" = all ,! Skipped # define the running log of bacula

Append = "/usr/local // bacula/log/bacula. err. log" = error, warning, fatal # define bacula> error log

Catalog = all

}

Messages {# defines a Messages logical segment named Daemon. "Daemon" has been referenced previously.

Name = Daemon

Mailcommand = "/usr/sbin/bsmtp-h localhost-f \" \ (Bacula \) \ <% r \> \ "-s \" Bacula daemon message \ "% r"

Mail = exitgogo@126.com = all ,! Skipped

Console = all ,! Skipped ,! Saved

Append = "/usr/local // bacula/log/bacula_demo.log" = all ,! Skipped

}


Pool {# defines the Pool attribute information for Job tasks, such as setting the backup file expiration time, overwrite expired backup data, and automatically clear expired backup.

Name = dbpool

Pool Type = Backup

Recycle = yes # Reuse

AutoPrune = yes # indicates that expired backup files are automatically cleared.

Volume Retention = 7 days # specify the backup file Retention time

Label Format = "db-$ {Year}-$ {Month: p/2/0/r}-$ {Day: p/2/0/r}-id $ {JobId} "# Set the backup file

Naming format, which produces the named file: db-2013-01-27-xxx

Maximum Volumes = 7 # set the Maximum number of backup files to be saved

Recycle Current Volume = yes # indicates that the latest expired backup files can be used to store new backups.

Maximum Volume Jobs = 1 # indicates that each Backup Task is executed to create a backup file.

}


Console {# Restrict the Console to use tray-monitor to obtain the Director status information

Name = chenyi-mon

Password = "/I9QK/9tvB63eOHT2TGJuO7KMzOkrNGi8UtOMGq9LHga"

CommandACL = status,. status

}

3. Configure the SD of bacula

SD can be a separate server, or on a machine with Director, this example will put the SD and Director end together for configuration, the SD configuration file is a bacula-sd.conf


Storage {# defines the Storage. In this example, It is chenyi-sd.

Name = chenyi-sd # define the storage Name

SDPort = 9103 # listening port

WorkingDirectory = "/usr/local // bacula/bin/working"

Pid Directory = "/usr/local // bacula/bin/working"

Maximum Concurrent Jobs = 20

}


Director {# define a storctor that controls StorageDaemon

Name = chenyi-dir # The "Name" value must be the same as the Name of the Director logical segment in the bacula-dironf configuration file of ctor.

Password = "u1nxynwrinyi?sulvmkp/uGTYiy2C5OY7wnSqkz2voU" # The "Password" value here must be the same as the Storage logical segment Password in the Director end profile bacula-dir.conf

}


Director {# define a monitor Director

Name = chenyi-mon # The "Name" value must be the same as the Name of the Console logical segment in the bacula-diconf configuration file of ctor.

Password = "/I9QK/9tvB63eOHT2TGJuO7KMzOkrNGi8UtOMGq9LHga" # here the "Password" value is the same as the Password in the Console logical segment in the Director end configuration file bacula-dir.conf

Monitor = yes

}

Device {# define Device

Name = FileStorage # defines the Name of the Device, which is referenced in the Storage logical segment Device item in the Director configuration file bacula-dir.conf

Media Type = File # specifies the storage Media Type. File indicates that the File system is used for storage.

Archive Device =/tmp/backup # Archive Device is used to specify the backup storage media, such as cd, dvd, and tap. Here, the backup files are saved in the/tmp/backup directory.

LabelMedia = yes; # use the Label command to create a volume File

Random Access = Yes; # Set whether to use Random Access to the storage media. Here, select yes.

AutomaticMount = yes; # indicates whether to use the storage device automatically when it is turned on.

RemovableMedia = no; # whether to support removable devices, such as tap or cd. Select no here.

AlwaysOpen = no; # Whether to ensure that the tap device is always available. The tap device is not used here, so it is set to no

}


Messages {# define a log or message processing mechanism for the storage device SD

Name = Standard

Director = chenyi-dir = all

}

At this point, the main control end of Bacula is roughly configured, and then the process of Bacula will be started [this article is from www.itchenyi.com, but you must keep the original link]

Start the Bacula Process

[Root @ chenyi bin] #./bacula start

Starting the Bacula Storage daemon

Starting the Bacula File daemon

Starting the Bacula Director daemon

The configuration is complete, but there is still a key step to add storage media

[Root @ chenyi bin] #./bconsole

Connecting to Director 192.168.1.220: 9101

1000 OK: chenyi-dir Version: 5.2.6 (21 February 2012)

Enter a period to cancel a command.

* Label

Automatically selected Catalog: MyCatalog

Using Catalog "MyCatalog"

Automatically selected Storage: File

Enter new Volume name: backup

Defined Pools:

1: Default

2: File

3: Scratch

Select the Pool (1-3): 1

Connect to Storage daemon File at 192.168.1.220: 9103...

Sending label command for Volume "backup" Slot 0...

3000 OK label. VolBytes = 193 DVD = 0 Volume = "backup" Device = "FileStorage" (/tmp/backup)

Catalog record for Volume "backup", Slot 0 successfully created.

Requesting to mount FileStorage...

3906 File device "" FileStorage "(/tmp/backup)" is always mounted.

*

Configure the Client (for the Client to be backed up)

1. Compile and install Bacula

Set the environment variable and set $ HOME to/usr/local.

[Root @ chenyi bacula-5.2.6] # HOME =/usr/local/

[Root @ chenyi bacula-5.2.6] # CFLAGS = "-g-Wall"

Run the Bacula configuration script. The configure option has been introduced in the <install Bacula Console> section. The following is an example:

[Root @ chenyi ~] # Tar zxf bacula-5.2.6.tar.gz

[Root @ chenyi ~] # Cd bacula-5.2.6

Pre-Configuration

[Root @ chenyi bacula-5.2.6] #./configure -- prefix =/usr/local/bacula/-- enable-client-only

The execution result is as follows:

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 Configuration on Thu Dec610: 23: 35CST2012: Host: i686-pc-linux-gnu -- redhatBacula version: Bacula5.2.6 (21February2012) Source code location :. install binaries:/usr/local/bacula/sbinInstall libraries:/usr/local/bacula/libInstall config files:/usr/local/bacula/etcScripts directory: /usr/local/bacula/etcArchive directory:/tmpWorking directory:/usr/local/bacula/var/bacula/workingPID directory:/var/runSubsys directory: /var/lock/subsysMan directory :$ {datarootdir}/manData directory:/usr/local/bacula/sharePlugin directory:/usr/local/bacula/libCCompiler: gcc4.4.6C ++ Compiler: /usr/bin/g + + export flags:-g-O2-Wall-fno-strict-aliasing-fno-exceptions-fno-rttiLinker flags: Libraries:-lpthread-ldlStatically Linked Tools: noStatically Linked FD: noStatically Linked SD: noStatically Linked DIR: noStatically Linked CONS: noDatabase backends: NoneDatabase port: Database name: baculaDatabase user: baculaJob Output Email: root @ localhostTraceback Email: root @ localhostSMTP Host Address: localhostDirector Port: 9101 File daemon Port: 9102 Storage daemon Port: 9103 Director User: Director Group: Storage Daemon User: Storage DaemonGroup: File Daemon User: File Daemon Group: Large file support: yesBacula conio support: noreadline support: noTCP Wrappers support: noTLS support: yesEncryption support: yesZLIB support: yesLZO support: noenable-smartalloc: yesenable-lockmgr: nobat support: noenable-gnome: noenable-bwx-console: noenable-tray-monitor: noclient-only: yesbuild-dird: yesbuild-stored: yesPlugin support: yesACL support: noXATTR support: yesPython support: now.emd support: noBatch insert enabled: None

Compile and install Bacula

[Root @ chenyi bacula-5.2.6] # make

You may seeLibtool: link: cannot find the library/lib/libattr.la' or unhandled argument/Lib/libattr. la'Error. You can create a soft connection of/usr/lib/libattr. la to solve the fault.

Ln-s/usr/lib/libattr. la/lib/libattr. la

[Root @ chenyi bacula-5.2.6] # make install

[Root @ chenyi bacula-5.2.6] # make install-autostart-fd # Add an automatically started daemon

[Root @ chenyi bacula-5.2.6] # ls/etc/rc. d/init. d/| grep bacula # Verification Result

Bacula-fd

At this point, the Centos System Client has been installed. You also need to configure Bacula-fd and then start Bacula.

Director {# define a control end that allows connection to FD

Name = chenyi-dir # The "Name" value here must be in the bacula-dir.conf of the Director side configuration file

Ctor logical segment names are the same

Password = "XqJ0aC66ZHt3REH1sFj6wfnTZGdQSd8oqOv + W9cJ + zkh2" # The "Password" value here must be the same as the Client logical segment Password in the Director end configuration file bacula-dir.conf

}


Director {# define a monitoring end that allows connection to FD

Name = chenyi.2-mon # chenyi.2-mon

Password = "xjcWMuoZPw68Vrs // P9BsbLME6lh4mtOFYwhTxZPmNUe"

Monitor = yes

}


FileDaemon {# define a monitoring end that allows connection to FD

Name = chenyi.2-fd

FDport = 9102 # Monitoring Port

WorkingDirectory =/usr/local/bacula/var/bacula/working

Pid Directory =/var/run

Maximum Concurrent Jobs = 20 # define the number of Concurrent Jobs that can be processed at a time

}


Messages {# define a Messages for FD

Name = Standard

Director = chenyi.2-dir = all ,! Skipped ,! Restored

The client configuration is relatively simple. You only need to modify this file.

[Root @ chenyi bin] #./bacula start # start the process

Starting the Bacula File daemon

Verify on server

[Root @ chenyi bin] #./bconsole

Connecting to Director 192.168.1.220: 9101

1000 OK: chenyi-dir Version: 5.2.6 (21 February 2012)

Enter a period to cancel a command.

* Run

Automatically selected Catalog: MyCatalog

Using Catalog "MyCatalog"

A job name must be specified.

The defined Job resources are:

1: wanquanbeifen

2: Client1

3: Client

4: RestoreFiles


Select Job resource (1-4): 1

Run Backup job

JobName: wanquanbeifen

Level: Full

Client: dbfd1

FileSet: dbfs

Pool: dbpool (From Job resource)

Storage: dbsd (From Job resource)

When: 2013-01-27 19:20:41

Priority: 10

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

Job queued. JobId = 14

* Status

Status available:

1: Director

2: Storage

3: Client

4: All

Select daemon type for status (1-4): 3

The defined Client resources are:

1: dbfd

2: dbfd1

Select Client (File daemon) resource (1-2): 2

Connecting to Client dbfd1 at 192.168.1.210: 9102


Chenyi.2-fd Version: 5.2.6 (21 February 2012) i686-pc-linux-gnu redhat

Daemon started 27-1 running 013. Jobs: run = 1 running = 0.

Heap: heap = 0 smbytes = 90,848 max_bytes = 171,749 bufs = 60 max_bufs = 109

Sizeof: boffset_t = 8 size_t = 4 debug = 0 trace = 0

Running Jobs:

Director connected at: 27-1 013

No Jobs running.

1234567 === Terminated Jobs: jobId Level Files Bytes Status Finished Name ================================ ============================================ 14Full2919. 20MOK27-1 g001319: 20 wanquanbeifen ====

You have messages.

*

In this case, check the previously defined backup path by ls.

[Root @ chenyi bin] # ls-lh/tmp/backup/

Total usage 19 M

-Rw-r -----. 1 root 193 December 6 10:08 backup

-Rw-r -----. 1 root 19 M January 27 19:20 db-2013-01-27-id14

Next, try to restore. First, delete all the files in the Client Boot.

The entire process from deployment to backup to restoration is complete ~~~~~


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.