bacula-5-2-13的安装以及基本的备份还原配置成功案例
来源:互联网 发布:闹钟备忘录软件 编辑:程序博客网 时间:2024/06/04 17:39
bacula-5-2-13的安装以及基本的备份还原配置成功案例
我用的是bacula5.2.13,系统方面,我在centos6和centos7下面都成功过,
bacula是个很强的备份工具,这点可以自行百度,最近在初学这个工具,此文章为怕自己忘记怎么配置备份所用,只是测试了备份以及还原文件而已,我只是一个小菜鸟,很多地方注释我都是用的自己的话,很多没有解清楚。。。。有什么不对的地方希望可以给我留言以及评论,谢谢
此次实验进行的是
1、备份以及还原本机的文件
2、备份以及还原远程客户端的文件
中文注释的地方是我修改的地方,可读性不怎么好,所有bconsole操作都是在服务器端操作,结果在客户端上查看
准备工作:
这里安装测试我只用了两台机器,一台做服务器端,配置文件有bacual-dir.conf , bacula-fd.conf , bacula-sd.conf , bconsole.conf
一台做客户端,配置文件有bacula-fd.conf , bconsole.conf
服务器:172.16.13.171 zdy1.cluster.com zdy1
客户端:172.16.13.172 zdy2.cluster.com zdy2
互相绑定主机名。关闭防火墙,selinux
一、安装
bacula的安装前:
检查gcc、gcc-c++。有的话就行,没有的话就yum安装一下。yum源的话我用的是本地镜像源,有时可能需要配个epel源和centos163源,这个可以百度
安装:
1,在服务端
yum -y install mysql mysql-server mysql-devel (mysql可以选择编译,这里采用yum安装)
centos7下:yum -y install mariadb mariadb-devel mariadb-server
创建安装包目录:mkdir /opt/bacula解压: tar xf bacula-5.2.13.tar.gz -C /opt/bacula cd /opt/bacula/bacula-5.2.13
编译安装:
./configure –prefix=/usr/local/bacula –with-mysql (如果mysql是编译的则需要指定mysql安装的路径)
make && make install
make install-autostart
vim /etc/profile 在最后一行加入: export PATH=$PATH:/usr/local/bacula/sbin 保存退出:source /etc/profile
安装完了之后,需要创建bacula对应的mysql数据库心及访问数据库的授权。
systemc mariadb start 或者service start mysqld
cd /usr/local/bacula/etc
./grant_mysql_privileges
./create_mysql_database
./make_mysql_tables
可以登录到mysql中查看bacula库的中表是否已经建立,上面三个脚本默认由空密码的root用户执行,因此需要确保mysql root的密码为空。
2,客户端
只是需要备份的客户端,因此只需要安装相应的客户端组件即可。
makdir /opt/bacula
tar xf … -C /opt/bacula
cd /opt/bacula/bacula-5.2.13
./configure –prefix=/usr/local/bacula –enable-client-only
make && make install
make install-autostart
到这里,就已经安装完成了,我觉得安装很简单,难的是理解配置文件的关系以及服务器端的job的定义
配置文件的关系可以去百度搜索看,注意理解服务器端四个配置文件:bacula-dir.conf 、bacula-fd.conf 、bacula-sd.conf 、bconsole.conf
注意理解客户端的两个文件:bconsole.conf , bacula-fd.conf
二、测试(这里我有测试备份和恢复本机文件,有备份和恢复远程客户端文件)中文注释及为我所修改
1、测试备份还原本机文件:
首先定义好服务器端bacula-dir.conf文件:
Director { # define myself Name = zdy1.cluster.com-dir DIRport = 9101 # where we listen for UA connections QueryFile = "/usr/local/bacula/etc/query.sql" WorkingDirectory = "/usr/local/bacula/opt/bacula/working" PidDirectory = "/var/run" Maximum Concurrent Jobs = 1 Password = "qYhhy5PNCZTgW/nzE1JYiPRr+fBmUYR93uqLIyFNCDR1" # Console password Messages = Daemon}JobDefs { #定义本机的文件备份 Name = "DefaultJob" Type = Backup Level = Incremental Client = zdy1.cluster.com-fd FileSet = "Full Set" Schedule = "WeeklyCycle" Storage = File Messages = Standard Pool = File Priority = 10 Write Bootstrap = "/usr/local/bacula/opt/bacula/working/%c.bsr" #备份的信息存储目录}JobDefs { #定义本机的文件还原 Name = "RestoreFiles" Type = Restore # Client=zdy1.cluster.com-fd FileSet="Full Set" Storage = File Pool = Default Messages = Standard Where = /tmp/bacula-restores #还原信息存储目录}####### 还原本机,备份本机############################Job { #备份本机文件,引用的是上面的DefaultJob Name = "Backuplocalhost" JobDefs = "DefaultJob"}Client { Name = zdy1.cluster.com-fd Address = zdy1 FDPort = 9102 Catalog = MyCatalog Password = "XJ7vbW5riIK6PDnGQMOUDVdl3PY8zT0KPit052HRpKHF" #这个密码和本机的bacula-fd.conf中第一个director的密码一样 File Retention = 30 days # 60 days Job Retention = 2 months # six months AutoPrune = yes # Prune expired Jobs/Files}Job { #还原本机文件 Name = "Restorelocahost" Type = Restore Client=zdy1.cluster.com-fd FileSet="Full Set" Storage = File Pool = File Messages = Standard Where = /home/bacula-restores #还原后的文件目录}################################################### 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 = "/usr/local/bacula/etc/make_catalog_backup.pl MyCatalog" # This deletes the copy of the catalog RunAfterJob = "/usr/local/bacula/etc/delete_catalog_backup" Write Bootstrap = "/usr/local/bacula/opt/bacula/working/%n.bsr" Priority = 11 # run after main backup}# List of files to be backed upFileSet { Name = "Full Set" Include { Options { # wildfile = "*.log" # wildfile = "*.txt" # wildfile = "*.tar.gz" # wildfile = "*.out" # exclude = yes signature = MD5 # Compression = gzip } File = /test #######这里定义的文件目录是我需要备份此目录下的所有文件 } Exclude { File = /usr/local/bacula/opt/bacula/working File = /tmp File = /proc File = /tmp 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 WeeklyCycleSchedule { Name = "WeeklyCycleAfterBackup" Run = Full sun-sat at 23:10}# This is the backup of the catalogFileSet { Name = "Catalog" Include { Options { signature = MD5 } File = "/usr/local/bacula/opt/bacula/working/bacula.sql" }}# Definition of file storage deviceStorage { Name = File# Do not use "localhost" here Address = zdy1 # N.B. Use a fully qualified name here SDPort = 9103 Password = "WDPX8qK0DJ98rvthf3Uf9p77+PxV8tfMY51HwYF5h++/" Device = FileStorage Media Type = File}# Generic catalog serviceCatalog { Name = MyCatalog dbname = "bacula"; dbuser = "bacula"; dbpassword = ""}# Reasonable message delivery -- send most everything to email address# and to the consoleMessages { Name = Standard mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" operatorcommand = "/usr/local/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 = "/usr/local/bacula/opt/bacula/log/bacula.log" = all, !skipped catalog = all}## Message delivery for daemon messages (no job).Messages { Name = Daemon mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r" mail = root@localhost = all, !skipped console = all, !skipped, !saved append = "/usr/local/bacula/opt/bacula/log/bacula.log" = all, !skipped} # Default pool definitionPool { Name = Default Pool Type = Backup Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 365 days # one year}# File Pool definitionPool { 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}# Scratch pool definitionPool { Name = Scratch Pool Type = Backup}## Restricted console used by tray-monitor to get the status of the director#Console { Name = zdy1.cluster.com-mon Password = "T24AhaA0Cg8WO4mALHG/swH0w05KgD46ODXgVszazDh7" CommandACL = status, .status}
以上修改了服务器端的dir文件,此时我想要备份还原本机,就是相当于把本机当成客户端,此时,我们需要修改本机的bacula-fd.conf文件:
Director { Name = zdy1.cluster.com-dir #改成和主机配置文件dir中的client{}中相同的name,然后下面的密码也要和dir文件中的client{}密码相同 Password = "XJ7vbW5riIK6PDnGQMOUDVdl3PY8zT0KPit052HRpKHF"}## Restricted Director, used by tray-monitor to get the# status of the file daemon#Director { Name = zdy1.cluster.com-mon #改成与服务器端console.conf配置文件中的console.conf中的name相同 Password = "qYhhy5PNCZTgW/nzE1JYiPRr+fBmUYR93uqLIyFNCDR1" #密码和服务器端dir文件中的第一个director中密码相同 Monitor = yes}## "Global" File daemon configuration specifications#FileDaemon { # this is me Name = zdy1.cluster.com-fd FDport = 9102 # where we listen for the director WorkingDirectory = /usr/local/bacula/opt/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20}
此时配置文件已经修改完毕,测试一下:
启动:bacula start
# bacula restartStopping the Bacula File daemonStopping the Bacula Storage daemonStopping the Bacula Director daemonStarting the Bacula Storage daemonStarting the Bacula File daemonStarting the Bacula Director daemon
进入控制台:bconsole
a、执行备份的命令,我在/test目录下创建了几个文件
[root@zdy1 test]# ls
test1 test2
# bconsole Connecting to Director zdy1:91011000 OK: zdy1.cluster.com-dir Version: 5.2.13 (19 February 2013)Enter a period to cancel a command.*run ######启动命令Automatically selected Catalog: MyCatalogUsing Catalog "MyCatalog"A job name must be specified.The defined Job resources are: 1: Backuplocalhost 2: RestorelocahostSelect Job resource (1-2): 1 ###############选择备份Run Backup jobJobName: BackuplocalhostLevel: IncrementalClient: zdy1.cluster.com-fdFileSet: Full SetPool: File (From Job resource)Storage: File (From Job resource)When: 2017-10-15 16:35:29Priority: 10OK to run? (yes/mod/no): yesJob queued. JobId=10You have messages.**wait #########等待*messages ########## 查看信息15-Oct 16:35 zdy1.cluster.com-dir JobId 10: No prior Full backup Job record found.15-Oct 16:35 zdy1.cluster.com-dir JobId 10: No prior or suitable Full backup found in catalog. Doing FULL backup.15-Oct 16:35 zdy1.cluster.com-dir JobId 10: Start Backup JobId 10, Job=Backuplocalhost.2017-10-15_16.35.31_0315-Oct 16:35 zdy1.cluster.com-dir JobId 10: Using Device "FileStorage" to write.15-Oct 16:35 zdy1.cluster.com-sd JobId 10: Volume "local" previously written, moving to end of data.15-Oct 16:35 zdy1.cluster.com-sd JobId 10: Ready to append to end of Volume "local" size=236615-Oct 16:35 zdy1.cluster.com-sd JobId 10: Elapsed time=00:00:01, Transfer rate=71 Bytes/second15-Oct 16:35 zdy1.cluster.com-dir JobId 10: Bacula zdy1.cluster.com-dir 5.2.13 (19Jan13): Build OS: x86_64-unknown-linux-gnu redhat (Core) JobId: 10 Job: Backuplocalhost.2017-10-15_16.35.31_03 Backup Level: Full (upgraded from Incremental) Client: "zdy1.cluster.com-fd" 5.2.13 (19Jan13) x86_64-unknown-linux-gnu,redhat,(Core) FileSet: "Full Set" 2017-10-15 13:21:03 Pool: "File" (From Job resource) Catalog: "MyCatalog" (From Client resource) Storage: "File" (From Job resource) Scheduled time: 15-Oct-2017 16:35:29 Start time: 15-Oct-2017 16:35:33 End time: 15-Oct-2017 16:35:33 Elapsed time: 0 secs Priority: 10 FD Files Written: 1 SD Files Written: 1 FD Bytes Written: 0 (0 B) SD Bytes Written: 71 (71 B) Rate: 0.0 KB/s Software Compression: None VSS: no Encryption: no Accurate: no Volume name(s): local Volume Session Id: 1 Volume Session Time: 1508056491 Last Volume Bytes: 2,877 (2.877 KB) Non-fatal FD errors: 0 SD Errors: 0 FD termination status: OK SD termination status: OK Termination: Backup OK15-Oct 16:35 zdy1.cluster.com-dir JobId 10: Begin pruning Jobs older than 2 months .15-Oct 16:35 zdy1.cluster.com-dir JobId 10: No Jobs found to prune.15-Oct 16:35 zdy1.cluster.com-dir JobId 10: Begin pruning Files.15-Oct 16:35 zdy1.cluster.com-dir JobId 10: No Files found to prune.15-Oct 16:35 zdy1.cluster.com-dir JobId 10: End auto prune.*
备份成功,我将/test下的几个文件删除掉
rm -rf /test*
b、还原测试:
*restore #使用还原命令First you select one or more JobIds that contain filesto be restored. You will be presented several methodsof specifying the JobIds. Then you will be allowed toselect 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: CancelSelect item: (1-13): 5 ####选择5进行最近的备份工作还原Defined Clients: 1: zdy1.cluster.com-fdSelect the Client (1-3): 1 ###选择需要还原的客户端(相当于本机)Automatically selected FileSet: Full Set+-------+-------+----------+----------+---------------------+------------+| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |+-------+-------+----------+----------+---------------------+------------+| 10 | F | 1 | 0 | 2017-10-15 16:35:33 | local || 11 | I | 3 | 0 | 2017-10-15 16:42:28 | local |+-------+-------+----------+----------+---------------------+------------+You have selected the following JobIds: 10,11Building directory tree for JobId(s) 10,11 ... 2 files inserted into the tree.You are now entering file selection mode where you add (mark) andremove (unmark) files to be restored. No files are initially added, unlessyou used the "all" keyword on the command line.Enter "done" to leave this mode.cwd is: / ##到这里差不多还原已经成功了$ ls #查看还原目录test/$ cd test cwd is: /test/$ ls #查看需要还原的文件test1 test2$ cd ..cwd is: /$ mark test* ##还原test以及test目录下所有文件3 files marked.$ cd testcwd is: /test/$ ls*test1*test2$ done ####结束还原 Bootstrap records written to /usr/local/bacula/opt/bacula/working/zdy1.cluster.com-dir.restore.1.bsrThe job will require the following Volume(s) Storage(s) SD Device(s)=========================================================================== local File FileStorage Volumes marked with "*" are online.3 files selected to be restored.The defined Restore Job resources are: 1: RestorelocahostSelect Restore Job (1-3): 1 ###选择还原本机Run Restore jobJobName: RestorelocahostBootstrap: /usr/local/bacula/opt/bacula/working/zdy1.cluster.com-dir.restore.1.bsrWhere: /home/bacula-restoresReplace: alwaysFileSet: Full SetBackup Client: zdy1.cluster.com-fdRestore Client: zdy1.cluster.com-fdStorage: FileWhen: 2017-10-15 16:44:51Catalog: MyCatalogPriority: 10Plugin Options: *None*OK to run? (yes/mod/no): yesJob queued. JobId=12***wait**message15-Oct 16:42 zdy1.cluster.com-dir JobId 11: Start Backup JobId 11, Job=Backuplocalhost.2017-10-15_16.42.26_0515-Oct 16:42 zdy1.cluster.com-dir JobId 11: Using Device "FileStorage" to write.15-Oct 16:42 zdy1.cluster.com-sd JobId 11: Volume "local" previously written, moving to end of data.15-Oct 16:42 zdy1.cluster.com-sd JobId 11: Ready to append to end of Volume "local" size=287715-Oct 16:42 zdy1.cluster.com-sd JobId 11: Elapsed time=00:00:01, Transfer rate=255 Bytes/second15-Oct 16:42 zdy1.cluster.com-dir JobId 11: Bacula zdy1.cluster.com-dir 5.2.13 (19Jan13): Build OS: x86_64-unknown-linux-gnu redhat (Core) JobId: 11 Job: Backuplocalhost.2017-10-15_16.42.26_05 Backup Level: Incremental, since=2017-10-15 16:35:33 Client: "zdy1.cluster.com-fd" 5.2.13 (19Jan13) x86_64-unknown-linux-gnu,redhat,(Core) FileSet: "Full Set" 2017-10-15 13:21:03 Pool: "File" (From Job resource) Catalog: "MyCatalog" (From Client resource) Storage: "File" (From Job resource) Scheduled time: 15-Oct-2017 16:42:23 Start time: 15-Oct-2017 16:42:28 End time: 15-Oct-2017 16:42:28 Elapsed time: 0 secs Priority: 10 FD Files Written: 3 SD Files Written: 3 FD Bytes Written: 0 (0 B) SD Bytes Written: 255 (255 B) Rate: 0.0 KB/s Software Compression: None VSS: no Encryption: no Accurate: no Volume name(s): local Volume Session Id: 2 Volume Session Time: 1508056491 Last Volume Bytes: 3,620 (3.620 KB) Non-fatal FD errors: 0 SD Errors: 0 FD termination status: OK SD termination status: OK Termination: Backup OK15-Oct 16:42 zdy1.cluster.com-dir JobId 11: Begin pruning Jobs older than 2 months .15-Oct 16:42 zdy1.cluster.com-dir JobId 11: No Jobs found to prune.15-Oct 16:42 zdy1.cluster.com-dir JobId 11: Begin pruning Files.15-Oct 16:42 zdy1.cluster.com-dir JobId 11: No Files found to prune.15-Oct 16:42 zdy1.cluster.com-dir JobId 11: End auto prune.15-Oct 16:44 zdy1.cluster.com-dir JobId 12: Start Restore Job Restorelocahost.2017-10-15_16.44.53_0615-Oct 16:44 zdy1.cluster.com-dir JobId 12: Using Device "FileStorage" to read.15-Oct 16:44 zdy1.cluster.com-sd JobId 12: Ready to read from volume "local" on device "FileStorage" (/tmp).15-Oct 16:44 zdy1.cluster.com-sd JobId 12: Forward spacing Volume "local" to file:block 0:2877.15-Oct 16:44 zdy1.cluster.com-sd JobId 12: End of Volume at file 0 on device "FileStorage" (/tmp), Volume "local"15-Oct 16:44 zdy1.cluster.com-sd JobId 12: End of all volumes.15-Oct 16:44 zdy1.cluster.com-dir JobId 12: Bacula zdy1.cluster.com-dir 5.2.13 (19Jan13): Build OS: x86_64-unknown-linux-gnu redhat (Core) JobId: 12 Job: Restorelocahost.2017-10-15_16.44.53_06 Restore Client: zdy1.cluster.com-fd Start time: 15-Oct-2017 16:44:55 End time: 15-Oct-2017 16:44:55 Files Expected: 3 Files Restored: 3 Bytes Restored: 0 Rate: 0.0 KB/s FD Errors: 0 FD termination status: OK SD termination status: OK Termination: Restore OK15-Oct 16:44 zdy1.cluster.com-dir JobId 12: Begin pruning Jobs older than 2 months .15-Oct 16:44 zdy1.cluster.com-dir JobId 12: No Jobs found to prune.15-Oct 16:44 zdy1.cluster.com-dir JobId 12: Begin pruning Files.15-Oct 16:44 zdy1.cluster.com-dir JobId 12: No Files found to prune.15-Oct 16:44 zdy1.cluster.com-dir JobId 12: End auto prune.*
还原成功,本机的/home/bacula-restores下有还原的文件
2、测试备份以及还原远程客户端的文件:
首先,我们在服务器的bacula-dir.conf文件的最后面加入以下脚本:
@|"sh -c 'for f in /usr/local/bacula/etc/conf.d/*.conf ; do echo @${f} ; done'"
以上脚本的作用是将自定义的客户端备份还原任务写到另外一个文件中,有利于阅读以及方便管理
然后在/usr/local/bacula/etc/下创建conf.d文件,在conf.d目录里创建备份以及还原任务:
[root@zdy1 etc]# cd conf.d/
[root@zdy1 conf.d]# ls
client172.conf
定义客户端的备份以及还原任务:
在client172.conf文文件中
Pool { #自定义存储条件 Name = zdy2 Pool Type = Backup Recycle = yes AutoPrune = yes Volume Retention = 30 days Maximum Volume Bytes = 50 G Maximum Volumes = 100 Maximum Volume Jobs = 1 Label Format = "${Job}-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}"}Client { #定义进行备份以及还原操作的远程客户端 Name = zdy2.cluster.com-fd Address = 172.16.13.172 FDPort = 9102 Catalog = MyCatalog Password = "cerU/APZwPP2zVSfrZuU+Y4osaZH5xrdEIwrpkCXqUMW" #此密码与客户端的bacula-fd.conf中的第一个director中密码相同 File Retention = 30 days Job Retention = 2 months AutoPrune = yes}Job { #定义备份任务 Name = zdy2-backup Type = Backup Level = Incremental Client = zdy2.cluster.com-fd FileSet = "Full Set" Schedule = WeeklyCycle Storage = File Messages = Standard Pool = zdy2 SpoolAttributes = yes Priority = 10 Write Bootstrap = /opt/bacula/working/%c.bsr}Job { #定义还原任务 Name = zdy2-restore Type = Restore Client = zdy2.cluster.com-fd FileSet = "Full Set" Storage = File Pool = zdy2 Messages = Standard Where = /home/bacula-restores #定义还原到客户端的哪个目录(默认是这个,可以自己定义)}
接下来修改远程客户端zdy2的bacula-fd.conf文件:
#Director { Name = zdy1.cluster.com-dir Password = "cerU/APZwPP2zVSfrZuU+Y4osaZH5xrdEIwrpkCXqUMW" #此密码和在服务器中(client172.conf)定义的客户端密码相同}Director { Name = zdy1.cluster.com-mon Password = "qYhhy5PNCZTgW/nzE1JYiPRr+fBmUYR93uqLIyFNCDR1" #服务器zdy1中dir.conf中的第一个director密码 Monitor = yes}FileDaemon { # this is me Name = zdy2.cluster.com-fd FDport = 9102 # where we listen for the director WorkingDirectory = /usr/local/bacula/opt/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20}
在客户端zdy2中创建文件:
[root@zdy2 test]# ls
test1 test2
修改完成后,重启服务器端和客户端的bacula
在服务器端进行备份操作:
# bconsole Connecting to Director zdy1:91011000 OK: zdy1.cluster.com-dir Version: 5.2.13 (19 February 2013)Enter a period to cancel a command.*runAutomatically selected Catalog: MyCatalogUsing Catalog "MyCatalog"A job name must be specified.The defined Job resources are: 1: Backuplocalhost 2: Restorelocahost 3: BackupCatalog 4: zdy2-backup 5: zdy2-restoreSelect Job resource (1-5): 4 #选择备份客户端zdy2Run Backup jobJobName: zdy2-backupLevel: IncrementalClient: zdy2.cluster.com-fdFileSet: Full SetPool: zdy2 (From Job resource)Storage: File (From Job resource)When: 2017-10-15 17:06:18Priority: 10OK to run? (yes/mod/no): yesJob queued. JobId=13**wait #############You have messages.**messages ####查看信息15-Oct 17:06 zdy1.cluster.com-dir JobId 13: Start Backup JobId 13, Job=zdy2-backup.2017-10-15_17.06.20_0315-Oct 17:06 zdy1.cluster.com-dir JobId 13: Created new Volume "zdy2-backup-2017-10-15-id13" in catalog.15-Oct 17:06 zdy1.cluster.com-dir JobId 13: Using Device "FileStorage" to write.15-Oct 17:06 zdy1.cluster.com-sd JobId 13: Labeled new Volume "zdy2-backup-2017-10-15-id13" on device "FileStorage" (/tmp).15-Oct 17:06 zdy1.cluster.com-sd JobId 13: Wrote label to prelabeled Volume "zdy2-backup-2017-10-15-id13" on device "FileStorage" (/tmp)15-Oct 17:06 zdy1.cluster.com-dir JobId 13: Max Volume jobs=1 exceeded. Marking Volume "zdy2-backup-2017-10-15-id13" as Used.15-Oct 17:06 zdy1.cluster.com-sd JobId 13: Elapsed time=00:00:01, Transfer rate=255 Bytes/second15-Oct 17:06 zdy1.cluster.com-sd JobId 13: Sending spooled attrs to the Director. Despooling 680 bytes ...15-Oct 17:06 zdy1.cluster.com-dir JobId 13: Bacula zdy1.cluster.com-dir 5.2.13 (19Jan13): Build OS: x86_64-unknown-linux-gnu redhat (Core) JobId: 13 Job: zdy2-backup.2017-10-15_17.06.20_03 Backup Level: Incremental, since=2017-10-15 14:24:22 Client: "zdy2.cluster.com-fd" 5.2.13 (19Jan13) x86_64-unknown-linux-gnu,redhat,(Core) FileSet: "Full Set" 2017-10-15 13:21:03 Pool: "zdy2" (From Job resource) Catalog: "MyCatalog" (From Client resource) Storage: "File" (From Job resource) Scheduled time: 15-Oct-2017 17:06:18 Start time: 15-Oct-2017 17:06:23 End time: 15-Oct-2017 17:06:23 Elapsed time: 0 secs Priority: 10 FD Files Written: 3 SD Files Written: 3 FD Bytes Written: 0 (0 B) SD Bytes Written: 255 (255 B) Rate: 0.0 KB/s Software Compression: None VSS: no Encryption: no Accurate: no Volume name(s): zdy2-backup-2017-10-15-id13 Volume Session Id: 1 Volume Session Time: 1508058353 Last Volume Bytes: 959 (959 B) Non-fatal FD errors: 0 SD Errors: 0 FD termination status: OK SD termination status: OK Termination: Backup OK15-Oct 17:06 zdy1.cluster.com-dir JobId 13: Begin pruning Jobs older than 2 months .15-Oct 17:06 zdy1.cluster.com-dir JobId 13: No Jobs found to prune.15-Oct 17:06 zdy1.cluster.com-dir JobId 13: Begin pruning Files.15-Oct 17:06 zdy1.cluster.com-dir JobId 13: No Files found to prune.15-Oct 17:06 zdy1.cluster.com-dir JobId 13: End auto prune.*
备份成功
删除/test中的文件,
[root@zdy2 test]# ls
test1 test2
[root@zdy2 test]# rm ./* -rf
[root@zdy2 test]# ls
[root@zdy2 test]#
还原:在服务器端zdy1操作
*restoreFirst you select one or more JobIds that contain filesto be restored. You will be presented several methodsof specifying the JobIds. Then you will be allowed toselect 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: CancelSelect item: (1-13): 5 #########选择还原最近备份文件Defined Clients: 1: zdy1.cluster.com-fd 2: zdy2.cluster.com-fdSelect the Client (1-2): 2 ##选择相应的客户端Automatically selected FileSet: Full Set+-------+-------+----------+----------+---------------------+-----------------------------+| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |+-------+-------+----------+----------+---------------------+-----------------------------+| 6 | F | 5 | 0 | 2017-10-15 14:24:22 | zdy2-backup-2017-10-15-id6 || 13 | I | 3 | 0 | 2017-10-15 17:06:23 | zdy2-backup-2017-10-15-id13 |+-------+-------+----------+----------+---------------------+-----------------------------+You have selected the following JobIds: 6,13Building directory tree for JobId(s) 6,13 ... 6 files inserted into the tree.You are now entering file selection mode where you add (mark) andremove (unmark) files to be restored. No files are initially added, unlessyou used the "all" keyword on the command line.Enter "done" to leave this mode.cwd is: / $ ls #进入到还原目录中test/$ cd testcwd is: /test/$ ls #查看需要还原的文件test1test2$ cd ..cwd is: /$ mark test* #还原目录以及目录下的所有文件3 files marked.$ cd testcwd is: /test/$ ls*test1*test2 #*号代表还原成功$ done #结束Bootstrap records written to /usr/local/bacula/opt/bacula/working/zdy1.cluster.com-dir.restore.1.bsrThe job will require the following Volume(s) Storage(s) SD Device(s)=========================================================================== zdy2-backup-2017-10-15-id6 File FileStorage zdy2-backup-2017-10-15-id13 File FileStorage Volumes marked with "*" are online.7 files selected to be restored.The defined Restore Job resources are: 1: Restorelocahost 2: zdy2-restoreSelect Restore Job (1-2): 2 ####选择相应的客户端Run Restore jobJobName: zdy2-restoreBootstrap: /usr/local/bacula/opt/bacula/working/zdy1.cluster.com-dir.restore.1.bsrWhere: /home/bacula-restoresReplace: alwaysFileSet: Full SetBackup Client: zdy2.cluster.com-fdRestore Client: zdy2.cluster.com-fdStorage: FileWhen: 2017-10-15 17:11:45Catalog: MyCatalogPriority: 10Plugin Options: *None*OK to run? (yes/mod/no): yesJob queued. JobId=14**waitYou have messages.**messages ####查看还原状态以及信息15-Oct 17:11 zdy1.cluster.com-dir JobId 14: Start Restore Job zdy2-restore.2017-10-15_17.11.46_0415-Oct 17:11 zdy1.cluster.com-dir JobId 14: Using Device "FileStorage" to read.15-Oct 17:11 zdy1.cluster.com-sd JobId 14: Ready to read from volume "zdy2-backup-2017-10-15-id6" on device "FileStorage" (/tmp).15-Oct 17:11 zdy1.cluster.com-sd JobId 14: Forward spacing Volume "zdy2-backup-2017-10-15-id6" to file:block 0:231.15-Oct 17:11 zdy1.cluster.com-sd JobId 14: End of Volume at file 0 on device "FileStorage" (/tmp), Volume "zdy2-backup-2017-10-15-id6"15-Oct 17:11 zdy1.cluster.com-sd JobId 14: Ready to read from volume "zdy2-backup-2017-10-15-id13" on device "FileStorage" (/tmp).15-Oct 17:11 zdy1.cluster.com-sd JobId 14: Forward spacing Volume "zdy2-backup-2017-10-15-id13" to file:block 0:232.15-Oct 17:11 zdy1.cluster.com-sd JobId 14: End of Volume at file 0 on device "FileStorage" (/tmp), Volume "zdy2-backup-2017-10-15-id13"15-Oct 17:11 zdy1.cluster.com-sd JobId 14: End of all volumes.15-Oct 17:11 zdy1.cluster.com-dir JobId 14: Bacula zdy1.cluster.com-dir 5.2.13 (19Jan13): Build OS: x86_64-unknown-linux-gnu redhat (Core) JobId: 14 Job: zdy2-restore.2017-10-15_17.11.46_04 Restore Client: zdy2.cluster.com-fd Start time: 15-Oct-2017 17:11:48 End time: 15-Oct-2017 17:11:49 Files Expected: 7 Files Restored: 7 Bytes Restored: 0 Rate: 0.0 KB/s FD Errors: 0 FD termination status: OK SD termination status: OK Termination: Restore OK15-Oct 17:11 zdy1.cluster.com-dir JobId 14: Begin pruning Jobs older than 2 months .15-Oct 17:11 zdy1.cluster.com-dir JobId 14: No Jobs found to prune.15-Oct 17:11 zdy1.cluster.com-dir JobId 14: Begin pruning Files.15-Oct 17:11 zdy1.cluster.com-dir JobId 14: No Files found to prune.15-Oct 17:11 zdy1.cluster.com-dir JobId 14: End auto prune.*
客户端上验证:
[root@zdy2 test]# cd /home/
[root@zdy2 home]# ls
bacula-restores
[root@zdy2 home]# cd bacula-restores/
[root@zdy2 bacula-restores]# cd test/
[root@zdy2 test]# ls
test1 test2
还原成功!!
- bacula-5-2-13的安装以及基本的备份还原配置成功案例
- bacula备份工具的编译安装+配置+测试
- 使用bacula实现Linux的远程备份和还原
- mongodb的备份还原案例
- Bacula服务端的安装
- SQL的备份以及还原
- bacula源码安装配置
- bacula服务器备份系统安装
- 数据库表备份以及还原的操作
- 开源网络备份软件bacula(安装bacula)
- RabbitMQ配置的备份与还原
- Bacula的web界面,bacula-web,bacula-gui
- Git的基本介绍安装以及配置
- bacula 的使用
- MySQL的备份还原
- 还原备份的数据库
- xtrabackup的备份还原
- FastDFS 5.05的安装成功案例
- SQL Server基础(一)
- 介绍一部经典的IT电影《黑客帝国》
- JavaScript闭包最简洁实用讲解
- Ajaxa经典面试题
- OpenCV 安装必看
- bacula-5-2-13的安装以及基本的备份还原配置成功案例
- promise实现原理的源码分析
- hadoop权威指南上 天气例子测试运行
- CentOS6.9编译安装LAMP
- php 图片的水印效果
- 2017/10/15编辑器测试
- 1007. 素数对猜想 (20)
- 1071. 小赌怡情(15)
- 一言不合,就抓个数据,统计看看