Linux Master: ディスクバックアップとリストア

dump(8) を使った増分バックアップと、restore(8) による回復。

0.前提となる環境

# df
Filesystem	     1K-ブロック    使用   使用可 使用% マウント位置
/dev/sda6		988088	  422232    514852  46% /
/dev/sda8		497829	   58598    413529  13% /home
/dev/sda7		497829	   10549    461578   3% /tmp
/dev/sda3	       1984044	  200852   1680780  11% /var
/dev/sda2	       4956316	 3056948   1643536  66% /usr
/dev/sda1		124427	   22604     95399  20% /boot
tmpfs		       1552608	       0   1552608   0% /dev/shm

1. dump によるフルバックアップ

# dump -0uf /home/tmp0.bkup /dev/sda7
  DUMP: Date of this level 0 dump: Fri Nov 21 18:25:00 2014
  DUMP: Dumping /dev/sda7 (/tmp) to /home/tmp0.bkup
  DUMP: Label: /tmp
  DUMP: Writing 10 Kilobyte records
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 106 blocks.
  DUMP: Volume 1 started with block 1 at: Fri Nov 21 18:25:01 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /home/tmp0.bkup
  DUMP: Volume 1 completed at: Fri Nov 21 18:25:01 2014
  DUMP: Volume 1 120 blocks (0.12MB)
  DUMP: 120 blocks (0.12MB) on 1 volume(s)
  DUMP: finished in less than a second
  DUMP: Date of this level 0 dump: Fri Nov 21 18:25:00 2014
  DUMP: Date this dump completed:  Fri Nov 21 18:25:01 2014
  DUMP: Average transfer rate: 0 kB/s
  DUMP: DUMP IS DONE

2. ファイルを追加し、増分バックアップ

# cp /etc/hosts /tmp/
# dump -1uf /home/tmp1.bkup /dev/sda7
  DUMP: Date of this level 1 dump: Fri Nov 21 18:25:24 2014
  DUMP: Date of last level 0 dump: Fri Nov 21 18:25:00 2014
  DUMP: Dumping /dev/sda7 (/tmp) to /home/tmp1.bkup
  DUMP: Label: /tmp
  DUMP: Writing 10 Kilobyte records
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 48 blocks.
  DUMP: Volume 1 started with block 1 at: Fri Nov 21 18:25:25 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /home/tmp1.bkup
  DUMP: Volume 1 completed at: Fri Nov 21 18:25:25 2014
  DUMP: Volume 1 50 blocks (0.05MB)
  DUMP: 50 blocks (0.05MB) on 1 volume(s)
  DUMP: finished in less than a second
  DUMP: Date of this level 1 dump: Fri Nov 21 18:25:24 2014
  DUMP: Date this dump completed:  Fri Nov 21 18:25:25 2014
  DUMP: Average transfer rate: 0 kB/s
  DUMP: DUMP IS DONE

3. バックアップ履歴確認

# dump -W
Last dump(s) done (Dump > file systems):
  /dev/sda6	(     /) Last dump: Level 0, Date Sun Nov  9 12:20:10 2014
> /dev/sda8	( /home) Last dump: never
  /dev/sda7	(  /tmp) Last dump: Level 1, Date Fri Nov 21 18:25:24 2014
> /dev/sda3	(  /var) Last dump: never
> /dev/sda2	(  /usr) Last dump: never
> /dev/sda1	( /boot) Last dump: never

4. restoreによる回復

# cd /home
# mkdir bkup.test
# cd bkup.test
# restore -rf /home/tmp1.bkup
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume # (none if no more volumes): 1
(バックアップファイルの個数を解答)
set owner/mode for '.'? [yn] y
(カレントディレクトリのパーミッション回復可否)
# ls -l
合計 1
-rw-r--r-- 1 root root 244 11月 21 18:25 hosts
# ls -ld .
drwxrwxrwt 2 root root 1024 11月 21 18:25 /home/bkup.test

4. 対話型回復

# restore -if /home/tmp0.bkup
restore > ls
.:
.ICE-unix/
.X0-lock
.X11-unix/
	:
restore > add .X0-lock
(回復するファイルを指定)
restore > ext
(回復実行)
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume # (none if no more volumes): 1
set owner/mode for '.'? [yn] y
restore > quit