关闭

bacula控制台使用

877人阅读 评论(0) 收藏 举报
分类:
在安装和配置好了bacula后,我们就可以开始使用它来进行备份和还原操作。

一、开启主控端、存储端、客户端线程
   启动线程方式有两种,一种是执行bacula启动脚本(存在与bacula/etc目录下(安装时指定的)),另一种是执行bacula启动二进制文件(存在/bacula/sbin目录下)。建议使用第一种,原因是执行时终端可以看到执行过程。
1.1启动服务端线程(服务端装有主控端、存储端和控制台):
#./bacula-ctl-dir start
#./bacula-ctl-sd start
或(第二种)
 #./bacula-dir 
#./bacula-sd

1.2 启动客户端线程(按照我的文档,客户端存储路径在/etc/bacula(默认路径)下,找到对应的文件)。
#./bacula-ctl-fd start
#./bacula-fd

二、Bconsole (bacula控制台)
Bconsole 是一个 shell 界面(TTY 风格)的控制台,允许用户在 Bacula 主控端守护进程运行时管理 Bacula。控制台也有两种方式进入,二进制和脚本,在对应目录下输入 # ./bacula
    在 Bconsole 中可以执行很多操作,如执行备份任务、还原任务、查看消息、查看任务状态等等,下面是所有可以执行的操作。
[root@localhost sbin]# ./bconsole
Connecting to Director localhost:9101
1000 OK: 1 saas-dir Version: 7.0.5 (28 July 2014)
Enter a period to cancel a command.
*help
  Command       Description
  =======       ===========
  add           Add media to a pool
  autodisplay   Autodisplay console messages
  automount     Automount after label
  cancel        Cancel a job
  create        Create DB Pool from resource
  delete        Delete volume, pool or job
  disable       Disable a job, attributes batch process
  enable        Enable a job, attributes batch process
  estimate      Performs FileSet estimate, listing gives full listing
  exit          Terminate Bconsole session
  gui           Non-interactive gui mode
  help          Print help on specific command
  label         Label a tape
  list          List objects from catalog
  llist         Full or long list like list command
  messages      Display pending messages
  memory        Print current memory usage
  mount         Mount storage
  prune         Prune expired records from catalog
  purge         Purge records from catalog
  quit          Terminate Bconsole session
  query         Query catalog
  restore       Restore files
  relabel       Relabel a tape
  release       Release storage
  reload        Reload conf file
  run           Run a job
  status        Report status
  stop          Stop a job
  setdebug      Sets debug level
  setbandwidth  Sets bandwidth
  setip         Sets new client address -- if authorized
  show          Show resource records
  sqlquery      Use SQL to query catalog
  time          Print current time
  trace         Turn on/off trace to file
  truncate      Truncate one or more Volumes
  unmount       Unmount storage
  umount        Umount - for old-time Unix guys, see unmount
  update        Update volume, pool or stats
  use           Use catalog xxx
  var           Does variable expansion
  version       Print Director version
  wait          Wait until no jobs are running

When at a prompt, entering a period cancels the command.

三、备份还原演示
3.1. 备份 Job
 进入 bconsole 之后,输入 run 命令

[root@localhost sbin]# ./bconsole
Connecting to Director localhost:9101
1000 OK: 1 saas-dir Version: 7.0.5 (28 July 2014)
Enter a period to cancel a command.
*run
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
     1: FullBackup
     2: IncrementalBackup
     3: DifferentialBackup
     4: restore
Select Job resource (1-4): 1

列表中的 Job 名对应的是 bacula-dir.conf 配置文件中的 Job{}中的 Name 值,这里选择1,回车

Select Job resource (1-4): 1
Run Backup job
JobName:  FullBackup
Level:    Full
Client:   saas-fd
FileSet:  Full Set
Pool:     Default (From Job resource)
Storage:  saas-sd (From Job resource)
When:     2015-07-02 13:49:03
Priority: 10
OK to run? (yes/mod/no): mod

系统会自动列出配置文件中的 FullBackup 已定义好的设定值,因为是实时执行 Job,该执行时间是当前时间,如果马上执行输入’yes’就可以了,如果要修改相关选项,需要输入’mod’,这里更改一下执行时间;

OK to run? (yes/mod/no): mod
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Client
     6: When
     7: Priority
     8: Pool
     9: Plugin Options
Select parameter to modify (1-9): 6
Please enter desired start time as YYYY-MM-DD HH:MM:SS (return for now): 2015-07-02 14:00:00
Run Backup job
JobName:  FullBackup
Level:    Full
Client:   saas-fd
FileSet:  Full Set
Pool:     Default (From Job resource)
Storage:  saas-sd (From Job resource)
When:     2015-07-02 14:00:00
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=80
*

已建立 Job,JobId 为 80。

