22:webサーバーを作る準備

ここを参照しクローンを作る。
次にこのサーバーにマウントする領域を設定していくが、このWEBサーバーの構成は
vda: ここにさらに領域が作られ、ルートが出来ている。
vdb: SWAP領域
vdc: /Downloadにマウントされる、他のサーバーと共有している。ここまではクローンで出来ている
vdd: /abcd1にマウント、ここにWEBコンテンツ、mysqlのデーターなどが保存される。
vde: /abcd2にマウント、ruby on rails のデーター保存場所
vdf: /abcd3にマウント、メールデーターの保存場所

マウント場所はダミーです。

元のサーバーとIPなどがダブっているが、参照先にその変更方法もあるので済まして置く。
次にサーバーを起動し、/etc/fstab を設定、下記を最後に追記

/dev/vdd		/abcd1	ext4	defaults		0 0
/dev/vde		/abcd2	ext4	defaults		0 0
/dev/vdf		/abcd3	ext4	defaults		0 0

新しいdirectoryの作成とアトリビュートの設定
# mkdir /abcd1
他のパーティションも設定する
そして設定の反映
# mount -a
次は本来ならapacheの設定だが、私はサーバーのマイグレーションをやろうとしているので、データーのコピーが必要。
色々考えたがrsyncを使うことにした。今はテストの段階だが、いずれデーターが必要なのでrsyncで同期をして置くことにした。
完全にテストが終わり、マイグレーションを実施する直前に再度 rsysnc で同期を取る。
rsyncの使い方はここに詳しく解説がある
rsyncデーモンをコピー元で動かすか、コピー先で動かすか迷ったが、コピー先つまりこのサーバーで動かすことにした。
CentOSではrsyncのデーモン動作はxinetd経由で動かすのだが、インストール済みである。また/etc/xinetd.d/rsync もxinetdのインストール時に出来ている。

service rsync
{
	disable	= no ← noに変更
# 	flags		= IPv6
 	socket_type     = stream
 	wait            = no
 	user            = root
 	server          = /usr/bin/rsync
 	server_args     = --daemon
 	log_on_failure  += USERID
}

flags=IPv6の設定の意味がよく分からない。これを行うとIPv4とIPv6の両方アクセプトするのか(多分この意味と思うが)、IPv6だけで通信を行うのか不明なのでコメントアウトしておいた。
次にrsyncの設定ファイルを作る
# gedit /etc/rsyncd.conf

# Global options
uid           = root
gid           = wheel
use chroot    = yes
log file      = /var/log/rsyncd.log
pid file      = /var/run/rsyncd.pid
hosts allow   = 192.168.xx.xx/24
hosts deny    = *
dont compress = *.gz *.tgz *.zip *.pdf *.sit *.sitx *.lzh *.bz2 *.jpg *.gif *.png

# Module options
[abcd1]
         comment      = rsync server
         path         = /abcd1
         auth users   = root
         secrets file = /etc/rsyncd.secrets
         read only    = no
[abcd2]
 	 comment      = rsync server
         path         = /abcd2
         auth users   = root
         secrets file = /etc/rsyncd.secrets
         read only    = no
[abcd3]
 	 comment      = rsync server
         path         = /abcd3
         auth users   = root
         secrets file = /etc/rsyncd.secrets
         read only    = no
 

hosts allow = で接続出来るホストをローカルネットワークに限定している。(xx.xx は環境に合わせる)
パスワードファイルの設定 /etc/rsyncd.secrets

root:xxxxxxxxx

ユーザー名:パスワードのように設定。
私はrsyncd.confに別のユーザーを指定したが出来なかった。rootにすると出来るようになった。又、このパスワードはOSのパスワードとは関係ない、勝手に決めてよい。
xinetdを再起動すればRQが来た時、動作する
# service xinetd restart
xinetdの再起動までやったが、ここはdaemonモードでやりたいので、rsyncをデーモンでスタートする
# rsync –daemon
ちなみに停止はPIDを調べてkillする
# ps auxww | grep ‘rsync –daemon’

root      2183  0.0  0.0 107624   536 ?        Ss   12:52   0:00 rsync --daemon
root      2328  0.0  0.0 107464   892 pts/0    S+   13:03   0:00 grep rsync --daemon

# kill 2183
***************
ここからはコピー元のサーバーの設定。
パスワードファイルを作る。これはなくてもパスワードを聞いてくるのですが、スクリプトを組、cronで定期的に実行するにはパスワードを聞いて来ては困るので、それに備え作っておく。
# gedit /etc/rsync.passwd

xxxxxxx

