分类:
2009-05-27 09:11:00
非交互式恢复增量备份:
(1)查看/etc/dumpdates中关于/export/home的信息:
# more /etc/dumpdates|grep c0t0d0s7
/dev/rdsk/c0t0d0s7 0 Wed Apr 07 09:55:34 2007
/dev/rdsk/c0t0d0s7 1 Web Apr 07 09:57:30 2007
(2)重新构建c0t0d0s7的文件系统,再挂载到/export/home目录:
#newfs /dev/rdsk/c0t0d0s7
#mount /dev/rdsk/c0t0d0s7 /export/home
(3)插入最低级别(0级)备份磁带,并执行恢复操作:
#cd /export/home
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 64
Dump date: Wed Apr 07 09:55:34 2004
Dumped from: the epoch
Level 0 dump of /export/home on sys41:/dev/dsk/c0t0d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Make node ./directory1
Make node ./directory2
Make node ./directory3
Extract new leaves.
Check pointing the restore
extract file ./file1
extract file ./file2
extract file ./file3
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
(4)放入最新的第2级别的磁带:
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 64
Dump date: Wed Apr 07 09:57:30 2004
Dumped from: Wed Apr 07 09:55:34 2004
Level 1 dump of /export/home on sys41:/dev/dsk/c0t0d0s7
Label: none
Begin incremental restore
Initialize symbol table.
Extract directories from tape
Mark entries to be removed.
Calculate node updates.
Make node ./directory4
Make node ./directory5
Make node ./directory6
Find unreferenced names.
Remove old nodes (directories).
Extract new leaves.
Check pointing the restore
extract file ./file4
extract file ./file5
extract file ./file6
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
重复上一次操作,逐级恢复。
交互式恢复增量备份:
(1)进入交互式恢复模式,v表示输出详细信息:
#ufsrestore iv /dev/rmt/0
Verify volume and initialize maps
Media block size is 64
Dump date: Mon Oct 11 13:10:12 2004
Dumped from: the epoch
Level 0 dump of /export/home on sys41:/dev/dsk/c0t0d0s7
Label: none
Extract directories from tape
Initialize symbol table.
ufsrestore > ls
.:
2 *./ 8 directory2 5 file2
2 *../ 9 directory3 6 file3
7 directory1 4 file1 3 lost+found/
The system lists files from the last Level 0 backup.
ufsrestore > add *
Warning: ./lost+found: File exists
ufsrestore > extract
Extract requested files
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 #: 1 –程序提示放入下一个磁带库
extract file ./file1
extract file ./file2
extract file ./file3
extract file ./directory1
extract file ./directory2
extract file ./directory3
Add links
Set directory mode, owner, and times.
set owner/mode for ’.’? [yn] n –因为是恢复增量备份,原目录肯定存在
Directories already exist, set modes anyway? [yn] n –不覆盖原目录的权限设置。
ufsrestore > q
(2)根据/etc/dumpdates文件中的信息显示0级备份后有一个增量备份,放入下一个磁带:
# ufsrestore iv
Verify volume and initialize maps
Media block size is 64
Dump date: Wed Apr 07 09:57:30 2004
Dumped from: Wed Apr 07 09:55:34 2004
Level 1 dump of /export/home on sys41:/dev/dsk/c0t0d0s7
Label: none
Extract directories from tape
Initialize symbol table.
ufsrestore > ls
.:
2 *./ 13 directory4 15 directory6 11 file5
2 *../ 14 directory5 10 file4 12 file6
ufsrestore > add *
ufsrestore > extract
Extract requested files
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 #: 1
extract file ./file4
extract file ./file5
extract file ./file6
extract file ./directory4
extract file ./directory5
extract file ./directory6
Add links
Set directory mode, owner, and times.
set owner/mode for ’.’? [yn] n
ufsrestore > q
五、快照备份:
快照命令的语法:
/usr/sbin/fssnap -F FSType -V -o special_option(s) mount-point | special
选项如下所示:
-d |
删除和文件系统相关的快照,如果建立快照时使用-o选项,则备份恢复文件也会一起删除,否则,备份恢复文件要手工删除。 |
-F FSTYPE |
指定要使用的文件系统类型 |
-I |
显示指定类型的文件系统的快照状态 |
-V |
显示完整的命令,但不执行命令 |
-o |
特殊的选项,指定备份文件的位置和大小等 |
要创建一个快照,通常使用如下命令:
# fssnap -F ufs -o bs=backing_store_path /file-system
backing_store_path可以是一个裸设备,也可以是已存在的目录。
下面的命令将在/var/tmp目录中创建/export/home文件系统的快照,快照文件名默认为snapshot0.
#fssnap -F ufs -o bs=/var/tmp /export/home
#ls -l /var/tmp
Snapshot0
快照子系统把文件系统的数据存储在一个备份恢复文件(backing-store file)中,具有如下特点:
1、快照文件是一个bit-mapped文件,会一直占用磁盘空间知道删除快照。
2、快照文件的大小随着被拍照的文件系统的活动次数而改变。
3、快照文件的位置不能和被拍照的文件系统处于同一文件系统。
4、快照文件可以存在不同类型的文件系统上,比如ufs或nfs文件系统。
Fssnap命令,创建了1个快照文件和2个只读的虚拟设备:块虚拟设备/dev/fssnap/0,裸虚拟设备/dev/rfssnap/0,虚拟设备可以像其他设备一样使用备份工具对其进行备份。从一个虚拟设备中创建的备份实际上是源文件系统的备份(ufs snapshot所拍照的哪个文件系统).
当一个UFS snapshot创建时,文件系统会暂时锁定,用户在这个文件系统写数据时,可能会感觉到轻微的停滞,该文件系统越大,停滞的时间越长,写数据没有任何影响。
命令用法示例:
(1),限定快照恢复文件的大小:
-o maxsize=n(k,m,g)
-o minsize=n(k,m,g)
如果一个快照文件用完了磁盘空间,系统会自动删除ufs snapshot,不会影响源文件系统,可查看/var/adm/messages中关于snapshot的错误消息。
如果强行卸载一个活动的文件系统(如umount -f),如果该文件系统有快照存在,系统会自动删除该快照。
(2)实例演示:
创建/opt快照:
#fssnap -o maxsize=500m,bs=/var/tmp /export/home
/dev/fssnap/0
查看快照的内容:
#ls -lh /var/tmp/snapshot0
显示快照的详细信息:
#fssnap -i
0 /opt
#/usr/lib/fs/ufs/fssnap -i /export/home只能用这个命令才能看详细信息
Snapshot number : 0
Block Device : /dev/fssnap/0
Raw Device : /dev/rfssnap/0
Mount point : /export/home
Device state : idle
Backing store path : /var/tmp/snapshot0
Backing store size : 0 KB
Maximum backing store size : 512000 KB
Snapshot create time : Mon Oct 11 08:58:33 2004
Copy-on-write granularity : 32 KB
挂载和卸载快照设备:
#mkdir /tmp/tmp.snap
#mount -o ro /dev/fssnap/0 /tmp/tmp.snap
#umount /dev/fssnap/0
删除快照:
#fssnap -d /export/home
#rm /var/tmp/snapshot0
(3),备份快照:
1、对UFS快照进行备份:
创建快照并挂载新添加的快照虚拟设备:
#fssnap -F ufs -o bs=/export/home /opt
#fssnap -i
#/usr/lib/fs/ufs/fssnap -i /opt
#mkdir /tmp/optsnap
#mount -o ro /dev/fssnap/0 /tmp/optsnap
使用tar命令进行备份:
#cd /tmp/optsnap
#tar cvf /dev/rmt/0
使用ufsdump命令进行备份:
#ufsdump 0uf /dev/rmt/0 /dev/fssnap/0
#ufsrestore tf /dev/rmt/0
2、对UFS进行增量备份:
命令示例:
#ufsdump 1ufN /dev/rmt/0 /dev/rdsk/c0t1d0s0 /dev/rfssnap/0
#ufsrestore tf /dev/rmt/0
快照的增量备份实例:
创建快照:
#fssnap -o bs=/var/tmp /extra
#fssnap -i
#/usr/lib/fs/ufs/fssnap -i /extra
#mkdir /extrasnap
#mount -o ro /dev/fssnap/0 /extrasnap
#df -k|grep extra
/dev/dsk/c1t0d0s0 1294023 9 1242254 1% /extra
/dev/fssnap/0 1294023 9 1242254 1% /extrasnap
#touch file1
#df -k|grep extra 查看可用空间的不同
/dev/dsk/c1t0d0s0 1294023 20 1242243 1% /extra
/dev/fssnap/0 1294023 9 1242254 1% /extrasnap
执行全备:
# ufsdump 0ufN /dev/rmt/0 /dev/rdsk/c1t0d0s0 /dev/rfssnap/0
# ufsrestore tf /dev/rmt/0 -检查备份
删除快照:
#umount /extrasnap
#fssnap -d /extra
# rm /var/tmp/snapshot0
增量备份:
#cp file1 file5
#cp file1 file6
#fssnap -o bs=/var/tmp/extra
#mount -o ro /dev/fssnap/0 /extrasnap
#df -k|grep extra
/dev/dsk/c1t0d0s0 1294023 46 1242217 1% /extra
/dev/fssnap/0 1294023 46 1242217 1% /extrasnap
#ufsdump 1ufN /dev/rmt/0 /dev/rdsk/c1t0d0s0 /dev/rfssnap/0
#ufsrestore tf /dev/rmt/0
3、从UFS快照的备份中恢复数据:
例:从磁带备份中恢复/usr文件系统的demo目录:
#cd /usr
#ufsrestore if /dev/rmt/0
ufsrestore > add demo
ufsrestore > extract
Specify next volume #: 1
set owner/mode for ’.’? [yn] n
ufsrestore > quit