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

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

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

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

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

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

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

作業 

説明 

参照先 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  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/device-name
    

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

  4. ファイルシステムをリモートテープドライブにバックアップする場合

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


      host root

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

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

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

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

  6. 書き込み保護をしていないテープをテープドライブに挿入します。

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


    # ufsdump options arguments filenames
    

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

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

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

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

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

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


    # ufsrestore tf device-name
    

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

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


# shutdown -g30 -y
# ufsdump 0ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Wed Sep 05 13:27:20 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t1d0s0 (earth:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 57150 blocks (27.91MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 57076 blocks (27.87MB) on 1 volume at 265 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Sep 05 13:27:20 2001
  # 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 オプションが含まれます。


# ufsdump 9ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 9 dump: Fri Jul 13 10:58:12 2001
  DUMP: Date of last level 0 dump: Fri Jul 13 10:46:09 2001
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 200 blocks (100KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 124 blocks (62KB) on 1 volume at 8 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 9 dump on Fri Jul 13 10:58:12 2001
# 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 オプションが含まれます。


# ufsdump 0ucf /dev/rmt/0 /export/home/kryten
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Fri Jul 13 11:30:45 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (pluto:/export/home) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 232 blocks (116KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 124 blocks (62KB) on 1 volume at 8 KB/sec
  DUMP: DUMP IS DONE
# ufsrestore tf /dev/rmt/0
         2	   .
      2688	   ./kryten
      5409	   ./kryten/letters
      5410	   ./kryten/letters/letter1
      5411	   ./kryten/letters/letter2
      5412	   ./kryten/letters/letter3
      2689	   ./kryten/.profile
      8096	   ./kryten/memos
        30	   ./kryten/reports
        31	   ./kryten/reports/reportA
        32	   ./kryten/reports/reportB
        33	   ./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: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Wed Sep 05 14:52:31 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s7 (starbug:/export/home) to earth:/dev ...
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 266 blocks (133KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 250 blocks (125KB) on 1 volume at 247 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Sep 05 14:52:31 2001
# ufsrestore tf earth:/dev/rmt/0
         2      .
         3      ./lost+found
      7168      ./rimmer
      7169      ./rimmer/.profile
     21504      ./rimmer/scdir
     21505      ./rimmer/scdir/scd557
     21506      ./rimmer/scdir/scd772
     10752      ./lister
     10753      ./lister/.profile
     10754      ./lister/filea
     10755      ./lister/fileb
     10756      ./lister/filec
     14336      ./pmorph
     14337      ./pmorph/.profile
      3584      ./pmorph/bigdir
      3585      ./pmorph/bigdir/bigfile
     17920      ./pmorph/smalldir
     17921      ./pmorph/smalldir/smallfile
 #