2012年12月16日日曜日

備忘録:ZFSルートのバックアップ手順

1. バックアップ用領域の作成

 % sudo zpool create -f backup c4t1d0s0 

 % zpool list
 NAME     SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
 backup  15.9G   126K  15.9G   0%  1.00x  ONLINE  -
 rpool   15.9G  5.22G  10.7G  32%  1.00x  ONLINE  -


2. ルートプールのプロパティを確認(ファイルに保存した方が良いかも)


 % zpool get all rpool 
 NAME   PROPERTY       VALUE                 SOURCE
 rpool  size           15.9G                 -
 rpool  capacity       32%                   -
 rpool  altroot        -                     default
 rpool  health         ONLINE                -
 rpool  guid           7318362038220972324   -
 rpool  version        33                    default
 rpool  bootfs         rpool/ROOT/solaris-1  local
 rpool  delegation     on                    default
 rpool  autoreplace    off                   default
 rpool  cachefile      -                     default
 rpool  failmode       wait                  default
 rpool  listsnapshots  off                   default
 rpool  autoexpand     off                   default
 rpool  dedupditto     0                     default
 rpool  dedupratio     1.00x                 -
 rpool  free           10.7G                 -
 rpool  allocated      5.22G                 -
 rpool  readonly       off                   -

3. ルートプールの容量確認

 % zpool list rpool
 NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
 rpool  15.9G  5.22G  10.7G  32%  1.00x  ONLINE  -

4. ルートプールのコンポーネントを特定(ファイルに保存した方が良いかも)

 % zfs list -r rpool
 NAME                       USED  AVAIL  REFER  MOUNTPOINT
 rpool                     5.29G  10.3G  46.5K  /rpool
 rpool/ROOT                2.97G  10.3G    31K  legacy
 rpool/ROOT/solaris        5.58M  10.3G  1.61G  /
 rpool/ROOT/solaris-1      2.96G  10.3G  1.62G  /
 rpool/ROOT/solaris-1/var   571M  10.3G   364M  /var
 rpool/ROOT/solaris/var    2.86M  10.3G   203M  /var
 rpool/dump                1.29G  10.4G  1.25G  -
 rpool/export               140K  10.3G    32K  /export
 rpool/export/home          108K  10.3G    32K  /export/home
 rpool/export/home/koji    76.5K  10.3G  76.5K   /export/home/koji
 rpool/swap                1.03G  10.4G  1.00G  -

5. ルートプールの再起的なスナップショットを作成

 % NOW=`date +%Y%m%d_%H%M%S`
 % sudo zfs snapshot -r rpool@rpool.${NOW}
 % zfs list -t snapshot
 NAME                                             USED  AVAIL    REFER  MOUNTPOINT
 rpool@rpool.20121216_115705                         0      -    46.5K  -
 rpool/ROOT@rpool.20121216_115705                    0      -    31K  -
 rpool/ROOT/solaris@rpool.20121216_115705            0      -    1.61G  -
 rpool/ROOT/solaris-1@install                    9.14M      -    1.40G  -
 rpool/ROOT/solaris-1@2012-12-07-02:16:10         179M      -    1.61G  -
 rpool/ROOT/solaris-1@rpool.20121216_115705          0      -    1.62G  -
 rpool/ROOT/solaris-1/var@install                 146M      -     215M  -
 rpool/ROOT/solaris-1/var@2012-12-07-02:16:10    18.1M      -     383M  -
 rpool/ROOT/solaris-1/var@rpool.20121216_115705      0      -     364M  -
 rpool/ROOT/solaris/var@rpool.20121216_115705        0      -     203M  -
 rpool/dump@rpool.20121216_115705                    0      -    1.25G  -
 rpool/export@rpool.20121216_115705                  0      -    32K  -
 rpool/export/home@rpool.20121216_115705             0      -    32K  -
 rpool/export/home/koji@rpool.20121216_115705        0      -    76.5K  -
 rpool/swap@rpool.20121216_115705                    0      -    1.00G  -

6. swap及び、dumpのスナップショットを削除

 % sudo zfs destroy rpool/dump@rpool.${NOW}
 % sudo zfs destroy rpool/swap@rpool.${NOW}
 % zfs list -t snapshot                              
 NAME                                             USED  AVAIL    REFER  MOUNTPOINT
 rpool@rpool.20121216_115705                         0      -    46.5K  -
 rpool/ROOT@rpool.20121216_115705                    0      -    31K  -
 rpool/ROOT/solaris@rpool.20121216_115705            0      -    1.61G  -
 rpool/ROOT/solaris-1@install                    9.14M      -    1.40G  -
 rpool/ROOT/solaris-1@2012-12-07-02:16:10         179M      -    1.61G  -
 rpool/ROOT/solaris-1@rpool.20121216_115705          0      -    1.62G  -
 rpool/ROOT/solaris-1/var@install                 146M      -     215M  -
 rpool/ROOT/solaris-1/var@2012-12-07-02:16:10    18.1M      -     383M  -
 rpool/ROOT/solaris-1/var@rpool.20121216_115705  76.5K      -     364M  -
 rpool/ROOT/solaris/var@rpool.20121216_115705        0      -     203M  -
 rpool/export@rpool.20121216_115705                  0      -    32K  -
 rpool/export/home@rpool.20121216_115705             0      -    32K  -
 rpool/export/home/koji@rpool.20121216_115705        0      -    76.5K  -

7. スナップショットをバックアップディスクに格納

 % sudo sh -c "zfs send -Rv rpool@rpool.${NOW} | gzip >/backup/rpool.${NOW}.gz" 
 sending from @ to rpool@rpool.20121216_115705
 WARNING: could not send rpool/swap@rpool.20121216_115705: does  not exist
 sending from @ to rpool/export@rpool.20121216_115705
 sending from @ to rpool/export/home@rpool.20121216_115705
 sending from @ to rpool/export/home/koji@rpool.20121216_115705
 sending from @ to rpool/ROOT@rpool.20121216_115705
 sending from @ to rpool/ROOT/solaris-1@install
 sending from @install to rpool/ROOT/solaris-1@2012-12-07-02:16:10
 sending from @2012-12-07-02:16:10 to rpool/ROOT/solaris-1@rpool.20121216_115705
 sending from @ to rpool/ROOT/solaris-1/var@install
 sending from @install to rpool/ROOT/solaris-1/var@2012-12-07-02:16:10
 sending from @2012-12-07-02:16:10 to rpool/ROOT/solaris-1/var@rpool.20121216_115705
 WARNING: could not send rpool/dump@rpool.20121216_115705: does  not exist
 sending from @ to rpool/ROOT/solaris@rpool.20121216_115705
 sending from @ to rpool/ROOT/solaris/var@rpool.20121216_115705
 % ls -hl /backup 
 total 2214377
 -rw-r--r--   1 root     root        1.1G 12月 16日  12:12  rpool.20121216_115705.gz

0 件のコメント:

コメントを投稿