原文地址:http://www.linuxde.net/2012/04/9734.html
1.创建卷组
执行如下命令,连接到bacula控制端,执行备份恢复操作:
- [root@baculaserver opt]#/opt/bacula/sbin/bconsole
- Connecting to Director 192.168.12.188:9101
- 1000 OK: f10-64-build-dir Version: 3.0.2 (18 July 2009)
- Enter a period to cancel a command
- *label
- Automatically selected Storage: dbsd
- Enter new Volume name: cicro4 #卷组名称,可随意指定,指定完毕后会在
- #bacula-dir.conf文件的指定位置生成一个cicro4文件
- Defined Pools:
- 1: dbpool
- 2: Scratch
- Select the Pool (1-2): 1 #指定卷组的放置位置,即为SD名称。
- #Dbpool在bacula-dir.conf中定义
- Connecting to Storage daemon dbsd at 192.168.12.188:9103 ... #由于指定SD在
- #192.168.12.188主机上,因此将卷cicro4创建到了此主机上
- Sending label command for Volume "cicro4" Slot 0 ...
- 3000 OK label. VolBytes=191 DVD=0 Volume="cicro4" Device="dbdev" (/cicro/backup2)
- Catalog record for Volume "cicro4", Slot 0 successfully created.
- Requesting to mount dbdev ...
- 3906 File device "dbdev" (/cicro/backup2) is always mounted.
2.利用run命令执行备份操作
下面继续在bacula控制端执行备份操作:
- *run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1 #这里的Client1 是在bacula-dir.conf中定义的一个Job执行任务
- 2: Client #这里的Client 也是在bacula-dir.conf中定义的一个Job执行任务
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-2): 1
- Run Backup job
- JobName: Client1
- Level: Incremental
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 13:40:13
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=67
到此为止,可以开始执行备份,在bacula-dir.conf文件中定义的Client1是一个增量备份,因此这个备份只是个增量操作。由于这是第一个备份,因此默认Client1会做一个完全备,第二次备份时,才执行增量备份。
3.查看备份状态
在bacula控制端利用“status”可以查看bacula的各种状态,这里查看备份时Director端的一个状态信息。
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 13:22, 0 Jobs run since started.
- Heap: heap=241,664 smbytes=82,242 max_bytes=82,498 bufs=245 max_bufs=250
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===============================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Running Jobs:
- Console connected at 21-Aug-09 13:37
- JobId Level Name Status
- ======================================================================
- 67 Full Client1.2009-08-21_13.40.16_07 is running
由此可知,备份正在进行,备份完成再次查看备份信息,输出如下:
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
由于这里bacula将备份的存储端(SD)和控制端(DIR)设置在一台服务器上,因此可以通过选项1“Director”来查看SD的状态,如果SD端和DIR端不在一台服务器上,要查看选项2,即“Storage”。这里选择选项1r后输出内容如下:
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 13:22, 1 Job run since started.
- Heap: heap=241,664 smbytes=73,891 max_bytes=84,825 bufs=212 max_bufs=250
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===============================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Running Jobs:
- Console connected at 21-Aug-09 13:42
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 58 Incr 2 46.85 M OK 19-Aug-09 16:51 Client1
- 59 Incr 2 3.908 M OK 19-Aug-09 16:51 Client1
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
这里可以看到,JobId为67的备份是一个完全备份,备份数据的文件数为25个,备份压缩后的大小为145.5MB,备份完成在“21-Aug-09 13:41”,最后的Client1是备份资源的名称。
在上面的操作中,设定的备份资源Job本身就是一个增量备份,下面执行的备份操作与上面完全相同,不同的是,这里是第二次备份,bacula会按照设定执行增量备份,操作如下代码清单如下所示。 执行增量备份
- * run
- Automatically selected Catalog: MyCatalog
- Using Catalog "MyCatalog"
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-2): 1
- Run Backup job
- JobName: Client1
- Level: Incremental
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:20:24
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=68
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 13:22, 2 Jobs run since started.
- Heap: heap=241,664 smbytes=84,576 max_bytes=97,749 bufs=218 max_bufs=252
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===============================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:19
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 59 Incr 2 3.908 M OK 19-Aug-09 16:51 Client1
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
从最后的备份列表可以看出,系统进行了增量备份,“3.908 M”就是上次备份与这次备份之间的数据增加量。而JobId =68这个备份的Level级别为Incr也说明了此次备份为增量备份。
差异备份与增量备份的原理,前面已经介绍过了,这里只给出具体的操作步骤。
1.开始执行备份
- *run
- Automatically selected Catalog: MyCatalog
- Using Catalog "MyCatalog"
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2 #这里有两个Job任务可选,名为Client1的为增量
- #备份操作,名为Client的为差异备份操作
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:31:04
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=69
- You have messages.
至此,开始执行差异备份,如果备份的数据量较大,可能需要一段时间才能完成备份。下面可以用“status”指令查看备份的状态。
2.查看备份状态
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 0 Jobs run since started.
- Heap: heap=253,952 smbytes=67,810 max_bytes=68,066 bufs=267 max_bufs=272
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- JobId Level Name Status
- ======================================================================
- 69 Full Client.2009-08-21_14.31.10_03 is running
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 59 Incr 2 3.908 M OK 19-Aug-09 16:51 Client1
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
从上面可以看到,备份还没有完成,备份状态为running。等待几分钟,再次查看备份状态如下:
- * status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 1 Job run since started.
- Heap: heap=253,952 smbytes=65,680 max_bytes=78,853 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ==========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
从这里可以看到,JobId为69的备份已经完成,并且是一个完全备份,备份文件大小为149.4MB,而完成此差异备份的Job任务名称是Client。
3.继续执行备份操作
在执行下面的操作前,首先在客户端FD需要备份的文件夹下(根据前面的配置可知,应该是/cws3)增加一个大小为3.8MB左右的文件。
- * run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:34:25
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=70
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 2 Jobs run since started.
- Heap: heap=253,952 smbytes=67,989 max_bytes=81,162 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 70 Diff 2 3.908 M OK 21-Aug-09 14:34 Client
从JobId为70的备份信息可以看出,此备份为差异增量备份,此次进行差异备份的数据量大小刚好为3.908 MB,与前面增加的文件大小基本相同。 为了证明是前面执行的是差异增量备份,在FD端需要备份的文件夹下再次增加一个大小为3.8MB左右的一个文件,继续执行以下备份操作:
- *run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:34:59
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=71
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 3 Jobs run since started.
- Heap: heap=253,952 smbytes=69,087 max_bytes=82,260 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 70 Diff 2 3.908 M OK 21-Aug-09 14:34 Client
- 71 Diff 3 7.817 M OK 21-Aug-09 14:35 Client
由JobId为71的备份可以看出,此次备份的大小为7.817 M,刚好是上次差异增量备份的大小与此次增加文件的大小之和,由此证明确实为差异备份。 第三次在FD端需要备份的文件夹下增加一个大小为3.8M左右的一个文件,继续执行备份操作:
- *run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:35:32
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=72
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 4 Jobs run since started.
- Heap: heap=253,952 smbytes=69,087 max_bytes=82,260 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 70 Diff 2 3.908 M OK 21-Aug-09 14:34 Client
- 71 Diff 3 7.817 M OK 21-Aug-09 14:35 Client
- 72 Diff 4 11.72 M OK 21-Aug-09 14:35 Client
第三次执行备份,从JobId为72的备份可以很清楚地看出差异备份与增量备份的差别。