とパスワードだけを書いておくそうな。
rsyncのデーモン動作の解説WEBには複数のユーザー設定もあるが、ユーザー名の指定が無いがどう動作するのかなー?
早速コピーをするが、万が一コピー元とコピー先を間違えると全部消えるので、まずはドライラン(実際にコピーはせずテストのみする)
rsyncの書式は rsync オプション コピー元 コピー先なので
# rsync -avn –password-file=/etc/rsync.passwd /webdata/ rsync://192.168.xx.xx/abcd1
もし、ユーザー認証で跳ねられる時は、rsync.passwd とrsyncがデーモンで動いているホストの rsyncd.secrets のパーミッションが600になっているか確認。
大丈夫そうなので
# rsync -av –password-file=/etc/rsync.passwd /webdata/ rsync;//192.168.xx.xx/abcd1
もちろんIPは今制作中のホスト。
最初はrsyncd.confの auth users = root と secrets file = /etc/rsyncd.secrets をコメントアウトし、テストした方が問題が切り分けやすい。
もちろん –password-file=/etc/rsync.passwd は付けない
同様に他のパーティションもコピーするがその前に元のWEBサーバーに登録してあるユーザーをこのサーバーにも登録しておく。ただしUIDを同じにしないといけない。
書式:useradd オプション 登録するユーザー名
私はこのWEBサーバーにFTPで接続を許すユーザーがおり、homeディレクトリーが違う。そのようなユーザーには
# useradd -u 元のWEBと同じUID -d 指定するディレクトリー ユーザー名
新規ユーザー作成ではGIDも指定したUIDと同じだが、usermodでUIDを変更したら、group IDも変更しておく
# groupmod -g 元のWEBと同じGID グループ名
次に作ったユーザーのパスワードを設定
書式:passwd ユーザー名
で2回同じパスワードを入れ設定する。
必要であれば所有者の変更(UIDが違う場合)
書式:chown -R ユーザー名:グループ名 設定するdirectoryのフルパス
その後rsyncで/homeをコピーする
****************
その後、制作中のホストに戻っておく。

カテゴリー: 省エネサーバー製作(CentOS 6) | コメントする

11:リストア速度(Building directory treeの速度)が劇的に早くなった

今までBuilding directory treeに時間が掛かっていたのはMYSQLの設定だった。
時間が掛かりすぎるのでbacluaのメーリングリストで聞いたら、やっぱりおかしいようだ。
一番の問題点はMYSQLのデーターベースエンジンに MyISAMを使っている事みたい。
これをInnoDBに変更する。ALTER TABLE テーブル名 ENGINE=InnoDB; を行なえと書いてあるが、データーベースごとそっくり変更出来ないかと調べたが、テーブル単位でしか出来ないようだ。
それではとデーターベースをエクスポートして、データーベース名を変更し、新規にbaculaをInnoDBで作り、インポートしたらおかしくなっていた。インポートしたファイルを見るとDBの指定がMyISAMになっていた。
面倒くさいので、既存のDBのテーブルを一つずつInnoDBにしてから
http://bacula.us/tuning/ にあるように /etc/my.cnf に

    sort_buffer_size = 2MB
    innodb_buffer_pool_size = 128MB
    innodb_flush_log_at_trx_commit = 0
    innodb_flush_method = O_DIRECT

を追記し、mysqlを再起動、テストで

+-------+-------+----------+---------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes      | StartTime           | VolumeName |
+-------+-------+----------+---------------+---------------------+------------+
|     4 | F     |  258,441 | 2,262,481,683 | 2015-07-02 14:32:50 | Vol-0004   |
|    14 | I     |      158 |    79,623,411 | 2015-07-03 04:32:49 | Vol-0014   |
+-------+-------+----------+---------------+---------------------+------------+
You have selected the following JobIds: 4,14
Building directory tree for JobId(s) 4,14 ...

のケースではBuilding directory treeに5時間20分(リストア全体の時間ではない、Building directory treeだけにかかった時間)掛かっていたのが、10秒位で終わった。
何だこれは!!こんなに違うの!!そういえば以前は”Building directory tree”の時CPUのユーティライゼションが100%になっていた。この時SWAPの状態をチェックしていなかったが、もしかしたらSWAPが大量に発生していたのかも?
結論】baculaでmysqlを使うときは絶対にDBのベースエンジンは InnoDB にし、上記の設定を追加する事。その後私はメモリーに少し余裕があるので 

innodb_buffer_pool_size = 256M

に変更した

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

10:リストアに時間がかかりすぎる

11:リストアの時間が劇的に早くなったを参照の事。
どうもリストア時のファイルの作成(Building directory tree)に時間がかかりすぎる

+-------+-------+----------+---------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes      | StartTime           | VolumeName|
+-------+-------+----------+---------------+---------------------+------------+
|     4 | F     |  258,441 | 2,262,481,683 | 2015-07-02 14:32:50 | Vol-0004   |
|    14 | I     |      158 |    79,623,411 | 2015-07-03 04:32:49 | Vol-0014   |
+-------+-------+----------+---------------+---------------------+------------+
 You have selected the following JobIds: 4,14
 Building directory tree for JobId(s) 4,14 ...  +++++++++++++++++++++++++++++++++++++++++++
224,831 files inserted into the tree.

上記の分で5時間20分もかかっている。
誤解の無いように言っておくが、これはリストアにかかった時間ではない。Building directory treeだけにかかった時間である。
ここで不安になって来た。もし壊れて場合こんなに時間がかかっているとその間はサービスが無い状態になってしまう。
ここから mark * で少し時間がかかり(上にあるように224、831もファイルがあるのでそれに印を付けるため)それから、いよいよリストアになりこれにも時間がかかる。
上の場合はフルバックアップと一つのインクリメントファイルだけである。最悪の場合(土曜日の時)フル、差分、6個のインクリメントの計8個のファイルを使って、リストアするファイルを作るとすれば、一体どれだけ時間がかかるの?
それとも私のやり方が間違っているの?どれだけ時間がかかるか調べて見ようか。