3.2 查看 Job 状态
执行 status 命令(或st ) 查看任务状态,JobId 为 80;

*status
Status available for:
     1: Director
     2: Storage
     3: Client
     4: Scheduled
     5: All
Select daemon type for status (1-5): 5
saas-dir Version: 7.0.5 (28 July 2014) x86_64-unknown-linux-gnu redhat (Core)
Daemon started 02-7月015 10:11. Jobs: run=6, running=1 mode=0,0
 Heap: heap=393,216 smbytes=416,834 max_bytes=769,569 bufs=356 max_bufs=484

Scheduled Jobs:
Level          Type     Pri  Scheduled          Job Name           Volume
===================================================================================
Full           Backup    10  03-7月015 11:20   FullBackup         test10
Full           Backup    10  03-7月015 11:20   DifferentialBackup test10
Full           Backup    10  03-7月015 11:20   IncrementalBackup  test10
Incremental    Backup    10  03-7月015 11:25   FullBackup         test10
Incremental    Backup    10  03-7月015 11:25   IncrementalBackup  test10
Incremental    Backup    10  03-7月015 11:25   DifferentialBackup test10
====

Running Jobs:
Console connected at 02-7月015 13:57
 JobId  Type Level     Files     Bytes  Name              Status
======================================================================
    80  Back Full          0         0  FullBackup        is waiting for its start time (02-7月 14:00)
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
    65  Full          6    39.56 K  OK       01-7月015 19:47 FullBackup
    67                0         0   Cancel   01-7月015 20:24 restore
    71                6    39.56 K  OK       01-7月015 20:29 restore
    72                6    39.56 K  OK       01-7月015 20:32 restore
    74  Full          2    19.78 K  OK       02-7月015 11:37 FullBackup
    75  Full          2    19.78 K  OK       02-7月015 11:37 IncrementalBackup
    76  Full          2    19.78 K  OK       02-7月015 11:37 DifferentialBackup
    77  Incr          2    19.78 K  OK       02-7月015 11:37 FullBackup
    78  Incr          2    19.78 K  OK       02-7月015 11:37 IncrementalBackup
    79  Full          2    19.78 K  OK       02-7月015 11:37 DifferentialBackup

====
Connecting to Storage daemon saas-sd at 192.168.1.170:9103

saas-sd Version: 7.0.5 (28 July 2014) x86_64-unknown-linux-gnu redhat (Core)
Daemon started 02-7月015 11:37. Jobs: run=6, running=0.
 Heap: heap=135,168 smbytes=473,290 max_bytes=1,086,762 bufs=111 max_bufs=177
 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
===================================================================
    63                2    20.02 K  OK       01-7月015 16:28 restore
    65  Full          6    40.32 K  OK       01-7月015 19:47 FullBackup
    71                6    40.32 K  OK       01-7月015 20:29 restore
    72                6    40.32 K  OK       01-7月015 20:32 restore
    74  Full          2    20.02 K  OK       02-7月015 11:37 FullBackup
    75  Full          2    20.02 K  OK       02-7月015 11:37 IncrementalBackup
    76  Full          2    20.02 K  OK       02-7月015 11:37 DifferentialBackup
    77  Incr          2    20.02 K  OK       02-7月015 11:37 FullBackup
    78  Incr          2    20.02 K  OK       02-7月015 11:37 IncrementalBackup
    79  Full          2    20.02 K  OK       02-7月015 11:37 DifferentialBackup
====

Device status:

Device "FileStorage" (/tmp/backup) is not open.
==
====

Used Volume status:
====

====

Connecting to Client saas-fd at localhost:9102

saas-fd Version: 7.0.5 (28 July 2014)  x86_64-unknown-linux-gnu redhat (Core)
Daemon started 02-7月015 11:37. Jobs: run=6 running=0.
 Heap: heap=135,168 smbytes=588,233 max_bytes=886,066 bufs=86 max_bufs=153
 Sizes: boffset_t=8 size_t=8 debug=0 trace=0 mode=0,0 bwlimit=0kB/s

Running Jobs:
Director connected at: 02-7月015 13:57
No Jobs running.
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
===================================================================
    63                2    19.78 K  OK       01-7月015 16:28 restore
    65  Full          6    39.56 K  OK       01-7月015 19:47 FullBackup
    71                6    39.56 K  OK       01-7月015 20:29 restore
    72                6    39.56 K  OK       01-7月015 20:32 restore
    74  Full          2    19.78 K  OK       02-7月015 11:37 FullBackup
    75  Full          2    19.78 K  OK       02-7月015 11:37 IncrementalBackup
    76  Full          2    19.78 K  OK       02-7月015 11:37 DifferentialBackup
    77  Incr          2    19.78 K  OK       02-7月015 11:37 FullBackup
    78  Incr          2    19.78 K  OK       02-7月015 11:37 IncrementalBackup
    79  Full          2    19.78 K  OK       02-7月015 11:37 DifferentialBackup

