备份:
console端
[root@JD ~]# /usr/local/bacula/sbin/bconsoleConnecting to Director XXXXXX:91011000 OK: JD-dir Version: 5.2.13 (19 February 2013)Enter a period to cancel a command.*label##使用label创建卷组Automatically selected Catalog: MyCatalogUsing Catalog "MyCatalog"Automatically selected Storage: FileEnter new Volume name: kk##输入卷组名称,可随意Defined Pools:1: Default2: File3: ScratchSelect the Pool (1-3): 1##使用默认池Connecting to Storage daemon File at XXXXXXXX:9103 ...Sending label command for Volume "allback" Slot 0 ...3000 OK label. VolBytes=187 DVD=0 Volume="allback" Device="FileStorage" (/tmp)Catalog record for Volume "kk", Slot 0 successfully created.Requesting to mount FileStorage ...3906 File device ""FileStorage" (/tmp)" is always mounted.*run##使用run命令直接执行任务A job name must be specified.The defined Job resources are:1: BackupClient12: BackupCatalog3: RestoreFilesSelect Job resource (1-3): 1##选择定义好的备份任务,笔者这为增量备份,但是由于是第一次备份,所以会先完全备份,第二次才执行增量备份。Run Backup jobJobName: BackupClient1Level: IncrementalClient: xad-fdFileSet: Full SetPool: File (From Job resource)Storage: File (From Job resource)When: 2017-09-22 10:52:45Priority: 10OK to run? (yes/mod/no): yes##选择mod可以临时修改任务策略Job queued. JobId=17##桉顺序自动分配任务序列号*You have messages.22-Sep 10:55 JD-dir JobId 17: Start Backup JobId 17, Job=BackupClient1.2017-09-22_10.55.05_1922-Sep 10:55 JD-dir JobId 17: Using Device "FileStorage" to write.22-Sep 10:55 JD-sd JobId 17: Volume "kk" previously written, moving to end of data.22-Sep 10:55 JD-sd JobId 17: Ready to append to end of Volume "kk" size=3312462735*status##查看Director端状态Status available for:1: Director2: Storage3: Client4: AllSelect daemon type for status (1-4): 1JD-dir Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat (Core)Daemon started 20-Sep-17 17:15. Jobs: run=8, running=1 mode=0,0Heap: heap=270,336 smbytes=159,805 max_bytes=194,200 bufs=333 max_bufs=519Scheduled Jobs:Level Type Pri Scheduled Name Volume===================================================================================Incremental Backup 10 22-Sep-17 23:05 BackupClient1 kkFull Backup 11 22-Sep-17 23:10 BackupCatalog kk====Running Jobs:Console connected at 22-Sep-17 10:40JobId Level Name Status======================================================================17 Increme BackupClient1.2017-09-22_10.55.05_19 is running##任务正在执行====*status##查看SD状态Status available for:1: Director2: Storage3: Client4: AllSelect daemon type for status (1-4): 2Automatically selected Storage: FileConnecting to Storage daemon File at XXXXXXXX:9103JD-sd Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat (Core)Daemon started 20-Sep-17 17:15. Jobs: run=7, running=0.Heap: heap=135,168 smbytes=245,754 max_bytes=310,350 bufs=117 max_bufs=121Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0Running Jobs:Writing: Incremental Backup job BackupClient1 JobId=17 Volume="kk"pool="File" device="FileStorage" (/tmp)spooling=0 despooling=0 despool_wait=0 Files=2 Bytes=84,098,420 AveBytes/sec=134,387 LastBytes/sec=133,736 ##备份速率,这里慢是因为网络不好才1M网络。。。FDReadSeqNo=1,303 in_msg=1298 out_msg=5 fd=5====.............====Device status:Device "FileStorage" (/tmp) is mounted with:Volume: kkPool: FileMedia type: File Total Bytes=3,396,586,383 Blocks=52,654 Bytes/block=64,507##当前的卷组大小状态Positioned at File=0 Block=3,396,586,382======Used Volume status:kk on device "FileStorage" (/tmp)Reader=0 writers=1 reserves=0 volinuse=1====*statusStatus available for:1: Director2: Storage3: Client4: AllSelect daemon type for status (1-4): 3Automatically selected Client: xad-fdConnecting to Client xad-fd at XXXXXXXXXX:9102xad-fd Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat (Core)Daemon started 20-Sep-17 16:53. Jobs: run=8 running=0.Heap: heap=36,864 smbytes=189,255 max_bytes=212,649 bufs=125 max_bufs=150Sizeof: boffset_t=8 size_t=8 debug=0 trace=0Running Jobs:JobId 17 Job BackupClient1.2017-09-22_10.55.05_19 is running.Incremental Backup Job started: 22-Sep-17 10:55Files=3 Bytes=109,869,316 Bytes/sec=134,808 Errors=0Files Examined=1,731Processing file: /usr/local/src/bacula-bat-5.0.1-2.src.rpm5##当前正在备份的数据文件SDReadSeqNo=5 fd=5Director connected at: 22-Sep-17 11:08====测试的时候可以创建较小的文件来测试,不然就看SD和FD的传输速率咋滴。。。完成后在使用status查看Director可以看到.........Terminated Jobs: JobId Level Files Bytes Status Finished Name =================================================================15 Full 19,486 823.9 M OK 22-Sep-17 04:35 BackupClient117 Incr 16 422.7 M OK 22-Sep-17 11:47 BackupClient1You have messages.*22-Sep 11:47 JD-sd JobId 17: Elapsed time=00:52:26, Transfer rate=134.3 K Bytes/second22-Sep 11:47 JD-dir JobId 17: Bacula JD-dir 5.2.13 (19Jan13):Build OS: x86_64-unknown-linux-gnu redhat (Core)JobId: 17Job: BackupClient1.2017-09-22_10.55.05_19Backup Level: Incremental, since=2017-09-22 02:53:05Client: "xad-fd" 5.2.13 (19Jan13) x86_64-unknown-linux-gnu,redhat,(Core)FileSet: "Full Set" 2017-09-20 16:37:24Pool: "File" (From Job resource)Catalog: "MyCatalog" (From Client resource)Storage: "File" (From Job resource)Scheduled time: 22-Sep-2017 10:52:45Start time: 22-Sep-2017 10:55:08End time: 22-Sep-2017 11:47:34Elapsed time: 52 mins 26 secsPriority: 10FD Files Written: 16SD Files Written: 16FD Bytes Written: 422,734,243 (422.7 MB)SD Bytes Written: 422,736,198 (422.7 MB)Rate: 134.4 KB/sSoftware Compression: NoneVSS: noEncryption: noAccurate: noVolume name(s): kkVolume Session Id: 8Volume Session Time: 1505898937Last Volume Bytes: 3,735,513,271 (3.735 GB)Non-fatal FD errors: 0SD Errors: 0FD termination status: OKSD termination status: OKTermination: Backup OK
还原
去客户端删除一些数据:[root@Aliyun src]# ll | grep bacula-bat-5.0.1-2.src.rpm8-rw-r--r-- 1 root root 51002498 Sep 22 10:54 bacula-bat-5.0.1-2.src.rpm8[root@Aliyun src]# rm -rf bacula-bat-5.0.1-2.src.rpm8##已经备份,为测试还原就删除一个数据包。
去Director端创建还原任务:[root@JD ~]# /usr/local/bacula/sbin/bconsole*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 run2: List Jobs where a given File is saved3: Enter list of comma separated JobIds to select4: Enter SQL list command5: Select the most recent backup for a client6: Select backup for a client before a specified time7: Enter a list of files to restore8: Enter a list of files to restore before a specified time9: Find the JobIds of the most recent backup for a client10: Find the JobIds for a backup for a client before a specified time11: Enter a list of directories to restore for found JobIds12: Select full restore to a specified Job date13: CancelSelect item: (1-13): 1##选择1查看最近20个任务+-------+--------+---------------------+----------+----------+-------------+| JobId | Client | StartTime | JobLevel | JobFiles | JobBytes |+-------+--------+---------------------+----------+----------+-------------+| 17 | xad-fd | 2017-09-22 10:55:08 | I | 16 | 422734243 || 16 | xad-fd | 2017-09-22 04:35:51 | F | 0 | 0 || 14 | xad-fd | 2017-09-22 04:35:48 | F | 0 | 0 || 15 | xad-fd | 2017-09-22 02:53:05 | F | 19486 | 823900553 || 13 | xad-fd | 2017-09-22 01:10:19 | F | 19486 | 823900553 |+-------+--------+---------------------+----------+----------+-------------+To select the JobIds, you have the following choices:1: List last 20 Jobs run2: List Jobs where a given File is saved3: Enter list of comma separated JobIds to select4: Enter SQL list command5: Select the most recent backup for a client6: Select backup for a client before a specified time7: Enter a list of files to restore8: Enter a list of files to restore before a specified time9: Find the JobIds of the most recent backup for a client10: Find the JobIds for a backup for a client before a specified time11: Enter a list of directories to restore for found JobIds12: Select full restore to a specified Job date13: CancelSelect item: (1-13): 3Enter JobId(s), comma separated, to restore: 17You have selected the following JobId: 17Building directory tree for JobId(s) 17 ...15 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: /$ helpCommand Description======= ===========add add dir/file to be restored recursively, wildcards allowedcd change current directorycount count marked files in and below the cddelete delete dir/file to be restored recursively in dirdir long list current directory, wildcards alloweddone leave file selection modeestimate estimate restore sizeexit same as done commandfind find files, wildcards allowedhelp print helpls list current directory, wildcards allowedlsmark list the marked files in and below the cdmark mark dir/file to be restored recursively, wildcards allowedmarkdir mark directory name to be restored (no files)pwd print current working directoryunmark unmark dir/file to be restored recursively in dirunmarkdir unmark directory name only no recursionquit quit and do not do restore? print help$ cd usr/local/srccwd is: /usr/local/src/$ lsbacula-bat-5.0.1-2.src.rpm1bacula-bat-5.0.1-2.src.rpm2bacula-bat-5.0.1-2.src.rpm3bacula-bat-5.0.1-2.src.rpm4bacula-bat-5.0.1-2.src.rpm5bacula-bat-5.0.1-2.src.rpm6bacula-bat-5.0.1-2.src.rpm7bacula-bat-5.0.1-2.src.rpm8varnish-3.0.7.tgz2varnish-3.0.7.tgz3varnish-3.0.7.tgz34varnish-3.0.7.tgz4varnish-3.0.7.tgz5varnish-3.0.7.tgz6varnish-3.0.7.tgz7$$ mark bacula-bat-5.0.1-2.src.rpm8 ##选择要还原的包1 file marked.$ doneBootstrap records written to /usr/local/bacula/opt/bacula/working/JD-dir.restore.1.bsrThe job will require the followingVolume(s) Storage(s) SD Device(s)===========================================================================kk File FileStorageVolumes marked with "*" are online.1 file selected to be restored.Automatically selected Client: xad-fdRun Restore jobJobName: RestoreFilesBootstrap: /usr/local/bacula/opt/bacula/working/JD-dir.restore.1.bsrWhere: /tmp/bacula-restoresReplace: alwaysFileSet: Full SetBackup Client: xad-fdRestore Client: xad-fdStorage: FileWhen: 2017-09-22 13:07:18Catalog: MyCatalogPriority: 10Plugin Options: *None*OK to run? (yes/mod/no): modParameters to modify:1: Level2: Storage3: Job4: FileSet5: Restore Client6: When7: Priority8: Bootstrap9: Where10: File Relocation11: Replace12: JobId13: Plugin OptionsSelect parameter to modify (1-13): 9Select parameter to modify (1-13): 9Please enter the full path prefix for restore (/ for none): /usr/local/src ##以你的备份路劲为根路径"/",所以现在我备份完后的路径是客户端的/usr/loca/src/usr/loca/src里Run Restore jobJobName: RestoreFilesBootstrap: /usr/local/bacula/opt/bacula/working/JD-dir.restore.1.bsrWhere: /usr/local/srcReplace: alwaysFileSet: Full SetBackup Client: xad-fdRestore Client: xad-fdStorage: FileWhen: 2017-09-22 13:07:18Catalog: MyCatalogPriority: 10Plugin Options: *None*OK to run? (yes/mod/no): yesJob queued. JobId=18You have messages.查看Director状态*statusStatus available for:1: Director2: Storage3: Client4: AllSelect daemon type for status (1-4): 1JD-dir Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat (Core)Daemon started 20-Sep-17 17:15. Jobs: run=9, running=1 mode=0,0Heap: heap=151,552 smbytes=92,781 max_bytes=209,746 bufs=282 max_bufs=519Scheduled Jobs:Level Type Pri Scheduled Name Volume===================================================================================Incremental Backup 10 22-Sep-17 23:05 BackupClient1 kkFull Backup 11 22-Sep-17 23:10 BackupCatalog kk====Running Jobs:Console connected at 22-Sep-17 10:40JobId Level Name Status======================================================================18 RestoreFiles.2017-09-22_13.08.52_20 is running====产看客户端状态*statusStatus available for:1: Director2: Storage3: Client4: AllSelect daemon type for status (1-4): 3Automatically selected Client: xad-fdConnecting to Client xad-fd at XXXXXXXXX:9102xad-fd Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat (Core)Daemon started 20-Sep-17 16:53. Jobs: run=9 running=0.Heap: heap=36,864 smbytes=182,314 max_bytes=214,461 bufs=108 max_bufs=153Sizeof: boffset_t=8 size_t=8 debug=0 trace=0Running Jobs:JobId 18 Job RestoreFiles.2017-09-22_13.08.52_20 is running.Restore Job started: 22-Sep-17 13:08Files=1 Bytes=3,932,160 Bytes/sec=100,824 Errors=0Files Examined=1 Processing file: /usr/local/src/usr/local/src/bacula-bat-5.0.1-2.src.rpm8SDReadSeqNo=129 fd=5Director connected at: 22-Sep-17 13:09====22-Sep 13:08 JD-dir JobId 18: Start Restore Job RestoreFiles.2017-09-22_13.08.52_2022-Sep 13:08 JD-dir JobId 18: Using Device "FileStorage" to read.22-Sep 13:08 JD-sd JobId 18: Ready to read from volume "kk" on device "FileStorage" (/tmp).22-Sep 13:08 JD-sd JobId 18: Forward spacing Volume "kk" to file:block 0:3312462735.*完成后再次查看状态*statusStatus available for:1: Director2: Storage3: Client4: AllSelect daemon type for status (1-4): 3Automatically selected Client: xad-fdConnecting to Client xad-fd at XXXXXXXXX:9102xad-fd Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat (Core)Daemon started 20-Sep-17 16:53. Jobs: run=10 running=0.Heap: heap=36,864 smbytes=110,544 max_bytes=214,461 bufs=82 max_bufs=153Sizeof: boffset_t=8 size_t=8 debug=0 trace=0Running Jobs:Director connected at: 22-Sep-17 13:24No Jobs running.Terminated Jobs:JobId Level Files Bytes Status Finished Name======================================================================.......17 Incr 16 422.7 M OK 22-Sep-17 11:47 BackupClient118 1 51.00 M OK 22-Sep-17 13:17 RestoreFiles====22-Sep 13:17 JD-dir JobId 18: Bacula JD-dir 5.2.13 (19Jan13):Build OS: x86_64-unknown-linux-gnu redhat (Core)JobId: 18Job: RestoreFiles.2017-09-22_13.08.52_20Restore Client: xad-fdStart time: 22-Sep-2017 13:08:54End time: 22-Sep-2017 13:17:02Files Expected: 1Files Restored: 1Bytes Restored: 51,002,498Rate: 104.5 KB/sFD Errors: 0FD termination status: OKSD termination status: OKTermination: Restore OK22-Sep 13:17 JD-dir JobId 18: Begin pruning Jobs older than 6 months .22-Sep 13:17 JD-dir JobId 18: No Jobs found to prune.22-Sep 13:17 JD-dir JobId 18: Begin pruning Files.22-Sep 13:17 JD-dir JobId 18: No Files found to prune.22-Sep 13:17 JD-dir JobId 18: End auto prune
.
到此完成还原,现在去客户端的/usr/local/src/usr/local/src/里看一下
[root@Aliyun src]# pwd/usr/local/src/usr/local/src[root@Aliyun src]# lltotal 49808-rw-r--r-- 1 root root 51002498 Sep 22 10:54 bacula-bat-5.0.1-2.src.rpm8