ここを参照 劇的に早くなる

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

9:バックアップする設定を変更する

8:他のホストにリストアでも言っていますが、バックアップされるホストの全てのファイルを(マウントしている他の領域の分も含めて)FileSetで指 定してしまうと、リストア時にものすごく時間がかかってしまいます。ちなみに私はあるホストには/領域で6.7GB、マウントしている領域で2.4GBも う一つの領域で9.9GBをバックアップしたら、リストア時に8時間以上かかってしまいました。ここを参照 劇的に早くなる

(バックアップされたサイズは10.9GB)なので、方針 を変更し、それぞれのパーティション毎にJOBを作り、それに合わせてFILESETも作るようにしましたので、レストアー時はパーティション毎になります。

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

8:他のホストにリストア

バックアップしたデーターをリストアする時には同じホストへリストア(デフォルトの設定)すると、ディスクの空き容量が足りない事があります(使用容量と同じより大きい空きスペースがいる)。
私は大容量のディスクがある、バックアップサーバーにリストアしますが、これまでその方法が判らなかったのですが(回答がインターネットにあまり無い)。
やっと方法が判りましたが、簡単でした。ここをクリックし、最後の
OK to run? (yes/mod/no): まで進んで下さい。そこで下記のようにすると他のホストにリストアします

OK to run? (yes/mod/no): m
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): 5
The defined Client resources are:
      1: smb5-fd
      2: kvm5-fd
      3: web5-fd
Select Client (File daemon) resource (1-3): 1
Run Restore job JobName:         Restore-web5
Bootstrap:       /var/spool/bacula/bacula-dir.restore.1.bsr
Where:           /Backup/Restores/web5
Replace:         always
FileSet:         Full web5
Backup Client:   web5-fd
Restore Client:  smb5-fd
Storage:         File
When:            2015-05-10 10:06:20
Catalog:         MyCatalog Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): y

この意味はmで編集を選び、5でリストアされたファイルを保存するホスト選択にし、1でディスク容量の余っているホストに保存の指定をし、yでリストアを始めます。
ここで気を付けなければならないのは、本体でディスクを分けてマウントしていても、リストアした分は( / ルート)以下がすべてリストアされますのでマウントしていたディスクのすべての使用容量分の空きスペースがいります。

これを避けるには、各パーティション毎にJOBを独立して作れば、リストアーはそのパーティション分になります。

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

7:リストアを試す

そろそろバックアップデーターも貯まって来たのでリストアをためします。

# bconsole
Connecting to Director 192.168.135.60:9101
1000 OK: bacula-dir Version: 5.0.0 (26 January 2010)
Enter a period to cancel a command.
* 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
Defined Clients:
     1: samba-fd
     2: web-fd
Select the Client (1-2): 2
The defined FileSet resources are:
     1: Catalog
     2: Full web
Select FileSet resource (1-2): 2
+-------+-------+----------+----------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes       | StartTime           | VolumeName |
+-------+-------+----------+----------------+---------------------+------------+
|   214 | F     |  326,050 | 24,520,406,195 | 2013-12-03 02:16:20 | Vol-0132   |
|   229 | D     |    2,409 |    103,565,858 | 2013-12-08 02:10:13 | Vol-0147   |
|   232 | I     |   50,884 |    680,830,900 | 2013-12-09 02:06:08 | Vol-0150   |
|   237 | I     |   86,776 |  1,018,653,845 | 2013-12-10 02:06:18 | Vol-0153   |
+-------+-------+----------+----------------+---------------------+------------+
You have selected the following JobIds: 214,229,232,237

Building directory tree for JobId(s) 214,229,232,237 ...  

コ ンソールを立ち上げ、restoreコマンドをして、直近のバックアップを選び(5)、クライアントを選択し、ファイルセットを選べば上記のような表示に なります。最初のフルバックアップが示すように、圧縮後でも24Gもあるので、ここからすごく時間がかかります。私の場合は約4時間位かっかたみたいで す。ここを参照 リストアの時間が劇的に早くなる
ともかく

386,584 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: /
$ mark *
431,973 files marked.
$ done
Bootstrap records written to /var/spool/bacula/bacula-dir.restore.1.bsr

The job will require the following
   Volume(s)                 Storage(s)                SD Device(s)
===========================================================================
   
    Vol-0132                  File                      FileStorage              
    Vol-0147                  File                      FileStorage              
    Vol-0150                  File                      FileStorage              
    Vol-0153                  File                      FileStorage              

Volumes marked with "*" are online.


431,973 files selected to be restored.

The defined Restore Job resources are:
     1: Restore-samba
     2: Restore-web
Select Restore Job (1-2): 2
Run Restore job
JobName:         Restore-web
Bootstrap:       /var/spool/bacula/bacula-dir.restore.1.bsr
Where:           /Backup/BackupTemp/web
Replace:         always
FileSet:         Full web
Backup Client:   web-fd
Restore Client:  web-fd
Storage:         File
When:            2013-12-11 19:43:33
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=239
*
11-12月 19:43 bacula-dir JobId 239: Start Restore Job Restore-web.2013-12-11_19.43.40_04
11-12月 19:43 bacula-dir JobId 239: Using Device "FileStorage"
11-12月 19:43 bacula-sd JobId 239: Ready to read from volume "Vol-0132" on device "FileStorage" (/Backup).
11-12月 19:43 bacula-sd JobId 239: Forward spacing Volume "Vol-0132" to file:block 0:204.

