bacula源码安装配置

最近在做一个数据库备份系统,从开源项目入手,在bacula安装过程中碰到不少问题,写这个博客记录一下。


先记录配置文件内容,之后更新其他部分。


bconsole.conf内容

Director {
  Name = localhost.localdomain-dir
  DIRport = 9101
  address = localhost
  Password = "0UyAGyOVqPomOYEowpVmK1fiXciby76oh84ZX1QZ2QRX"
}

bacula-dir.conf内容

 
Director {                            # define myself
  Name = localhost.localdomain-dir
  DIRport = 9101                # where we listen for UA connections
  QueryFile = "/home/bacula/etc/query.sql"
  WorkingDirectory = "/opt/bacula/working"
  PidDirectory = "/var/run"
  Maximum Concurrent Jobs = 20
  Password = "0UyAGyOVqPomOYEowpVmK1fiXciby76oh84ZX1QZ2QRX"         # Console password
  Messages = Daemon
}

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Client = localhost.localdomain-fd
  FileSet = "Full Set"
  Schedule = "WeeklyCycle"
  Storage = File1
  Messages = Standard
  Pool = File
  SpoolAttributes = yes
  Priority = 10
  Write Bootstrap = "/opt/bacula/working/%c.bsr"
}

Job {
  Name = "BackupClient1"
  JobDefs = "DefaultJob"
}

# Backup the catalog database (after the nightly save)
Job {
  Name = "BackupCatalog"
  JobDefs = "DefaultJob"
  Level = Full
  FileSet="Catalog"
  Schedule = "WeeklyCycleAfterBackup"
  # This creates an ASCII copy of the catalog
  # Arguments to make_catalog_backup.pl are:
  #  make_catalog_backup.pl <catalog-name>
  RunBeforeJob = "/home/bacula/etc/make_catalog_backup.pl MyCatalog"
  # This deletes the copy of the catalog
  RunAfterJob  = "/home/bacula/etc/delete_catalog_backup"
  Write Bootstrap = "/opt/bacula/working/%n.bsr"
  Priority = 11                   # run after main backup
}

Job {
  Name = RestoreFiles
  Type = Restore
  Client = localhost.localdomain-fd
  FileSet = restroe
  Storage = File1
  Pool = Default
  Messages = Standard
  Where = /home/mybackup/restore
  Run After Job = "/home/bacula/shell/oracle_insert    /home/bacula/shell/delete_oracle_file"
}


# List of files to be backed up
FileSet {
  Name = "Full Set"
  Include {
    Options {
      signature = MD5
    }
    File = /home/bacula/sbin
  }

  Exclude {
    File = /opt/bacula/working
    File = /tmp
    File = /proc
    File = /tmp
    File = /sys
    File = /.journal
    File = /.fsck
  }
}

Schedule {
  Name = "WeeklyCycle"
  Run = Full 1st sun at 23:05
  Run = Differential 2nd-5th sun at 23:05
  Run = Incremental mon-sat at 23:05
}

# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
  Name = "WeeklyCycleAfterBackup"
  Run = Full sun-sat at 23:10
}

# This is the backup of the catalog
FileSet {
  Name = "Catalog"
  Include {
    Options {
      signature = MD5
    }
    File = "/opt/bacula/working/bacula.sql"
  }
}

