Solaris のシステム管理 (基本編)

第 47 章 ファイルとファイルシステムのバックアップ (手順)

この章では、ufsdump コマンドを使用したファイルシステムのバックアップ手順について説明します。

手順の詳細については、ファイルとファイルシステムのバックアップ (作業マップ)を参照してください。

バックアップの実行方法の概要については、第 46 章「ファイルシステムのバックアップと復元 (概要)」を参照してください。

ufsdump コマンドの構文、オプション、引数の詳細については、第 50 章「UFS バックアップおよび復元コマンド (参照情報)」を参照してください。

ファイルとファイルシステムのバックアップ (作業マップ)

作業 

説明 

参照先 

1. ファイルシステムのバックアップ準備を行う。 

バックアップで使用するファイルシステム、バックアップタイプ、テープデバイスを確認する。 

ファイルシステムバックアップの実行準備

2. ファイルシステムのバックアップに必要なテープの数を決定する。 

ファイルシステムの完全バックアップに必要なテープの数を決定する。 

完全バックアップに必要なテープ数を判別する

3. ファイルシステムをバックアップする。 

ファイルシステムの完全バックアップを実行して、全ファイルの基準コピーを取得する。 

日単位で変更されたファイルのコピーを保持することが、サイトで重要かどうかに基づいて、ファイルシステムの増分バックアップを実行する。 

ファイルシステムのバックアップをテープに作成する方法

ファイルシステムバックアップの実行準備

ファイルシステムバックアップの準備は、計画を作成することから始まります。詳細については、第 46 章「ファイルシステムのバックアップと復元 (概要)」 を参照してください。この段階では、次の項目を決定します。

詳細については、第 46 章「ファイルシステムのバックアップと復元 (概要)」を参照してください。

この節では、ファイルシステムのバックアップを作成する前に実行する必要のある、次の 2 つの作業について説明します。

ファイルシステム名を検索する方法

  1. /etc/vfstab ファイルの内容を表示します。


    $ more /etc/vfstab
    
  2. mount point 列に表示されるファイルシステム名を調べます。

  3. ファイルシステムのバックアップを作成する際、mount point 列に表示されたディレクトリ名を使用します。

例 — ファイルシステム名を検索する

この例では、バックアップ対象のファイルシステムはルート (/)、/usr/datab、および /export/home です。


$ more /etc/vfstab
#device           device             mount        FS   fsck mount   mount
#to mount         to fsck            point        type pass at boot options
#
fd                -                  /dev/fd      fd    -    no      -
/proc             -                  /proc        proc  -    no      -
/dev/dsk/c0t0d0s1 -                  -            swap  -    no      -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 /            ufs   1    no      -
/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr         ufs   1    no      -
/dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /datab       ufs   2    yes     -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs   2    yes     -
swap              -                  /tmp         tmpfs -    yes     -

完全バックアップに必要なテープ数を判別する

  1. スーパーユーザーになるか、同等の役割を引き受けます。

  2. バックアップのサイズをバイト単位で予測します。


    # ufsdump S file-system
    

    S オプションを指定すると、バックアップの実行に必要な予想バイト数が表示されます。

  3. 予測サイズをテープの容量で割り、必要なテープの数を確認します。

    テープ容量のリストについては、表 46–5 を参照してください。

例 — テープの本数を決定する

次の例では、150M バイトのテープに 489472 バイトのファイルシステムが入ります。


# ufsdump S /export/home
489472

ファイルシステムのバックアップ

バックアップを実行する際の一般的なガイドラインは次のとおりです。


注 –

NIS+ マスターサーバーをバックアップする場合は、nisbackup コマンドを使用してください。このコマンドの使用方法については、『Solaris のシステム管理 (ネーミングとディレクトリサービス : FNS、NIS+ 編)』を参照してください。


ファイルシステムのバックアップをテープに作成する方法