Mark * で全ファイルに印を付け、doneでマークの作業を終われせ、2 でリストアするJOB(ホストの指定)し、yes でリストアの実行をします。
しばらくするとメールが着た。内容は下記の通り

11-12月 20:18 bacula-sd JobId 239: End of Volume at file 5 on device "FileStorage" (/Backup), Volume "Vol-0132"
11-12月 20:18 bacula-sd JobId 239: Ready to read from volume "Vol-0147" on device "FileStorage" (/Backup).
11-12月 20:18 bacula-sd JobId 239: Forward spacing Volume "Vol-0147" to file:block 0:204.
11-12月 20:18 bacula-sd JobId 239: End of Volume at file 0 on device "FileStorage" (/Backup), Volume "Vol-0147"
11-12月 20:18 bacula-sd JobId 239: Ready to read from volume "Vol-0150" on device "FileStorage" (/Backup).
11-12月 20:18 bacula-sd JobId 239: Forward spacing Volume "Vol-0150" to file:block 0:204.
11-12月 20:19 bacula-sd JobId 239: End of Volume at file 0 on device "FileStorage" (/Backup), Volume "Vol-0150"
11-12月 20:19 bacula-sd JobId 239: Ready to read from volume "Vol-0153" on device "FileStorage" (/Backup).
11-12月 20:19 bacula-sd JobId 239: Forward spacing Volume "Vol-0153" to file:block 0:204.
11-12月 20:21 bacula-sd JobId 239: End of Volume at file 0 on device "FileStorage" (/Backup), Volume "Vol-0153"
11-12月 20:21 bacula-sd JobId 239: End of all volumes.
11-12月 20:21 bacula-dir JobId 239: Bacula bacula-dir 5.0.0 (26Jan10): 11-12月-2013 20:21:30
  Build OS:               x86_64-redhat-linux-gnu redhat 
  JobId:                  239
  Job:                    Restore-web.2013-12-11_19.43.40_04
  Restore Client:         web-fd
  Start time:             11-12月-2013 19:43:42
  End time:               11-12月-2013 20:21:30
  Files Expected:         431,973
  Files Restored:         431,973
  Bytes Restored:         30,557,020,587
  Rate:                   13473.1 KB/s
  FD Errors:              0
  FD termination status:  OK
  SD termination status:  OK
  Termination:            Restore OK

11-12月 20:21 bacula-dir JobId 239: Begin pruning Jobs older than 43 years 5 months 25 days 11 hours 21 mins 30 sec.
11-12月 20:21 bacula-dir JobId 239: No Jobs found to prune.
11-12月 20:21 bacula-dir JobId 239: Begin pruning Jobs.
11-12月 20:21 bacula-dir JobId 239: Pruned Files from 4 Jobs for client web-fd from catalog.
11-12月 20:21 bacula-dir JobId 239: End auto prune.

19:43にリストアが始まり、20:21に終わり、約30GBをリストアした。

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

6:バックアップをする

firewallのTCP 9101から9103を開けておきます。
いよいよbacula(mysqlも)を走らせます。
# service mysqld start
# service bacula-sd start
# service bacura-fd start
# service bacula-dir start
この起動順はあまり関係無いと思うが、どこかのWEBでこの順番だったので。又、再起動にそなえ
# chkconfig mysqld on
# chkconfig bacula-dir on
# chkconfig bacula-sd on
# chkconfig bacula-fd on
もう一つあるホストでも
# service bacula-fd start
# chkconfig bacula-fd on
コンソールを走らせます。bacula-dirをインストールしたホストで
# bconsole
Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 5.0.0 (26 January 2010)
Enter a period to cancel a command.
*status all
bacula-dir Version: 5.0.0 (26 January 2010) x86_64-redhat-linux-gnu redhat
Daemon started 04-12��2013 19:33, 0 Jobs run since started.
Heap: heap=270,336 smbytes=46,669 max_bytes=47,246 bufs=226 max_bufs=227

Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 05-12��2013 02:05 Backup-samba *unknown*
Incremental Backup 10 05-12��2013 02:05 Backup-web *unknown*
Full Backup 11 05-12��2013 02:10 Catalog-samba *unknown*
====

Running Jobs:
Console connected at 04-12��2013 19:35
No Jobs running.
====
No Terminated Jobs.
====
Connecting to Storage daemon File at 192.168.135.65:9103