# Client (File Services) to backup
Client {
  Name = localhost.localdomain-fd
  Address = localhost
  FDPort = 9102
  Catalog = MyCatalog
  Password = "YuPyURVfB4+/YfnNY6wjkF8AfdS0GBQGQyMXYVGXl5hu"          # password for FileDaemon
  File Retention = 60 days            # 60 days
  Job Retention = 6 months            # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}

# Definition of file Virtual Autochanger device
Storage {
  Name = File1
# Do not use "localhost" here
  Address = localhost                # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "PewSohrx2nRqesPK3iuf5FoaC3z8QYIUrPL2z+x2s7ZJ"
  Device = FileChgr1
  Media Type = File1
  Maximum Concurrent Jobs = 10        # run up to 10 jobs a the same time
}

Storage {
  Name = File2
# Do not use "localhost" here
  Address = localhost                # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "PewSohrx2nRqesPK3iuf5FoaC3z8QYIUrPL2z+x2s7ZJ"
  Device = FileChgr2
  Media Type = File2
  Maximum Concurrent Jobs = 10        # run up to 10 jobs a the same time
}

# Definition of LTO-4 tape Autochanger device
#Storage {
#  Name = LTO-4
#  Do not use "localhost" here
#  Address = localhost               # N.B. Use a fully qualified name here
#  SDPort = 9103
#  Password = "PewSohrx2nRqesPK3iuf5FoaC3z8QYIUrPL2z+x2s7ZJ"         # password for Storage daemon
#  Device = LTO-4                     # must be same as Device in Storage daemon
#  Media Type = LTO-4                 # must be same as MediaType in Storage daemon
#  Maximum Concurrent Jobs = 10
#}

# Generic catalog service
Catalog {
  Name = MyCatalog
  dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
}

# Reasonable message delivery -- send most everything to email address
#  and to the console
Messages {
  Name = Standard

  mailcommand = "/home/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
  operatorcommand = "/home/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
  mail = root@localhost = all, !skipped
  operator = root@localhost = mount
  console = all, !skipped, !saved
  append = "/opt/bacula/log/bacula.log" = all, !skipped
  catalog = all
}


#
# Message delivery for daemon messages (no job).
Messages {
  Name = Daemon
  mailcommand = "/home/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
  mail = root@localhost = all, !skipped
  console = all, !skipped, !saved
  append = "/opt/bacula/log/bacula.log" = all, !skipped
}

# Default pool definition
Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # one year
  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
  Maximum Volumes = 100               # Limit number of Volumes in Pool
}

# File Pool definition
Pool {
  Name = File
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # one year
  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
  Maximum Volumes = 100               # Limit number of Volumes in Pool
  Label Format = "Vol-"               # Auto label
}


# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}

Console {
  Name = localhost.localdomain-mon
  Password = "MZmC1qDyJPR9bf/bLu2sLc5N4n+c85M5uFVPbK5iNlmD"
  CommandACL = status, .status
}
FileSet {
  Name = mysql
  Include {
    File = /home/mybackup/backup/mysqlData.sql
    Options {
      signature = MD5
    }
  }
}
Job {
  Name = mysqlbackup
  Type = Backup
  Level = Full
  Client = localhost.localdomain-fd
  FileSet = mysql
  Storage = File1
  Pool = File
  Messages = Standard
  Priority = 10
  Run Before Job = /home/bacula/shell/make_mysqldump_all
  Run After Job = /home/bacula/shell/delete_mysqldump_file
  Write Bootstrap = "/opt/bacula/working/%c.bsr"
}
FileSet {
  Name = restroe
  Include {
    File = /home/mybackup/restore
    Options {
    }
  }
}
FileSet {
  Name = backupTest
  Include {
    File = /home/mybackup/backup
    Options {
    }
  }
}
Job {
  Name = backupTest
  Type = Backup
  Level = Incremental
  Client = localhost.localdomain-fd
  FileSet = backupTest
  Schedule = WeeklyCycle
  Storage = File1
  Pool = File
  Messages = Standard
}
Client {
  Name = zhouzhou-fd
  Password = abG1+yPFSmtgNiPZogVHdKtFhGWwTCBEzaZdFfB6PPhu
  Address = 172.26.162.162
  FDPort = 9102
  Catalog = MyCatalog
  File Retention = 30 days
  Job Retention = 6 months
}
FileSet {
  Name = windows
  Include {
    File = D:/databackup/backup
    Options {
    }
  }
}
Job {
  Name = windowsJob
  Type = Backup
  Level = Incremental
  Client = zhouzhou-fd
  FileSet = "Full Set"
  Schedule = WeeklyCycle
  Storage = File1
  Pool = Default
  Messages = Standard
}
FileSet {
  Name = full_backup
  Include {
    File = /home/mybackup/backup
    Options {
    }
  }
}
Job {
  Name = FULL_backup
  Type = Backup
  Level = Full
  Client = localhost.localdomain-fd
  FileSet = full_backup
  Schedule = WeeklyCycle
  Storage = File1
  Pool = File
  Messages = Standard
  Run Before Job = /home/bacula/shell/make_mysqldump_all
  Run After Job = home/bacula/shell/delete_mysqldump_file
}