ufsdump コマンドを使用してファイルシステムのバックアップを作成する一般的な手順を示します。この例では、オプションと引数の使用方法を示しています。

  1. スーパーユーザーになるか、同等の役割を引き受けます。

  2. システムをレベル S (シングルユーザーモード) に移行します。

    たとえば、次のようになります。


    # shutdown -g30 -y
    
  3. (省略可能) ファイルシステムの整合性をチェックします。

    たとえば、次のようになります。


    # fsck -m /dev/rdsk/c0t0d0s7
    

    fsck -m コマンドを実行すると、ファイルシステムの整合性がチェックされます。たとえば、電源障害が発生すると、ファイルが不整合になることがあります。fsck コマンドの詳細については、第 43 章「UFS ファイルシステムの整合性チェック (手順)」を参照してください。

  4. ファイルシステムをリモートテープドライブにバックアップする場合は、次の手順を実行します。

    1. テープドライブが接続されているシステム (テープサーバー) の ./rhosts ファイルに、次のエントリを追加します。


      host root

      host エントリには、ufsdump コマンドを実行してバックアップを行うシステムの名前を指定します。

    2. テープサーバー上で、上記の /.rhosts ファイルに追加したホストに、ネームサービス経由でアクセスできることを確認します。

  5. テープドライブのデバイス名を確認します。

    デフォルトのテープドライブは、/dev/rmt/0 です。

  6. 書き込み可能なテープをテープドライブに挿入します。

  7. システムのバックアップを実行します。


    # ufsdump options arguments filenames
    

    ファイルシステムまたはファイルシステム内のディレクトリやファイルをバックアップできます。ファイルを個別にバックアップする方法については、tar(1) または cpio(1) のマニュアルページを参照してください。

    次の例では、もっとも一般的な ufsdump オプションおよび引数の使用方法を示します。

    その他の ufsdump オプションと引数については、第 50 章「UFS バックアップおよび復元コマンド (参照情報)」を参照してください。

  8. プロンプトが表示されたら、テープを取り出して、次のテープを挿入します。

  9. 各テープにボリューム番号、ダンプレベル、日付、システム名、ディスクスライス、ファイルシステム名を記入したラベルを貼ります。

  10. Control + D キーを押してシステムをレベル 3 の動作に戻します。

  11. バックアップが正常に実行されたことを確認します。


    # ufsrestore tf device-name
    

例 — ルート (/) の完全バックアップ

次の例では、ルート ( /) ファイルシステムの完全バックアップを実行する方法を示します。この例では、バックアップの実行前にシステムをシングルユーザーモードにしています。次の ufsdump オプションが含まれます。

たとえば、次のようになります。