bacula-sd Version: 5.0.0 (26 January 2010) x86_64-redhat-linux-gnu redhat
Daemon started 04-12��2013 19:33, 0 Jobs run since started.
Heap: heap=135,168 smbytes=13,943 max_bytes=77,749 bufs=53 max_bufs=54
Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
====
以下、省略
まだ何もバックアップしていないので、こんな感じ表示になると思います。
で、いよいよバックアップを試す。一番最初は自動的にフルバックアップになる見たい。
*run
Automatically selected Catalog: MyCatalog
Using Catalog “MyCatalog”
A job name must be specified.
The defined Job resources are:
1: Backup-samba
2: Backup-web
3: Catalog-samba
4: Restore-samba
5: Restore-web
Select Job resource (1-5): 1
Run Backup job
JobName: Backup-samba
Level: Incremental
Client: samba-fd
FileSet: Full samba
Pool: File (From Job resource)
Storage: File (From Job resource)
When: 2013-12-04 19:40:42
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=1
You have messages.
*message
04-12月 19:41 bacula-dir JobId 1: No prior Full backup Job record found.
04-12月 19:41 bacula-dir JobId 1: No prior or suitable Full backup found in catalog. Doing FULL backup.
04-12月 19:41 bacula-dir JobId 1: Start Backup JobId 1, Job=Backup-samba.2013-12-04_19.41.03_03
04-12月 19:41 bacula-dir JobId 1: Created new Volume “Vol-0001” in catalog.
04-12月 19:41 bacula-dir JobId 1: Using Device “FileStorage”
04-12月 19:41 bacula-sd JobId 1: Labeled new Volume “Vol-0001” on device “FileStorage” (/Backup).
04-12月 19:41 bacula-sd JobId 1: Wrote label to prelabeled Volume “Vol-0001” on device “FileStorage” (/Backup)
04-12月 19:41 bacula-dir JobId 1: Max Volume jobs exceeded. Marking Volume “Vol-0001” as Used.
*
上記は run で Jobを表示させ、1でBackup-sambaを選び、yesでバックアップを開始し、messageでそのメッセージを表示している。
フルバックアップなのでかなり時間がかかる筈。気長に待つことにする。しばらくしてmessageとすると、結果が表示される(この時終わっていなければ、メッセージは無いと言われるので、終わっていない事が解る)
*message
04-12月 19:41 bacula-dir JobId 1: No prior Full backup Job record found.
04-12月 19:41 bacula-dir JobId 1: No prior or suitable Full backup found in catalog. Doing FULL backup.
04-12月 19:41 bacula-dir JobId 1: Start Backup JobId 1, Job=Backup-samba.2013-12-04_19.41.03_03
04-12月 19:41 bacula-dir JobId 1: Created new Volume “Vol-0001” in catalog.
04-12月 19:41 bacula-dir JobId 1: Using Device “FileStorage”
04-12月 19:41 bacula-sd JobId 1: Labeled new Volume “Vol-0001” on device “FileStorage” (/Backup).
04-12月 19:41 bacula-sd JobId 1: Wrote label to prelabeled Volume “Vol-0001” on device “FileStorage” (/Backup)
04-12月 19:41 bacula-dir JobId 1: Max Volume jobs exceeded. Marking Volume “Vol-0001” as Used.
*message
04-12月 19:42 samba-fd JobId 1: /net is a different filesystem. Will not descend from / into /net
04-12月 19:42 samba-fd JobId 1: /sys is a different filesystem. Will not descend from / into /sys
04-12月 19:42 samba-fd JobId 1: /root/.gvfs is a different filesystem. Will not descend from / into /root/.gvfs
04-12月 19:42 samba-fd JobId 1: /dev is a different filesystem. Will not descend from / into /dev
04-12月 19:42 samba-fd JobId 1: /misc is a different filesystem. Will not descend from / into /misc
04-12月 19:42 samba-fd JobId 1: /Download is a different filesystem. Will not descend from / into /Download
04-12月 19:48 bacula-sd JobId 1: Job write elapsed time = 00:07:51, Transfer rate = 3.900 M Bytes/second
04-12月 19:48 bacula-dir JobId 1: Bacula bacula-dir 5.0.0 (26Jan10): 04-12月-2013 19:48:56
Build OS: x86_64-redhat-linux-gnu redhat
JobId: 1
Job: Backup-samba.2013-12-04_19.41.03_03
Backup Level: Full (upgraded from Incremental)
Client: “samba-fd” 5.0.0 (26Jan10) x86_64-redhat-linux-gnu,redhat,
FileSet: “Full samba” 2013-12-04 19:41:03
Pool: “File” (From Job resource)
Catalog: “MyCatalog” (From Client resource)
Storage: “File” (From Job resource)
Scheduled time: 04-12月-2013 19:40:42
Start time: 04-12月-2013 19:41:05
End time: 04-12月-2013 19:48:56
Elapsed time: 7 mins 51 secs
Priority: 10
FD Files Written: 181,795
SD Files Written: 181,795
FD Bytes Written: 1,810,354,266 (1.810 GB)
SD Bytes Written: 1,837,013,316 (1.837 GB)
Rate: 3843.6 KB/s
Software Compression: 60.8 %
VSS: no
Encryption: no
Accurate: no
Volume name(s): Vol-0001
Volume Session Id: 1
Volume Session Time: 1386153227
Last Volume Bytes: 1,843,893,529 (1.843 GB)
Non-fatal FD errors: 0
SD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Backup OK

04-12月 19:48 bacula-dir JobId 1: Begin pruning Jobs older than 43 years 8 months 18 days 10 hours 48 mins 56 sec.
04-12月 19:48 bacula-dir JobId 1: No Jobs found to prune.
04-12月 19:48 bacula-dir JobId 1: Begin pruning Jobs.
04-12月 19:48 bacula-dir JobId 1: No Files found to prune.
04-12月 19:48 bacula-dir JobId 1: End auto prune.

