Bacula.jp構築入門

RPMによるインストールyumによるインストールBaculaの設定バックアップとリストアWindowsクライアント

バックアップとリストア

コンソールの設定

これまでの作業でバックアップを取得する準備が全て整ったので実際にバックアップを取得してみましょう。

ConsoleからDirectorデーモンへ接続します。Consoleの起動はbconsoleで行います。
Consoleで接続する前にbconsoleにDirectorデーモンの設定を行う必要があります。

bconsoleの設定

# vi /etc/bacula/bconsole.conf

Director {
Name = bacula-dir
DIRport = 9101
address = 192.168.0.173 ←接続するDirectorデーモンのIPアドレスかホスト名を指定
Password = "bacula" ←Directorデーモンに接続するためのパスワードを指定
}

バックアップ

bconsoleの設定が出来たら、bconsoleからDirectorデーモンに接続してみましょう。

bconsoleの実行

# bconsole

Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 2.0.3 (06 March 2007)
Enter a period to cancel a command.

bconsoleを起動してDirectorデーモンに接続するとプロンプトが*(アスタリスク)に変わります。
バックアップを行うためにはバックアップメディアにラベル付けを行う必要があるので、labelコマンドを実行してラベル付けを行います。

ラベルの作成

*label

Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Automatically selected Storage: File
Enter new Volume name: TESTVOL01 ←任意のラベル名を指定
Automatically selected Pool: Default
Connecting to Storage daemon File at 192.168.1.171:9103 ...
Sending label command for Volume "TESTVOL01" Slot 0 ...
3000 OK label. VolBytes=198 DVD=0 Volume="TESTVOL01" Device="FileStorage" (/var/backup)
Catalog record for Volume "TESTVOL01", Slot 0 successfully created.
Requesting to mount FileStorage ...
3906 File device "FileStorage" (/var/backup) is always mounted.

ラベル付けが終わったらバックアップを実行します。バックアップの実行はrunコマンドで行います。

バックアップの実行

*run

Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
1: Client1
2: BackupCatalog
3: RestoreFiles
Select Job resource (1-3): 1 ←Client1を選択
Run Backup job
JobName: Client1
Level: Incremental
Client: vm-nshost-fd
FileSet: Full Set
Pool: Default (From Job resource)
Storage: File (From Job resource)
When: 2008-07-17 23:14:43
Priority: 10
OK to run? (yes/mod/no): mod ←modを選択し、LevelをIncremental(増分バックアップ)からFull(フルバックアップ)に変更する。
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: When
7: Priority
8: Pool
Select parameter to modify (1-8): 1 ←1を選択
Levels:
1: Base
2: Full
3: Incremental
4: Differential
5: Since
Select level (1-5): 2 ←2を選択

これでバックアップレベルがFullに変更されます。それではバックアップを実行してみましょう。

Run Backup job
JobName: Client1
Level: Full
Client: bacula-fd
FileSet: Full Set
Pool: Default (From Job resource)
Storage: File (From Job resource)
When: 2008-07-21 13:38:45
Priority: 10
OK to run? (yes/mod/no): yes ←yesを選択し、バックアップを実行
Job queued. JobId=1

statusコマンドを実行して、バックアップ結果を確認します。

ステータスの確認

*status

Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3 ←3を選択
Automatically selected Client: bacula-fd
Connecting to Client bacula-fd at 192.168.1.171:9102

bacula-fd Version: 2.0.3 (06 March 2007) i386-redhat-linux-gnu redhat
Daemon started 21- 72008 12:51, 1 Job run since started.
Heap: bytes=77,813 max_bytes=151,376 bufs=53 max_bufs=92
Sizeof: boffset_t=8 size_t=4 debug=0 trace=0

Running Jobs:
Director connected at: 21- 72008 13:43
No Jobs running.
====

Terminated Jobs:
JobId Level Files Bytes Status Finished Name
======================================================================
1 Full 50 874.4 K OK 21- 72008 13:42 Client1
====