3.3 查看 Job 执行详情
执行 messages 命令查看日志。注意当 Job 执行完成后,系统自动将信息显示在bconsole 控制台,如果信息已显示后,再次查看此任务信息,则需要查看 Bacula 日志文件(日志文件由bacula配置bacula-dir.conf中的Messages指定)

You have messages.
*messages
02-7月 14:00 saas-dir JobId 80: Start Backup JobId 80, Job=FullBackup.2015-07-02_13.53.30_12
02-7月 14:00 saas-dir JobId 80: Using Device "FileStorage" to write.
02-7月 14:00 saas-sd JobId 80: Volume "test10" previously written, moving to end of data.
02-7月 14:00 saas-sd JobId 80: Ready to append to end of Volume "test10" size=185,783
02-7月 14:00 saas-sd JobId 80: Elapsed time=00:00:10, Transfer rate=2.002 K Bytes/second
02-7月 14:00 saas-dir JobId 80: Bacula saas-dir 7.0.5 (28Jul14):
  Build OS:               x86_64-unknown-linux-gnu redhat (Core)
  JobId:                  80
  Job:                    FullBackup.2015-07-02_13.53.30_12
  Backup Level:           Full
  Client:                 "saas-fd" 7.0.5 (28Jul14) x86_64-unknown-linux-gnu,redhat,(Core)
  FileSet:                "Full Set" 2015-06-30 19:26:42
  Pool:                   "Default" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "saas-sd" (From Job resource)
  Scheduled time:         02-7月-2015 14:00:00
  Start time:             02-7月-2015 14:00:02
  End time:               02-7月-2015 14:00:13
  Elapsed time:           11 secs
  Priority:               10
  FD Files Written:       2
  SD Files Written:       2
  FD Bytes Written:       19,780 (19.78 KB)
  SD Bytes Written:       20,028 (20.02 KB)
  Rate:                   1.8 KB/s
  Software Compression:   None
  VSS:                    no
  Encryption:             no
  Accurate:               no
  Volume name(s):         test10
  Volume Session Id:      7
  Volume Session Time:    1435808229
  Last Volume Bytes:      206,249 (206.2 KB)
  Non-fatal FD errors:    0
  SD Errors:              0
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Backup OK

02-7月 14:00 saas-dir JobId 80: Begin pruning Jobs older than 6 months .
02-7月 14:00 saas-dir JobId 80: No Jobs found to prune.
02-7月 14:00 saas-dir JobId 80: Begin pruning Files.
02-7月 14:00 saas-dir JobId 80: No Files found to prune.
02-7月 14:00 saas-dir JobId 80: End auto prune.

*
根据提示信息我们可以知道是否备份成功、文件保存到了哪个位置哪个文件。

3.4 还原Job
还原 Job 使用 run 和 restore 命令都可以执行,但是使用 run 命令执行一个还原 Job 时,还原的数据是该 Job 最近一次的备份;而 restore 命令执行还原很早的备份 Job,执行不同要求的还原 Job。
由于本地测试run执行还原未成功,所以run还原在此不做讲解,有兴趣的可以移步到附件《bacula_管理.pdf》第 2.2.4. 还原 Job 中学习。
 
restore 命令执行还原

*restore
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"

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): 5

这里列出了很多种还原方式,这里选择第 5 种,还原最近的一次备份。


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: /
$ mark *
2 files marked.
$ done

输入 JobId 后,系统提示进入’文件选择模式’,也就是说可以选择哪些文件需要还原’mark’,哪些文件不需要还原’unmark’,还原所有文件为’mark *’。输入’mark *’之后,输入’done’完成文件选择;

$ done
Bootstrap records written to /usr/local/bacula/bin/working/saas-dir.restore.1.bsr

The Job will require the following (*=>InChanger):
   Volume(s)                 Storage(s)                SD Device(s)
===========================================================================
   
    test10                    saas-sd                   FileStorage              

Volumes marked with "*" are in the Autochanger.


2 files selected to be restored.

Using Catalog "MyCatalog"
Run Restore job
JobName:         restore
Bootstrap:       /usr/local/bacula/bin/working/saas-dir.restore.1.bsr
Where:           *None*
Replace:         always
FileSet:         Full Set
Backup Client:   saas-fd
Restore Client:  saas-fd
Storage:         saas-sd
When:            2015-07-02 14:19:11
Catalog:         MyCatalog
Priority:        10
OK to run? (yes/mod/no): yes
Job queued. JobId=81

还原后,也可以通过messages查看是否还原成功。同样的也可以通过status命令查看。
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:55615次
    • 积分:739
    • 等级:
    • 排名:千里之外
    • 原创:26篇
    • 转载:10篇
    • 译文:0篇
    • 评论:7条
    最新评论