*
と 無事バックアップが終わった。このバックアップに 7 mins 51 secs かかり、そのサイズは 1.843 GB であった。この時のホストの使用量は /:4.7GB, /Smbdata 約300MB でした。(bcomsoleを抜けるにはexitを入力)
そしてメールが来る。他のホスト(Backup-web)と Catalog-samba をやって置く。その後 exit で bconsoleを終了する。
リストアもテストするがもう少しバックアップしたデータが貯まってから試す。

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

5:bacula-fdの設定

bacula-fd.confの設定をしていきますが、これはそれぞれのホストに設定をしていきますが、まずはこのホスト自身のバックアップも取るので、その設定(/etc/bacula/bacula-fd.conf)
他のホストには(almalinux9の場合)
# dnf install bacula-client bacula-console

# List Directors who are permitted to contact this File daemon
Director {
  Name = bacula-dir
  Password = "xxxxx"
}

Director {
  Name = bacula-mon
  Password = "xxxxx"
  Monitor = yes
}

# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
# "Global" File daemon configuration specifications
FileDaemon {                          # this is me
  Name = samba-fd ← bacula-dir.confの名前に合わせる
  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /var/spool/bacula
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
}

# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = bacula-dir = all, !skipped, !restored
}

パスワード(データーベースに設定したPW)とName = samba-fd 以外はdefaultのままです。
次にもう一つのホストの設定ですが、その前にインストール
# yum install bacula-client bacula-console
でそのホストにbacula-clientとbacula-consoleをインストール。そして/etc/bacula/bacula-fd.confの設定

Director {
  Name = bacula-dir
  Password = "XXXX"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
#
Director {
  Name = bacula-mon
  Password = "xxxx"
  Monitor = yes
}

#
# "Global" File daemon configuration specifications
#
FileDaemon {                          # this is me
  Name = bacula-fd ← bacula-dir.confの名前に合わせる
  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /var/spool/bacula
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
}

# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = bacula-dir = all, !skipped, !restored
}

/etc/bacula/bconsole.confの設定

Director {
  Name = bacula-dir
  DIRport = 9101
  address = 192.168.xxx.xxx ← directorの動いているホストの指定をする
  Password = "xxxxx"
}

2014-07-01追記:basula-fdをスタートさせ、再起動後もスタートするように
# service bacula-fd start
# chkconfig bacula-fd on

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

4:bacula-sdの設定

bacula-sd.confの設定

Storage {                             # definition of myself
  Name = bacula-sd
  SDPort = 9103                  # Director's port      
  WorkingDirectory = "/var/spool/bacula"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
}

# List Directors who are permitted to contact Storage daemon
Director {
  Name = bacula-dir
  Password = "xxxxx"
}

# Restricted Director, used by tray-monitor to get the
#   status of the storage daemon
Director {
  Name = bacula-mon
  Password = "xxxxxx"
  Monitor = yes
}

# Note, for a list of additional Device templates please
#  see the directory <bacula-source>/examples/devices
# Or follow the following link:
#  http://bacula.svn.sourceforge.net/viewvc/bacula/trunk/bacula/examples/devices/

# Devices supported by this Storage daemon
# To connect, the Director's bacula-dir.conf must have the
#  same Name and MediaType. 
Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /Backup ← バックアップfileを保存する場所
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
}

# Send all messages to the Director, 
# mount messages also are sent to the email address
Messages {
  Name = Standard
  director = bacula-dir = all
}

パスワード(データーベースに登録したPW)とArchive Device = /Backup以外はデフォールトまま。Archive Device は物理的に別のディスク(このホスト自身のバックアップも取るから)で容量の大きなDiskを使う。

bconsole.confの設定

Director {
  Name = bacula-dir
  DIRport = 9101
  address = localhost
  Password = "xxxxx"
}

パスワード(データーベースに設定したPW)以外はdefaultのままです。

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする

3:bacula-dirの設定

まずは/etc/bacula/bacula-dir.confの設定(かなり長いですが)。http://lunatear.net/archives/001067.html も参考にしました

Director {                      # define myself
  Name = bacula-dir
  DIRport = 9101                # where we listen for UA connections
  QueryFile = "/usr/libexec/bacula/query.sql" ← こんなファイルは存在しないが、問題無い見たい
  WorkingDirectory = "/var/spool/bacula"
  PidDirectory = "/var/run"
  Maximum Concurrent Jobs = 1
  Password = "xxxxxx" ← database baculaに設定したパスワード
  Messages = Daemon
}

# Define the main nightly save backup job
#   By default, this job will back up to disk in /tmp
Job {
  Name = "Backup-samba" ← 私は二つのホストをバックアップするのでホスト毎に設定
  Client = samba-fd ← 私は二つのホストをバックアップするのでホスト毎に設定
  FileSet = "Full samba" ← 私は二つのホストをバックアップするのでホスト毎に設定
  JobDefs = "DefaultJob" ← このJobの定義はDefaultJobに定義してある
}

Job {
  Name = "Backup-web" ← 私は二つのホストをバックアップするのでホスト毎に設定
  Client = web-fd ← 私は二つのホストをバックアップするのでホスト毎に設定
  FileSet = "Full web" ← 私は二つのホストをバックアップするのでホスト毎に設定
  JobDefs = "DefaultJob" ← samba-fdと同じJobDefsを使う。つまり共通する部分をまとめてDefaultJobとして定義する
}