ステータスを確認して、OKと表示されていれば正常にバックアップが終了してます。
exitコマンドを実行し、bconsoleから抜け、bacula-sd.confのArchive Deviceで指定したディレクトリにバックアップが取得できているかを確認してください。バックアップはlabelコマンドで付与したラベル名で保存されます。

bconsoleの終了

*exit

バックアップファイルの確認

# ls -l /var/backup
-rw-r----- 1 root root 881592 2008-07-21 13:42 TESTVOL01

リストア

次に、取得したバックアップからファイルを復元できるか確認してみます。
bconsoleを実行してDirectorデーモンに接続し、restoreコマンドを実行する。

bconsoleの実行

# bconsole
Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 2.0.3 (06 March 2007)
Enter a period to cancel a command.

リストアの実行

*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: Cancel
Select item: (1-12): 5 ←5を選択
Automatically selected Client: bacula-fd
Automatically selected FileSet: Full Set
+-------+-------+----------+----------+---------------------+------------+-----------+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName | StartFile |
+-------+-------+----------+----------+---------------------+------------+-----------+
| 1 | F | 50 | 874,483 | 2008-07-21 13:42:28 | TESTVOL01 | 0 |
+-------+-------+----------+----------+---------------------+------------+-----------+
You have selected the following JobId: 1

Building directory tree for JobId 1 ... ++++++++++++++++++++
1 Job, 41 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: /
$ cd var/log ←logディレクトリに移動

cwd is: /var/log/

このディレクトリにリカバリ対象のファイル、今回はログファイルが存在する。ここでリストアの対象とするファイルを指定します。リストア対象の選択はmarkコマンドで行います。今回は全てのログファイルをリストアします。

$ mark *
49 files marked.

これで復元対象の選択は完了した。doneと入力して選択画面から抜ける。

$ done

doneコマンドを入力すると、復元の確認が表示されます。復元されるデータはWhereで指定したディレクトリに置かれるので、存在しているディレクトリを指定します。デフォルトでは/tmp/bacula-restoresとなっています。

Bootstrap records written to /var/spool/bacula/bacula-dir.restore.2.bsr

The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
TESTVOL01 File FileStorage

49 files selected to be restored.

Run Restore job
JobName: RestoreFiles
Bootstrap: /var/spool/bacula/bacula-dir.restore.2.bsr
Where: /tmp/bacula-restores
Replace: always
FileSet: Full Set
Client: bacula-fd
Storage: File
When: 2008-07-21 15:04:57
Catalog: MyCatalog
Priority: 10
OK to run? (yes/mod/no): yes ←変更がある場合はmodをこの状態で復元する場合はyesを選択
Job queued. JobId=3

これで復元対象の選択は完了した。doneと入力して選択画面から抜ける。

ステータスの確認

*status

Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3 ←3を選択
Automatically selected Client: bacula-fd
Connecting to Client bacula-fd at 192.168.1.171:9102

bacula-fd Version: 2.0.3 (06 March 2007) i386-redhat-linux-gnu redhat
Daemon started 21- 72008 12:51, 3 Jobs run since started.
Heap: bytes=143,652 max_bytes=210,872 bufs=56 max_bufs=95
Sizeof: boffset_t=8 size_t=4 debug=0 trace=0

Running Jobs:
Director connected at: 21- 72008 15:08
No Jobs running.
====

Terminated Jobs:
JobId Level Files Bytes Status Finished Name
======================================================================
1 Full 50 874.4 K OK 21- 72008 13:42 Client1
3 50 874.4 K OK 21- 72008 14:34 RestoreFiles

JobID3のStatusがOKとなっていれば、リストアが正常に行われています。
それでは実際にファイルが復元されたか確認してみましょう。

bconsoleの終了

*exit

リストアされたファイルの確認
# ls /tmp/bacula-restores/var/log/

lsコマンドでログファイルの一覧が表示されれば、リストアは成功です。

ページ先頭へ