# init 0
ok boot -s
# ufsdump 0ucf /dev/rmt/0 /
  DUMP: Date of this level 0 dump: Tue Oct 07 16:23:08 2003
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 296644 blocks (144.85MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 296224 blocks (144.64MB) on 1 volume at 424 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Tue Oct 07 16:23:08 2003
  # ufsrestore tf /dev/rmt/0
         2      .
         3      ./lost+found
      3776      ./usr
      7552      ./var
     11328      ./export
     15104      ./export/home
     18880      ./etc
     22656      ./etc/default
     22657      ./etc/default/sys-suspend
     22673      ./etc/default/cron
     22674      ./etc/default/devfsadm
     22675      ./etc/default/dhcpagent
     22676      ./etc/default/fs
     22677      ./etc/default/inetinit
     22678      ./etc/default/kbd
     22679      ./etc/default/mpathd
     22680      ./etc/default/nfslogd
     22681      ./etc/default/passwd
                .
                .
                .
  # (Control + D を押して、システムをレベル 3 に戻す)

例 — ルート (/) の増分バックアップ

次の例は、シングルユーザーモードでルート (/) ファイルシステムの増分バックアップを実行する方法を示します。次の ufsdump オプションが含まれます。


# init 0
ok boot -s
.
.
.
Rebooting with command: boot -s
SunOS Release 5.9  Generic May 2002
Copyright 1983-2003 Sun Microsystems, Inc.  All rights reserved.
.
.
.
# ufsdump 9ucf /dev/rmt/0 /
 DUMP: Date of this level 9 dump: Mon Oct 06 12:36:10 2003 
 DUMP: Date of last level 0 dump: Wed Oct 08 10:12:13 2003
 DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
 DUMP: Mapping (Pass I) [regular files]
 DUMP: Mapping (Pass II) [directories]
 DUMP: Writing 63 Kilobyte records
 DUMP: Estimated 335844 blocks (163.99MB).
 DUMP: Dumping (Pass III) [directories]
 DUMP: Dumping (Pass IV) [regular files]
 DUMP: 335410 blocks (163.77MB) on 1 volume at 893 KB/sec
 DUMP: DUMP IS DONE
 DUMP: Level 9 dump on Mon Oct 06 12:36:10 2003
 # ufsrestore tf /dev/rmt/0
         2      .
         3      ./lost+found
      5696      ./usr
     11392      ./var
     17088      ./export
     22784      ./export/home
     28480      ./opt
      5697      ./etc
     11393      ./etc/default
     11394      ./etc/default/sys-suspend
     11429      ./etc/default/cron
     11430      ./etc/default/devfsadm
     11431      ./etc/default/dhcpagent
     11432      ./etc/default/fs
     11433      ./etc/default/inetinit
     11434      ./etc/default/kbd
     11435      ./etc/default/nfslogd
     11436      ./etc/default/passwd
     11437      ./etc/default/tar
                .
                .
                .

例 — ホームディレクトリの完全バックアップ

次の例は、/export/home/kryten ホームディレクトリの完全バックアップを実行する方法を示します。次の ufsdump オプションが含まれます。


# umount /export/home

# ufsdump 0ucf /dev/rmt/0 /export/home/kryten
  DUMP: Date of this level 0 dump: Tue Oct 07 08:41:41 2003
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 470 blocks (235KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 376 blocks (188KB) on 1 volume at 1205 KB/sec
  DUMP: DUMP IS DONE
# ufsrestore tf /dev/rmt/0
         2	    .
         5      ./export
         6      ./export/home
     80799      ./export/home/kryten
     80800      ./export/home/kryten/filea
     80801      ./export/home/kryten/fileb
     80802      ./export/home/kryten/filec
     80803      ./export/home/kryten/letters
     80804      ./export/home/kryten/letters/letter1
     80805      ./export/home/kryten/letters/letter2
     80806      ./export/home/kryten/letters/letter3
     80807      ./export/home/kryten/reports
     80808      ./export/home/kryten/reports/reportA
     80809      ./export/home/kryten/reports/reportB
     80810      ./export/home/kryten/reports/reportC
#

例 — リモートシステムへの完全バックアップ (Solaris 9 データを Solaris 9 システムへ)

次の例では、Solaris 9 システム (starbug) のローカルの /export/home ファイルシステムを、シングルユーザーモードでリモートの Solaris 9 システム (earth) のテープデバイスに完全バックアップする方法を示します。次の ufsdump オプションが含まれます。


# ufsdump 0ucf earth:/dev/rmt/0 /export/home
  DUMP: Date of this level 0 dump: Mon Oct 06 12:46:50 2003
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s7 (starbug:/export/home) to 
  earth:/dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 410 blocks (205KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 376 blocks (188KB) on 1 volume at 546 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Mon Oct 06 12:46:50 2003
 # ufsrestore tf earth:/dev/rmt/0
          2      .
         3      ./lost+found
         4      ./kryten
         5      ./kryten/filea
         6      ./kryten/fileb
         7      ./kryten/filec
         8      ./kryten/letters
         9      ./kryten/letters/letter1
        10      ./kryten/letters/letter2
        11      ./kryten/letters/letter3
        12      ./kryten/reports
.
.
.
 #