JobDefs {
  Name = "DefaultJob" ← 上の二つの定義をする
  Type = Backup ← バックアップをする
  Level = Incremental ← 増分の指定
  Schedule = "WeeklyCycle" ← スケジュールはWeeklyCycleを使う
  Storage = File ← ストレージのタイプはFileである。つまりディスクにファイルとして保存する
  Messages = Standard ← e-mailの内容はStandardに定義する
  Pool = File ← Poolはfile
  Priority = 10 ← プライオリティは数が少ないほど高い
  Write Bootstrap = "/var/spool/bacula/%c.bsr" ← Bootstrupファイルを記録するパス。下記参照
}

# Backup the catalog database (after the nightly save)
Job {
  Name = "Catalog-samba" ←名前の定義
  Client = samba-fd ←clientはsamba-fdを使う
  JobDefs = "CatalogJob" ←jobの定義はCatalogJobに書く
}

JobDefs {
  Name = "CatalogJob"
  Type = Backup ← バックアップをする
  Level = Full ← いつもfullバックアップをとる
  FileSet= "Catalog" ← FileSetとして、Catalogに定義する
  Schedule = "WeeklyCycleAfterBackup" ← スケジュールはWeeklyCycleAfterBackupを使う
  Storage = File ← ストレージのタイプはFileである。つまりディスクにファイルとして保存する
  Messages = Standard ← messageはStandardを使う
  Pool = File
  # This creates an ASCII copy of the catalog
  # Arguments to make_catalog_backup.pl are:
  #  make_catalog_backup.pl <catalog-name>
  RunBeforeJob = "/usr/libexec/bacula/make_catalog_backup.pl MyCatalog"
  # This deletes the copy of the catalog
#  RunAfterJob  = "/usr/libexec/bacula/delete_catalog_backup"
  Write Bootstrap = "/var/spool/bacula/%n.bsr" ← 下記参照
  Priority = 11
}

# Standard Restore template, to be changed by Console program
#  Only one such job is needed for all Jobs/Clients/Storage ...
#
Job {
  Name = "Restore-samba" ← 私は二つのホストをバックアップするのでホスト毎に設定
  Type = Restore ← リストアを定義している
  Client= samba-fd ← 私は二つのホストをバックアップするのでホスト毎に設定
  FileSet= "Full samba"                  
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /Backup/Restores/samba ← リストアされるファイルの場所を指定
}

Job {
  Name = "Restore-web"
  Type = Restore
  Client= web-fd
  FileSet= "Full web"                  
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /Backup/Restores/web ← リストアされるファイルの場所を指定
}

# List of files to be backed up
FileSet {
  Name = "Full samba" ← バックアップされるFileSetの名前
  Include {
    Options {
      signature = MD5
      Compression = GZIP ← GZip圧縮を使ってバックアップする
    }
    File = /
    File = /Data ← パーティションが違うので指定
    File = /Download ← パーティションが違うので指定
  }
  Exclude { ← バックアップしたくないディレクトリーをこれ以下に入れる
    File = /Backup ← パーティションが違うので指定しなくてもよいが念の為
    File = /var/spool/bacula ← defaultでbaculaが使うディレクトリ、私は変更しているので指定しなくてもよい
    File = /tmp ← 除外するディレクトリーの指定、最後に / を付けてはいけない
    File = /proc
    File = .journal ← 除外ファイルの指定、*.journal* と言う意味らしい
    File = .fsck
    File = .lock
  }
}

FileSet {
  Name = "Full web"
  Include {
    Options {
      signature = MD5
      Compression = GZIP
    }
    File = /
    File = /Maildata ← パーティションが違うので指定
    File = /webdata ← パーティションが違うので指定
    File = /Davdata ← パーティションが違うので指定
  }
  Exclude {
    File = /var/spool/bacula
    File = /tmp
    File = /proc
    File = .journal
    File = .fsck
    File = .lock
  }
}

# This is the backup of the catalog
FileSet {
  Name = "Catalog"
  Include {
    Options {
      signature = MD5
    }
    File = "/var/spool/bacula/bacula.sql" ← こんなファイルは無いが問題無いみたい
  }
}

# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = "WeeklyCycle"
  Run = Full 1st sun at 2:05
  Run = Differential 2nd-5th sun at 2:05
  Run = Incremental mon-sat at 2:05
}

# This schedule does the catalog. It starts after the WeeklyCycle
Schedule { ← この指定はカタログの分、
  Name = "WeeklyCycleAfterBackup"
  Run = Full sun-sat at 2:10
 # 2:10にバックアップするが、このスケジュールを使うCatalogJobの定義にPriority = 11があるので、
 # 各ホストのバックアップが終わってから始まる
}

# Client (File Services) to backup
Client {
  Name = samba-fd
  Address = 192.168.xxx.xxx ← このサーバー自体の設定なので自分のIPを指定
  FDPort = 9102
  Catalog = MyCatalog
  Password = "xxxxxx"              # password for FileDaemon
  File Retention = 62 days         # カタログDBからバックアップしたファイル一覧が削除されるまでの期間
  Job Retention = 3 months         # カタログDBからジョブの記録が消えるまでの期間
  AutoPrune = yes                  # Prune expired Jobs/Files
}