bacula-fd内容


Director {
  Name = localhost.localdomain-dir
  Password = "YuPyURVfB4+/YfnNY6wjkF8AfdS0GBQGQyMXYVGXl5hu"
}


Director {
  Name = localhost.localdomain-mon
  Password = "bCD2kd5hPpxcjTh/pZM5RITNl+q9h/aE6X3LZNGHl2tX"
  Monitor = yes
}


FileDaemon {                          # this is me
  Name = localhost.localdomain-fd
  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /opt/bacula/working
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
  Plugin Directory = /home/bacula/lib
}

# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = localhost.localdomain-dir = all, !skipped, !restored
}

bacula-sd内容

Storage {                             # definition of myself
  Name = localhost.localdomain-sd
  SDPort = 9103                  # Director's port
  WorkingDirectory = "/opt/bacula/working"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
}

#
# List Directors who are permitted to contact Storage daemon
#
Director {
  Name = localhost.localdomain-dir
  Password = "PewSohrx2nRqesPK3iuf5FoaC3z8QYIUrPL2z+x2s7ZJ"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the storage daemon
#
Director {
  Name = localhost.localdomain-mon
  Password = "kn+8HJZ6Q3uo20VUWzc2pwOiTRS1KcNRqnTEa8cB88s3"
  Monitor = yes
}

Autochanger {
  Name = FileChgr1
  Device = FileChgr1-Dev1, FileChgr1-Dev2
  Changer Command = ""
  Changer Device = /dev/null
}

Device {
  Name = FileChgr1-Dev1
  Media Type = File1
  Archive Device = /tmp
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Device {
  Name = FileChgr1-Dev2
  Media Type = File1
  Archive Device = /tmp
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

#
# Define a second Virtual autochanger
#
Autochanger {
  Name = FileChgr2
  Device = FileChgr2-Dev1, FileChgr2-Dev2
  Changer Command = ""
  Changer Device = /dev/null
}

Device {
  Name = FileChgr2-Dev1
  Media Type = File2
  Archive Device = /tmp
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Device {
  Name = FileChgr2-Dev2
  Media Type = File2
  Archive Device = /tmp
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Messages {
  Name = Standard
  director = localhost.localdomain-dir = all
}


备份shell脚本内容

delete_mysqldump_file:

#!/bin/sh
rm -f /home/mybackup/backup/mysqlData.sql

delete_oracle_file

#!/bin/sh

rm -f /home/mybackup/backup/mysqlData.sql
rm -f /home/mybackup/backup/oracle_insert.sql

make_mysqldump_file

#!/bin/sh

cd /home/mybackup/backup
/home/mysql/bin/mysqldump -uroot -ppassword test >mysqlData.sql

make_oracle_all

#!/bin/sh
java -jar /home/bacula/java/O2M.jar /home/mybackup/backup/

mysqldump_all_time

#!/bin/sh

Date='date +%Y%m%d'
BakDir=/home/mybackup/allBackup/
cd $BakDir
DumpFile=$Date.sql
/home/mysql/bin/mysqldump -uroot -p123456 test >DumpFile

oracle_insert:

#!/bin/sh
echo "进行数据转换"
java -jar /home/bacula/java/M2O.jar /home/mybackup/backup/

sqlplus scott/password @/home/mybackup/backup/oracle_insert.sql


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值