bacula初使用备份(完全备份,增量备份,和还原指定数据)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了bacula初使用备份(完全备份,增量备份,和还原指定数据)相关的知识,希望对你有一定的参考价值。
备份:
console端
[[email protected] ~]# /usr/local/bacula/sbin/bconsole Connecting to Director XXXXXX:9101 1000 OK: JD-dir Version: 5.2.13 (19 February 2013) Enter a period to cancel a command. *label##使用label创建卷组 Automatically selected Catalog: MyCatalog Using Catalog "MyCatalog" Automatically selected Storage: File Enter new Volume name: kk##输入卷组名称,可随意 Defined Pools: 1: Default 2: File 3: Scratch Select 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: BackupClient1 2: BackupCatalog 3: RestoreFiles Select Job resource (1-3): 1##选择定义好的备份任务,笔者这为增量备份,但是由于是第一次备份,所以会先完全备份,第二次才执行增量备份。 Run Backup job JobName: BackupClient1 Level: Incremental Client: xad-fd FileSet: Full Set Pool: File (From Job resource) Storage: File (From Job resource) When: 2017-09-22 10:52:45 Priority: 10 OK 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_19 22-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: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 1 JD-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,0 Heap: heap=270,336 smbytes=159,805 max_bytes=194,200 bufs=333 max_bufs=519 Scheduled Jobs: Level Type Pri Scheduled Name Volume =================================================================================== Incremental Backup 10 22-Sep-17 23:05 BackupClient1 kk Full Backup 11 22-Sep-17 23:10 BackupCatalog kk ==== Running Jobs: Console connected at 22-Sep-17 10:40 JobId Level Name Status ====================================================================== 17 Increme BackupClient1.2017-09-22_10.55.05_19 is running##任务正在执行 ==== *status##查看SD状态 Status available for: 1: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 2 Automatically selected Storage: File Connecting to Storage daemon File at XXXXXXXX:9103 JD-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=121 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0 Running 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: kk Pool: File Media 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 ==== *status Status available for: 1: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 3 Automatically selected Client: xad-fd Connecting to Client xad-fd at XXXXXXXXXX:9102 xad-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=150 Sizeof: boffset_t=8 size_t=8 debug=0 trace=0 Running Jobs: JobId 17 Job BackupClient1.2017-09-22_10.55.05_19 is running. Incremental Backup Job started: 22-Sep-17 10:55 Files=3 Bytes=109,869,316 Bytes/sec=134,808 Errors=0 Files Examined=1,731 Processing file: /usr/local/src/bacula-bat-5.0.1-2.src.rpm5##当前正在备份的数据文件 SDReadSeqNo=5 fd=5 Director 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 BackupClient1 17 Incr 16 422.7 M OK 22-Sep-17 11:47 BackupClient1 You have messages. * 22-Sep 11:47 JD-sd JobId 17: Elapsed time=00:52:26, Transfer rate=134.3 K Bytes/second 22-Sep 11:47 JD-dir JobId 17: Bacula JD-dir 5.2.13 (19Jan13): Build OS: x86_64-unknown-linux-gnu redhat (Core) JobId: 17 Job: BackupClient1.2017-09-22_10.55.05_19 Backup Level: Incremental, since=2017-09-22 02:53:05 Client: "xad-fd" 5.2.13 (19Jan13) x86_64-unknown-linux-gnu,redhat,(Core) FileSet: "Full Set" 2017-09-20 16:37:24 Pool: "File" (From Job resource) Catalog: "MyCatalog" (From Client resource) Storage: "File" (From Job resource) Scheduled time: 22-Sep-2017 10:52:45 Start time: 22-Sep-2017 10:55:08 End time: 22-Sep-2017 11:47:34 Elapsed time: 52 mins 26 secs Priority: 10 FD Files Written: 16 SD Files Written: 16 FD Bytes Written: 422,734,243 (422.7 MB) SD Bytes Written: 422,736,198 (422.7 MB) Rate: 134.4 KB/s Software Compression: None VSS: no Encryption: no Accurate: no Volume name(s): kk Volume Session Id: 8 Volume Session Time: 1505898937 Last Volume Bytes: 3,735,513,271 (3.735 GB) Non-fatal FD errors: 0 SD Errors: 0 FD termination status: OK SD termination status: OK Termination: Backup OK
还原
去客户端删除一些数据: [[email protected] 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 [[email protected] src]# rm -rf bacula-bat-5.0.1-2.src.rpm8 ##已经备份,为测试还原就删除一个数据包。
去Director端创建还原任务: [[email protected] ~]# /usr/local/bacula/sbin/bconsole *restore First you select one or more JobIds that contain files to be restored. You will be presented several methods of specifying the JobIds. Then you will be allowed to select 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: Cancel Select 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 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: Cancel Select item: (1-13): 3 Enter JobId(s), comma separated, to restore: 17 You have selected the following JobId: 17 Building directory tree for JobId(s) 17 ... 15 files inserted into the tree. You are now entering file selection mode where you add (mark) and remove (unmark) files to be restored. No files are initially added, unless you used the "all" keyword on the command line. Enter "done" to leave this mode. cwd is: / $ help Command Description ======= =========== add add dir/file to be restored recursively, wildcards allowed cd change current directory count count marked files in and below the cd delete delete dir/file to be restored recursively in dir dir long list current directory, wildcards allowed done leave file selection mode estimate estimate restore size exit same as done command find find files, wildcards allowed help print help ls list current directory, wildcards allowed lsmark list the marked files in and below the cd mark mark dir/file to be restored recursively, wildcards allowed markdir mark directory name to be restored (no files) pwd print current working directory unmark unmark dir/file to be restored recursively in dir unmarkdir unmark directory name only no recursion quit quit and do not do restore ? print help $ cd usr/local/src cwd is: /usr/local/src/ $ ls bacula-bat-5.0.1-2.src.rpm1 bacula-bat-5.0.1-2.src.rpm2 bacula-bat-5.0.1-2.src.rpm3 bacula-bat-5.0.1-2.src.rpm4 bacula-bat-5.0.1-2.src.rpm5 bacula-bat-5.0.1-2.src.rpm6 bacula-bat-5.0.1-2.src.rpm7 bacula-bat-5.0.1-2.src.rpm8 varnish-3.0.7.tgz2 varnish-3.0.7.tgz3 varnish-3.0.7.tgz34 varnish-3.0.7.tgz4 varnish-3.0.7.tgz5 varnish-3.0.7.tgz6 varnish-3.0.7.tgz7 $ $ mark bacula-bat-5.0.1-2.src.rpm8 ##选择要还原的包 1 file marked. $ done Bootstrap records written to /usr/local/bacula/opt/bacula/working/JD-dir.restore.1.bsr The job will require the following Volume(s) Storage(s) SD Device(s) =========================================================================== kk File FileStorage Volumes marked with "*" are online. 1 file selected to be restored. Automatically selected Client: xad-fd Run Restore job JobName: RestoreFiles Bootstrap: /usr/local/bacula/opt/bacula/working/JD-dir.restore.1.bsr Where: /tmp/bacula-restores Replace: always FileSet: Full Set Backup Client: xad-fd Restore Client: xad-fd Storage: File When: 2017-09-22 13:07:18 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 Select parameter to modify (1-13): 9 Please enter the full path prefix for restore (/ for none): /usr/local/src ##以你的备份路劲为根路径"/",所以现在我备份完后的路径是客户端的/usr/loca/src/usr/loca/src里 Run Restore job JobName: RestoreFiles Bootstrap: /usr/local/bacula/opt/bacula/working/JD-dir.restore.1.bsr Where: /usr/local/src Replace: always FileSet: Full Set Backup Client: xad-fd Restore Client: xad-fd Storage: File When: 2017-09-22 13:07:18 Catalog: MyCatalog Priority: 10 Plugin Options: *None* OK to run? (yes/mod/no): yes Job queued. JobId=18 You have messages. 查看Director状态 *status Status available for: 1: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 1 JD-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,0 Heap: heap=151,552 smbytes=92,781 max_bytes=209,746 bufs=282 max_bufs=519 Scheduled Jobs: Level Type Pri Scheduled Name Volume =================================================================================== Incremental Backup 10 22-Sep-17 23:05 BackupClient1 kk Full Backup 11 22-Sep-17 23:10 BackupCatalog kk ==== Running Jobs: Console connected at 22-Sep-17 10:40 JobId Level Name Status ====================================================================== 18 RestoreFiles.2017-09-22_13.08.52_20 is running ==== 产看客户端状态 *status Status available for: 1: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 3 Automatically selected Client: xad-fd Connecting to Client xad-fd at XXXXXXXXX:9102 xad-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=153 Sizeof: boffset_t=8 size_t=8 debug=0 trace=0 Running Jobs: JobId 18 Job RestoreFiles.2017-09-22_13.08.52_20 is running. Restore Job started: 22-Sep-17 13:08 Files=1 Bytes=3,932,160 Bytes/sec=100,824 Errors=0 Files Examined=1 Processing file: /usr/local/src/usr/local/src/bacula-bat-5.0.1-2.src.rpm8 SDReadSeqNo=129 fd=5 Director 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_20 22-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. * 完成后再次查看状态 *status Status available for: 1: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 3 Automatically selected Client: xad-fd Connecting to Client xad-fd at XXXXXXXXX:9102 xad-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=153 Sizeof: boffset_t=8 size_t=8 debug=0 trace=0 Running Jobs: Director connected at: 22-Sep-17 13:24 No Jobs running. Terminated Jobs: JobId Level Files Bytes Status Finished Name ====================================================================== ....... 17 Incr 16 422.7 M OK 22-Sep-17 11:47 BackupClient1 18 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: 18 Job: RestoreFiles.2017-09-22_13.08.52_20 Restore Client: xad-fd Start time: 22-Sep-2017 13:08:54 End time: 22-Sep-2017 13:17:02 Files Expected: 1 Files Restored: 1 Bytes Restored: 51,002,498 Rate: 104.5 KB/s FD Errors: 0 FD termination status: OK SD termination status: OK Termination: Restore OK 22-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/里看一下
[[email protected] src]# pwd /usr/local/src/usr/local/src [[email protected] src]# ll total 49808 -rw-r--r-- 1 root root 51002498 Sep 22 10:54 bacula-bat-5.0.1-2.src.rpm8
本文出自 “TOP-ONE” 博客,请务必保留此出处http://onenice.blog.51cto.com/13201315/1967741
以上是关于bacula初使用备份(完全备份,增量备份,和还原指定数据)的主要内容,如果未能解决你的问题,请参考以下文章
使用xtrabackup工具简单实现完全备份和增量备份并还原