Client {
  Name = web-fd
  Address = 192.168.xxx.xxx ← バックされるもう一つのホストのIP
  FDPort = 9102
  Catalog = MyCatalog
  Password = "xxxxxx"              # password for FileDaemon
  File Retention = 62 days         # カタログDBからバックアップしたファイル一覧が削除されるまでの期間
  Job Retention = 3 months         # カタログDBからジョブの記録が消えるまでの期間
  AutoPrune = yes                  # Prune expired Jobs/Files
}

# Definition of file storage device
Storage {
  Name = File
# Do not use "localhost" here    
  Address = 192.168.xxx.xxx ← ストレージのホストつまり自分のIP、必ずIPで指定
  SDPort = 9103
  Password = "xxxxxx"
  Device = FileStorage
  Media Type = File
}

# Definition of DVD storage device
#Storage {
#  Name = "DVD"
#  Do not use "localhost" here
#  Address = storage.example.com     # N.B. Use a fully qualified name here
#  SDPort = 9103
#  Password = "@@SD_PASSWORD@@"
#  Device = "DVD Writer"
#  MediaType = "DVD"
#}

# Generic catalog service
Catalog {
  Name = MyCatalog
  dbname = "bacula"; dbuser = "bacula"; dbpassword = "xxxxx"
}

# Reasonable message delivery -- send most everything to email address
#  and to the console
Messages {
  Name = Standard
# NOTE! If you send to two email or more email addresses, you will need
#  to replace the %r in the from field (-f part) with a single valid
#  email address in both the mailcommand and the operatorcommand.
#  What this does is, it sets the email address that emails would display
#  in the FROM field, which is by default the same email as they're being
#  sent to.  However, if you send email to more than one address, then
#  you'll have to set the FROM address manually, to a single address. 
#  for example, a 'no-reply@mydomain.com', is better since that tends to
#  tell (most) people that its coming from an automated source.
  mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
  operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
  mail = xxxxx@asahi.email.ne.jp = all, !skipped ← メールを送るメアドの指定
  operator = xxxxx@asahi.email.ne.jp = mount ← メールを送るメアドの指定
  console = all, !skipped, !saved
# WARNING! the following will create a file that you must cycle from
#          time to time as it will grow indefinitely. However, it will
#          also keep all your messages if they scroll off the console.
  append = "/var/spool/bacula/log" = all, !skipped
  catalog = all
}

#
# Message delivery for daemon messages (no job).
Messages {
  Name = Daemon
  mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
  mail = xxxx@asahi.email.ne.jp = all, !skipped            
  console = all, !skipped, !saved
  append = "/var/log/bacula.log" = all, !skipped
}

# Default pool definition
Pool {
  Name = Default
  Pool Type = Backup
  Maximum Volume Jobs = 1	# これを指定しないと、同一ファイルに追記し差分や増分のファイルも一つになる
  Recycle = yes			# Bacula can automatically recycle Volumes
  AutoPrune = yes		# Prune expired volumes
  Volume Retention = 3 months	# 3ヶ月
}

# File Pool definition
Pool {
  Name = File
  Pool Type = Backup
  Maximum Volume Jobs = 1	# これを指定しないと、同一ファイルに追記し差分や増分のファイルも一つになる
  Recycle = yes			# Bacula can automatically recycle Volumes
  AutoPrune = yes		# Prune expired volumes
  Volume Retention = 3 months	# 3ヶ月
  Maximum Volume Bytes = 50G	# Limit Volume size to something reasonable
  Maximum Volumes = 200		# Limit number of Volumes in Pool
  Label Format = "Vol-"
}

# Scratch pool definition
# この定義を使っているものは無いが、defaultで存在していたので、残してある。多分無くてもOK
Pool {
  Name = Scratch
  Pool Type = Backup
}

# Restricted console used by tray-monitor to get the status of the director
#
Console {
  Name = bacula-mon
  Password = "xxxxxx"
  CommandACL = status, .status
}

Write Bootstrapにある%c.bsrはclientの名前に展開される。この場合はsamba-fd.bsrとweb-fd.bsr。%n.bsrはこのJebDefsを使っているjobの名前に変換される。この場合はCatalog-samba.bsr。
各パスワードはデーターベースbacluaのパスワードしか登録していないので、全部に同じパスワードを指定する。
私は後で出てくるbacula-sd.confのDevice{ でArchive Device で/Backup(バックアップしたデーターを保存する場所)を指定しているが、物理的に独立したHDDにする事、またもちろんバックアップ対象には入れない。
Schedule { Name = “WeeklyCycle”は、これで毎月最初の日曜日にフルバックアップし、それ以外の日曜日に差分バックアップし、それ以外の日では増分バックアップをすると言う設定。
Schedule { の Name = “WeeklyCycleAfterBackup”はバックアップが行われたら、その後にカタログを作るためにこのスケジュールがある。JobDefs{ のCatalogJobの所に Priority = 11 があるので、バックアップが終わってからスタートする。
リストア時に保存されるDirectoryは(/Backup/Restores/sambaなど)作らなくても自動で作ってくれる様だ

カテゴリー: Baclua(バックアップ)に挑戦 | コメントする