Amanda(the Advanced Maryland Automatic Network Disk Archiver)は、クライアントサーバー型のバックアップシステムです。テープドライブを搭載した Amanda サーバーで、LAN 経由の複数ホスト(Amanda クライアント)のバックアップに対応します。バックアップを採取する側をサーバー、採取される側をクライアントとして記載します。
Turbolinux 10 Server の Amnda の関連ファイルは以下の通りです。
表 29-5. Amanda 関連ファイル
| ファイル名 | 備考 | |
|---|---|---|
| バージョン | Amanda-2.4.4p3 | |
| Amanda-server-2.4.4p3 | ||
| Amanda-client-2.4.4p3 | ||
| デーモン | /usr/lib/amanda/amandad | バックアップを採取されるクライアント側 |
| /usr/lib/amanda/amindexd | バックアップ用のデバイスを接続しているサーバー側 | |
| /usr/lib/amanda/amidxtaped | テープデバイスを使用するサーバー側 | |
| xinetd 経由の起動ファイル | /etc/xinetd.d/amandaidx | サーバー側 |
| /etc/xinetd.d/amidxtape | サーバー側 | |
| /etc/xinetd.d/amanda | クライアント側 | |
| 設定ファイル | /etc/amanda/DailySet1/amanda.conf | サーバー側のメインの設定ファイル |
| /etc/amanda/DailySet1/disklist | サーバー側 disklist ファイル | |
| /etc/amanda/DailySet1/tapelist | サーバー側 tapelist ファイル | |
| /etc/amanda/crontab.sample | 自動実行 cron 用サンプルファイル | |
| ログ | /var/lib/amanda/DailySet1/ 以下 |
Amanda サーバーおよびクライアントは、スーパーサーバーモードで起動します。Turbolinux 10 Server にはあらかじめ /etc/xinetd.d/ ディレクトリ以下に amanda(クライアント)、amandaidx(サーバー)、amidxtape(サーバー)の 3 つのファイルがあります。以下のように入力して xinetd による起動を有効にします。
# chkconfig amanda on # chkconfig amandaidx on # chkconfig amidxtape on # /etc/init.d/xinetd restart |
停止するには、以下のように入力して xinetd による起動を無効にします。
# chkconfig amanda off # chkconfig amandaidx off # chkconfig amidxtape off # /etc/init.d/xinetd restart |
Amanda には、amanda.conf、disklist、tapelist という 3 つの設定ファイルがあります。ここでは、メインの設定ファイル amanda.conf について解説します。(disklist は 項29.4.4 を、tapelist は 項29.4.5 を参照)。
これらの設定ファイルは、/etc/amanda ディレクトリ下の任意のディレクトリに配置され、複数のバックアップ設定が可能です。例えば、毎日定期的に行う通常のバックアップ設定は、/etc/amanda/normal ディレクトリ以下に配置し、フルバックアップを行うための設定は、/etc/amanda/archive ディレクトリ以下に配置することができます。システム管理者はバックアップのスケジュールや設計に則って設定ファイルを配置します。
Turbolinux 10 Server では、あらかじめ /etc/amanda/DailySet1/amanda.conf ファイルが用意されています。このファイルをコピーして利用することができます。
org "DailySet1" # your organization name for reports
mailto "amanda" # space separated list of operators at your site
dumpuser "amanda" # the user to run dumps under
inparallel 4 # maximum dumpers that will run in parallel
netusage 600 Kbps # maximum net bandwidth for Amanda, in KB per sec
dumpcycle 4 weeks # the number of days in the normal dump cycle
runspercycle 4 weeks # the number of amdump runs in dumpcycle days
tapecycle 25 tapes # the number of tapes in rotation
bumpsize 20 Mb # minimum savings (threshold) to bump level 1 -> 2
bumpdays 1 # minimum days at each level
bumpmult 4 # threshold = bumpsize * bumpmult^(level-1)
etimeout 300 # number of seconds per filesystem for estimates.
tapetype HP-DAT # what kind of tape it is (see tapetypes below)
labelstr "^DailySet1[0-9][0-9]*$" # label constraint regex: all tapes must match
runtapes 1 # number of tapes to be used in a single run of amdump
holdingdisk hd1 {
comment "main holding disk"
directory "/var/tmp" # where the holding disk is
use 290 Mb # how much space can we use on it
# a negative value mean:
# use all space except that value
# chunksize 2 Gb # size of chunk if you want big dump to be
# dumped on multiple files on holding disks
# N Kb/Mb/Gb split disks in chunks of size N
# 0 split disks in INT_MAX/1024 Kb chunks
# -N Kb/Mb/Gb dont split, dump larger
# filesystems directly to tape
# (example: -2 Gb)
}
define tapetype QIC-60 {
comment "Archive Viper"
length 60 mbytes
filemark 100 kbytes # don't know a better value
speed 100 kbytes # dito
}
省略 ...
define dumptype global {
comment "Global definitions"
}
define dumptype always-full {
global
comment "Full dump of this filesystem always"
compress none
priority high
dumpcycle 0
}
define interface local {
comment "a local disk"
use 1000 kbps
}
define interface eth0 {
comment "10 Mbps ethernet"
use 400 kbps
} |
主な設定項目は以下の通りです。# 以降の記述はコメントとして扱われます。キーワードの小文字と大文字は区別されません。値に数値(int)をとる項目では inf (無制限)の指定が可能です。その他、tape と tapes、day と days、y と yes、n と no のように同義として処理されるキーワードがあります(詳細は amanda の man ページを参照)。また、/etc/amanda/DailySet1/amanda.conf ファイル内にも設定項目の説明がコメントとして記載されていますので合わせて参照してください。
レポートに表示されるバックアップ設定の名前です。
レポートを受け取るユーザー名を指定します。
バックアッププロセスのユーザー名を指定します。デフォルトは amanda です。バックアップクライアント側ではこのユーザーからのアクセスを許可するように、.amandahosts に許可する必要があります。(.amandahosts の詳細は項29.4.7を参照)
Amanda が並行して実行するバックアップの最大数を指定します。
Amanda で使用可能なネットワークの最大帯域幅(1 秒あたりのキロバイト数)を指定します。
dumpする周期(バックアップサイクル)を 10 days や 4 weeks のように指定します。この周期でフルバックアップを行います。0 を指定すると常にフルバックアップを行います。
バックアップ周期中の、amdump 実行回数の指定です。
バックアップ周期中に使用するテープ数の最小値の指定です。
1 回の実行で使用するテープの数を指定します。
テープ装置のデバイス名を指定します。
テープチェンジャのデバイス名を指定します。
テープ装置(テープチェンジャ)の装置名を指定します。設定ファイルの下方に代表的なテープ装置の指定(length、filemark、speed)がありますので参照してください。
データベースファイルのパスを指定します。
ログ用ディレクトリを指定します。
インデックス用ディレクトリを指定します。
tapelist ファイルのパスを指定します。Amanda プロセスのユーザーによる書き込みを許可した空の tapelist ファイルを用意しておくと、現在使用可能なテープのリスト が Amanda により作成されます。管理者が編集する必要はありません。
バックアップをテープに書き出す前にハードディスク内に保存するための設定を以下の書式で記述します。
holdingdisk name {
holdingdisk-option holdingdisk-value
...
} |
name には、この設定を識別するための名前を指定します。holdingdisk-option には、以下の指定が可能です。詳細は、amanda の man ページや設定ファイル中のコメントを参照してください。
バックアップ方法に関する設定を以下の書式で記述します。この設定は、disklist ファイルから参照されます。
define dumptype name {
dumptype-option dumptype-value
...
} |
name には、このバックアップ設定を識別するための名前を指定します。dumptype-option には、主に以下の指定が可能です。非常に多くの指定項目があります。詳細は、amanda の man ページや設定ファイル中のコメントを参照してください。
表 29-7. dumtype - 主な dumptype-option
| auth "auth_type" | サーバーとクライアント間の認証方法の指定です。デフォルトでは bsd が指定されます。 |
| comment "comment" | コメントです。 |
| compress [client|server] "type" | バックアップイメージの圧縮の指定です。type には none (圧縮しない)、fast(CPUのオーバーヘッドは少ないが圧縮率の低い圧縮)、 best(可能な限り圧縮する) を指定します。 |
| priority "priority" | テープ残量が無い場合にこのプライオリティ順にディスクにバックアップを取ります。priority には、high(または 2)、medium(または 1)、low(または 0)から指定をします。 |
テープ装置に関する設定を以下の書式で記述します。この設定は、tapetype から参照されます。
define tapetype name {
tapetype-option tapetype-value
...
} |
name には、このテープ装置を識別するための名前を指定します。tapetype-option には、以下の指定が可能です。詳細は、amanda の man ページや設定ファイル中のコメントを参照してください。使用する tapetype は、amtapetype コマンドで調査することができます。
ネットワークインターフェースに関する設定を以下の書式で記述します。この設定は、disklist ファイルから参照されます。
define interface name {
interface-option interface-value
...
} |
name には、ネットワークインターフェースを識別するための名前を指定します。interface-option には、以下の指定が可能です。詳細は、amanda の man ページや設定ファイル中のコメントを参照してください。
例えば、以下のように編集します。
org "DailySet1"
mailto "amanda"
dumpuser "amanda"
inparallel 4
netusage 600 Kbps
dumpcycle 4 weeks
runspercycle 4 weeks
tapecycle 25 tapes
bumpsize 20 Mb
bumpdays 1
bumpmult 4
etimeout 300
runtapes 1
tapedev "/dev/nst0"
tapetype test
labelstr "^DailySet1[0-9][0-9]*$"
holdingdisk hd1 {
comment "main holding disk"
directory "/var/tmp"
use 290 Mb
}
infofile "/var/lib/amanda/DailySet1/curinfo"
logdir "/var/lib/amanda/DailySet1"
indexdir "/var/lib/amanda/DailySet1/index"
define tapetype test {
comment "just produced by tapetype prog (hardware compression on)"
length 16513 mbytes
filemark 0 kbytes
speed 1953 kps
}
define dumptype global {
comment "Global definitions"
index yes
}
define dumptype always-full {
global
comment "Full dump of this filesystem always"
compress none
priority high
dumpcycle 0
}
define interface local {
comment "a local disk"
use 1000 kbps
}
define interface eth0 {
comment "10 Mbps ethernet"
use 400 kbps
}
|
disklist ファイルには、バックアップの対象を指定します。書式は以下の通りです。サンプルファイル /etc/amanda/DailySet1/disklist がありますので合わせて参照してください。
hostname diskname [ diskdevice ] dumptype [ spindle [ interface ] ] |
表 29-10.
| hostname | バックアップされるホスト名を指定します。もし diskdevice に Samba 共有が指定された場合、Amanda はバックアップのためにこのホスト上で smbclient プログラムを実行します。 |
| diskname | バックアップ対象のデバイス名を指定します。通常は、ディスク名を指定しデバイスの指定は省略できます。同一ディスクデバイスに複数の指定をする場合には、異なるディスク名を指定する必要があります。 |
| diskdevice | デフォルトでは、ディスク名と同じで省略可能です。/dev からはじまるフルデバイス名、これを省略した sd0a 、マウントポイント、PC 上の共有 である //some-pc/home(合わせて dumptype に、GNE tar の指定があるとき、Samba 共有と認識されます)のように指定することができます。 |
| dumptype | amanda.conf に指定のある dumptype を指定することができます。(詳細は 項29.4.3 を参照) |
| spindle | デフォルトは -1 です。Amanda は 同じ番号を持つバックアップを同時には実行しません。 |
| interface | amanda.conf に指定のある interface を指定することができます。(詳細は 項29.4.3 を参照) |
例えば、client1.example.com の /home 以下のフルバックアップを指定するには以下のようになります。dumptype は、amanda.conf に指定のある前提です。
client1.example.com /home always-full |
amanda.conf ファイルの tapelist に指定をしたパス(省略時には、amanda.conf と同じディレクトリ下)に空のファイルを用意します。このファイルは、Amanda プロセスのユーザーに書き込みを許可します。システム管理者は tapelist ファイルを編集する必要はありません。
以下のように実行します。
# touch /etc/amanda/DailySet1/tapelist # chown amanda /etc/amanda/DailySet1/tapelist |
Amanda によって自動で以下のように使用可能なテープのリストが作成されます。
20040831 DailySet101 reuse |
Amanda で使用するテープには、amanda.conf ファイルの labelstr で指定をしたラベル名(正規表現の使用が可能)にマッチするよう設定しておく必要があります。以下のように、amlabel コマンドで設定します。例は、DailySet101 というラベル名の指定です。
# amlabel -f DailySet1 DailySet101 rewinding, reading label, reading label DailySet101 rewinding, writing label, DailySet101 checking label, done. |
/etc/amanda/DailySet1/amanda.conf には以下の設定があります。
tapedev "/dev/null" labelstr "^DailySet1[0-9][0-9]*$" |
バックアップを取られるクライアント側の設定を解説します。クライアント側では、まず、サーバーからのアクセスを許可する必要があります。クライアント側で、~amanda/.amandahosts ファイルに以下のようにアクセスを許可するサーバー(hostname)とユーザー(username)を指定します。
hostname [username] |
Turbolinux 10 Server の初期状態では以下のように記述されリモートホストからのバックアップが許可されていません。適切に編集をしてください。
localhost amanda localhost.localdomain amanda |
server1.example.com の amanda ユーザーからのアクセスを許可するには以下の例のように追記します。
server1.example.com amanda |
次に、バックアップ対象のデバイスに対するバックアップユーザー(amanda)の読み取り権限を有効にします。また、/etc/dumpdates ファイルへの書き込み権限が有効であることを確認します。Turbolinux 10 Server の初期状態では、/etc/dumpdates の所有グループ disk に書き込みが許可されており、amanda ユーザーは disk グループに所属しています。
/etc/services には以下のようにサーバー側と等しいポート番号を記述します。サーバー側の記述が、UDP の 10080 番の場合の例です。
amanda 10080/udp |
スーパーサーバー xinetd から Amanda クライアントが起動するように、以下のコマンドを実行します。
# chkconfig amanda on # /etc/init.d/xinetd restart |
TCP Wrappers の設定を行います。以下のように、/etc/hosts.allow ファイルを編集し、サーバー(例は、server1.example.com)からの amandad へのアクセスを許可します。
amandad server1.example.com |
手動で実行する場合は以下のように行います。正しいテープがマウントされているか、すべてのバックアップクライアントのファイルシステムの準備ができているのかをチェックします。問題がある場合は、以下の例のようにエラーが表示されます。例は、バックアップを取られるクライアント側のサービスからの応答が得られていません。
# amcheck DailySet1 Amanda Tape Server Host Check NOTE: skipping tape-writable test. Tape DailySet102 label ok. Server check took 34.966 seconds. Amanda Backup Client Hosts Check -------------------------------- WARNING: client1: selfcheck request timed out. Host down? WARNING: client2: selfcheck request timed out. Host down? Client check: 136 hosts checked in 51.945 seconds, 2 problems found. |
問題を解決してから以下のように実行します。DailySet1 の部分には、/etc/amanda 下の設定ファイル格納ディレクトリの名前を指定します。
# amdump DailySet1 |
実際に Amanda によるバックアップを取得する場合は、cron を使用して自動的に実行します。Amanda には、cron 用のサンプルファイルが /etc/amanda/crontab.sample が以下の内容で用意されています。毎週月曜から金曜の 16 時に amcheck によりテープやバックアップ対象のチェックが行われ、毎週火曜から土曜の深夜 0 時 45 分には、amdump によりバックアップが実行される場合の例です。このサンプルを参考にして cron の設定を行ってください。cron について詳細は 第27章 を参照してください。
0 16 * * 1-5 /usr/sbin/amcheck -m DailySet1 45 0 * * 2-6 /usr/sbin/amdump DailySet1 |
Amanda のバックアップデータをリストアする方法の 1 つに amrecover コマンドがあります。対話型のインターフェースを使用し、テープ上のファイルの確認や特定を行いリストア処理を実行します。このとき、サーバー側では、Amanda のデーモン(amindexd と amidxtaped)が起動されいて、amanda.conf ファイルの DUMPTYPE で index パラメータの値を yes に設定し、indexdir にバックアップのインデックスが作成されている必要があります。また、~amanda/.amandahosts ファイルに以下のようにアクセスを許可するクライアント(hostname)とユーザー(username)を指定しておきます。amrecover は、root ユーザーで起動するため、リストには amanda ユーザーではなく root を記述します。
hostname [username] |
ローカルホスト(サーバー側)で実行する場合は以下のように root ユーザーのアクセスを追加します。
localhost root localhost.localdomain root |
![]() | 他にも、amadmin や amrestore コマンドなどが用意されています。詳細は、 amanda の man ページ等を確認してください。 |
スーパーユーザーで実行します。
# amrecover AMRECOVER Version 2.4.4p3. Contacting server on localhost ... 220 dhcp-97 AMANDA index server (2.4.4p3) ready. 200 Access OK Setting restore date to today (2004-09-01) 200 Working date set to 2004-09-01. Scanning /var/tmp... 20040901: found Amanda directory. 200 Config set to DailySet1. 501 Host dhcp-97 is not in your disklist. Trying host dhcp-97.jp.tlan ... 501 Host dhcp-97.jp.tlan is not in your disklist. amrecover> |
確認やリストアを行うバックアップデータのホスト名を指定します。
amrecover> sethost client1.example.com 200 Dump host set to client1.example.com |
disklist (バックアップ対象のデバイス名やマウントポイント)を指定します。
amrecover> setdisk /home 200 Disk set to /home. |
テープ装置を指定します。
amrecover> settape server1.example.com:/dev/nst0 Using tape "/dev/nst0" from server server1.example.com. |
ls や cd を使用してバックアップファイルの内容を確認することができます。その他のコマンドは、help で確認することができます。
amrecover> ls 2004-09-01 . 2004-08-31 info/ 2004-08-31 lost+found/ 2004-08-31 project/ 2004-08-31 rika/ 2004-08-31 taro/ amrecover> cd taro /home/taro help valid commands are: add path1 ... - add to extraction list (shell wildcards) addx path1 ... - add to extraction list (regular expressions) cd directory - change cwd on virtual file system (shell wildcards) cdx directory - change cwd on virtual file system (regular expressions) 省略 ... |
ハードディスクのカレントディレクトリを移動します。リストアを実行するとカレントディレクトリに展開されます。以下の例は、/home2 に移動しています。
amrecover> lcd /home2 |
リストア対象をリストに追加します。以下は、*(ワイルドカード)を使用してテープ上のカレントディレクトリ以下をすべてリストに追加しています。
amrecover> add * Added dir /taro at date 2004-08-31 Added /taro/.Xdefaults Added /taro/.bash_history Added /taro/.bash_logout Added /taro/.bash_profile 省略 ... |
リストア対象のリストから、temp ファイルをに除きます。
amrecover> delete temp |
リストア対象のリストを表示確認します。
amrecover> list
TAPE DailySet102 LEVEL 0 DATE 2004-08-31
/taro/id_rsa.pub
/taro/.xsession
/taro/.xemacs
/taro/.vimrc
/taro/.tcshrc
省略 ... |
リストアを実行します。
mrecover> extract Extracting files using tape drive /dev/nst0 on host localhost. The following tapes are needed: DailySet102 Restoring files into directory /home2 Continue [?/Y/n]? Y Extracting files using tape drive /dev/nst0 on host localhost. Load tape DailySet102 now Continue [?/Y/n/s/t]? Y restoring ./taro/.bash_logout restoring ./taro/.Xdefaults restoring ./taro/.xemacs/init.el restoring ./taro/.lang/i18n restoring ./taro/.lang/i18nterm restoring ./taro/.lang/langrc.csh 省略 ... set owner/mode for '.'? [yn] y |
終了します。
amrecover> exit |