开源备份软件bacula安装记录--含备份-恢复演练
公司原来的备份机器用的是oracle-linux 5.7 运行的不是很稳定,经常出现死机,新装了一个centos6.5, 准备使用bacula来对数据进行备份,在这里记录一下安装过错,备忘.操作系统:centos6.51、安装mysql用yum安装yum install mysql mysql-server mysql-devel这里要注意的是一定要安装mysq
公司原来的备份机器用的是oracle-linux 5.7 运行的不是很稳定,经常出现死机,新装了一个centos6.5, 准备使用bacula来对数据进行备份,在这里记录一下安装过错,备忘.
操作系统:centos6.5
1、安装mysql
用yum安装
yum install mysql mysql-server mysql-devel
这里要注意的是一定要安装mysql-devel,否则在等下configure bacula的时候会报找不到mysql.h文件--这里折腾了我好久,差点想去编译安装mysql
2、安装bacula-server端
解压
./configure --prefix=/opt/bacula --with-mysql #这里只要指定mysql就可以,不需要指定路径,因为bacula会去默认的路径去找mysql
make
make install
3、初始化数据库
初始化的时候要保证mysql的root密码为空。。。。
进入bacula/etc 目录,执行以下命令
./grant_mysql_privileges
./create_mysql_database
./make_mysql_tables
4、配置bacula Director端\SD端
这里需要配置一个job 一个fileset 一个client 其他用默认的配置即可满足一般要求
下面贴一下我的配置
Job{ #job的作用是定义一个备份任务,一些参数像差异备份啦 备份周期啦 日志啦等等
Name="7.17"
Type = Backup
Level = Incremental
Client = 7.17
FileSet = "7.17"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/opt/bacula/var/bacula/working/%c.bsr"
}
FileSet { #在fileset里面定义客户端要备份的文件或者目录
Name = "7.17"
Include {
Options {
signature = MD5
}
File = "/opt/jdk"
}
Client { #定义客户端的一些参数,比如ip 端口 等
Name = 7.17
Address = 192.168.7.17
FDPort = 9102
Catalog = MyCatalog
Password = "24H/a2pSWjFxWituyFuB8LpParvcDKgEMywQlxEgxxxx2" # password for FileDaemon
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
SD端使用默认配置即可
5、配置FD端--备份客户端
直接上配置,要点就是director的名字和密码要和dir的配置对上!
Director {
Name = Bacula200-dir
Password = "24H/a2pSWjFxWituyFuB8LpParvcDKgEMywQlxEgRldd2"
}
#
# Restricted Director, used by tray-monitor to get the
# status of the file daemon
#
Director {
Name = Bacula200-mon
Password="24H/a2pSWjFxWituyFuB8LpParvcDKgEMywQlxEgRldd2"
Monitor = yes
}
#
# "Global" File daemon configuration specifications
#
FileDaemon { # this is me
Name = centos-003-fd
FDport = 9102 # where we listen for the director
WorkingDirectory = /opt/bacula/var/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
# Send all messages except skipped files back to Director
Messages {
Name = Standard
director = centos-003-dir = all, !skipped, !restored
}
6、开始备份、恢复过程
备份首先要创建卷组
在环境变量里面加上 bacula的sbin路径
PATH=$PATH:$HOME/bin:/opt/bacula/sbin
然后使用bconsole进入控制台
然后就可以通过命令控制备份程序了
首先通过label欻关键卷组
然后使用run命令开始操作
备份
*run #开始任务使用run选择刚才创建的任务
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
1: BackupClient1
2: xxxxxx
3: xxxxxx
4: BackupCatalog
5: RestoreFiles
Select Job resource (1-5): 1
Run Backup job
JobName: BackupClient1
Level: Incremental
Client: Bacula200-fd
FileSet: Full Set
Pool: File (From Job resource)
Storage: File (From Job resource)
When: 2014-07-07 22:32:21
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=1
You have messages.
*s #使用s查看director来查看任务执行情况
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 1
Bacula200-dir Version: 5.2.6 (21 February 2012) x86_64-unknown-linux-gnu redhat
Daemon started 07-Jul-14 22:22. Jobs: run=1, running=0 mode=0,0
Heap: heap=274,432 smbytes=81,718 max_bytes=95,201 bufs=292 max_bufs=330
Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 07-Jul-14 23:05 BackupClient1 20140708
Incremental Backup 10 07-Jul-14 23:05 xxxxx 20140708
Incremental Backup 10 07-Jul-14 23:05 xxxxx 20140708
Full Backup 11 07-Jul-14 23:10 BackupCatalog 20140708
====
Running Jobs:
Console connected at 07-Jul-14 22:30
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
1 Full 16 10.98 M OK 07-Jul-14 22:32 BackupClient1
#任务完成后,如果你登陆控制台,他会给你发下面备份成功的消息,如果失败也会发消息告诉你原因
Build OS: x86_64-unknown-linux-gnu redhat
JobId: 1
Job: BackupClient1.2014-07-07_22.32.27_03
Backup Level: Full (upgraded from Incremental)
Client: "Bacula200-fd" 5.2.6 (21Feb12) x86_64-unknown-linux-gnu,redhat,
FileSet: "Full Set" 2014-07-07 22:32:27
Pool: "File" (From Job resource)
Catalog: "MyCatalog" (From Client resource)
Storage: "File" (From Job resource)
Scheduled time: 07-Jul-2014 22:32:21
Start time: 07-Jul-2014 22:32:29
End time: 07-Jul-2014 22:32:30
Elapsed time: 1 sec
Priority: 10
FD Files Written: 16
SD Files Written: 16
FD Bytes Written: 10,988,458 (10.98 MB)
SD Bytes Written: 10,990,169 (10.99 MB)
Rate: 10988.5 KB/s
Software Compression: None
VSS: no
Encryption: no
Accurate: no
Volume name(s): 20140708
Volume Session Id: 1
Volume Session Time: 1404786153
Last Volume Bytes: 10,999,377 (10.99 MB)
Non-fatal FD errors: 0
SD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Backup OK
恢复
*run #还是使用run开始
A job name must be specified.
The defined Job resources are:
1: BackupClient1
2: xmygc
3: xm214
4: BackupCatalog
5: RestoreFiles
Select Job resource (1-5): 5
Please enter a JobId for restore: 1 #jobid 可以通过s- dirctory 来查看
Run Restore job
JobName: RestoreFiles
Bootstrap: *None*
Where: /tmp/bacula-restores
Replace: always
Client: Bacula200-fd
Storage: File
JobId: 1
When: 2014-07-08 11:00:35
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): mod #可以选择修改恢复的一些参数,这里选择更改恢复目的地
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Restore Client
6: When
7: Priority
8: Bootstrap
9: Where
10: File Relocation
11: Replace
12: JobId
13: Plugin Options
Select parameter to modify (1-13): 9
Please enter path prefix for restore (/ for none): /root/test
Run Restore job
JobName: RestoreFiles
Bootstrap: *None*
Where: /root/test
Replace: always
Client: Bacula200-fd
Storage: File
JobId: 1
When: 2014-07-08 11:00:35
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=2
#报告恢复完成
08-Jul 11:11 Bacula200-dir JobId 4: Start Restore Job RestoreFiles.2014-07-08_11.10.59_11
08-Jul 11:11 Bacula200-dir JobId 4: Using Device "FileStorage"
08-Jul 11:11 Bacula200-sd JobId 4: Ready to read from volume "20140708" on device "FileStorage" (/home/bak).
08-Jul 11:11 Bacula200-sd JobId 4: Forward spacing Volume "20140708" to file:block 0:198.
08-Jul 11:11 Bacula200-sd JobId 4: End of Volume at file 0 on device "FileStorage" (/home/bak), Volume "20140708"
08-Jul 11:11 Bacula200-sd JobId 4: End of all volumes.
08-Jul 11:11 Bacula200-dir JobId 4: Bacula Bacula200-dir 5.2.6 (21Feb12):
Build OS: x86_64-unknown-linux-gnu redhat
JobId: 4
Job: RestoreFiles.2014-07-08_11.10.59_11
Restore Client: Bacula200-fd
Start time: 08-Jul-2014 11:11:01
End time: 08-Jul-2014 11:11:01
Files Expected: 0
Files Restored: 16
Bytes Restored: 10,988,458
Rate: 0.0 KB/s
FD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Restore OK
更多推荐
所有评论(0)