风之幻想 发表于 2007-03-29 09:05

如何使用vxdump和vxrestore(转自veritas)

Symptom
How to use vxdump and vxrestore in a shell script



Resolution


A possible way to make a backup using vxdump and vxrestore is:

solaris1 # vxdump 0f - /testmount | (cd /testrestore ; vxrestore -yxf -)
vxfs vxdump: Date of this level 0 dump: Mon Sep 23 09:38:00 2002
vxfs vxdump: Date of last level 0 dump: the epoch
vxfs vxdump: Dumping /dev/vx/rdsk/testdg/testvol to stdout
vxfs vxdump: mapping (Pass I)
vxfs vxdump: mapping (Pass II)
vxfs vxdump: estimated 114 blocks (57KB).
vxfs vxdump: dumping (Pass III)
vxfs vxdump: dumping (Pass IV)
vxfs vxdump: vxdump: 51 tape blocks
vxfs vxdump: vxdump is done
UX:vxfs vxrestore: ERROR: cannot preserve extent attributes
UX:vxfs vxrestore: WARNING: warning: ./lost+found: File exists
set owner/mode for '.'? y
solaris1 #


The vxdump output is sent directly to 'stdout' (standard output). The standard output is piped into vxrestore
which reads from 'stdin' (standard input). This can be achieved by using the "-" option rather than
specifying a particular file to restore.

Example:
restore from "/tmp/dumpfile": vxrestore -yxf /tmp/dumpfile
restore from stdin: vxrestore -yxf -


The method using stdout/stdin is very efficient however it cannot be used inside
a shell script. Looking at the last line of the vxrestore output we see that vxrestore expects
user input before it returns to the shell prompt.

set owner/mode for '.'? y

At this point vxrestore takes stdin control completely off the shell. Any attempt
to pipe or re-direct "y" into 'stdin' would have not effect. Here is an example:

solaris1 # echo y | (vxdump 0f - /testmount | (cd /testrestore ; vxrestore -yxf -))
vxfs vxdump: Date of this level 0 dump: Mon Sep 23 09:54:39 2002
vxfs vxdump: Date of last level 0 dump: the epoch
vxfs vxdump: Dumping /dev/vx/rdsk/testdg/testvolto stdout
vxfs vxdump: mapping (Pass I)
vxfs vxdump: mapping (Pass II)
vxfs vxdump: estimated 114 blocks (57KB).
vxfs vxdump: dumping (Pass III)
vxfs vxdump: dumping (Pass IV)
vxfs vxdump: vxdump: 51 tape blocks
vxfs vxdump: vxdump is done
UX:vxfs vxrestore: ERROR: cannot preserve extent attributes
UX:vxfs vxrestore: WARNING: warning: ./lost+found: File exists
set owner/mode for '.'?

We see that vxrestore still expects the user to input "y" or "n".


What can be done to work around this ?

A possible workaround is using a temporary dump file:

solaris1 # vxdump 0f /tmp/dumpfile /testmount
vxfs vxdump: Date of this level 0 dump: Mon Sep 23 10:13:14 2002
vxfs vxdump: Date of last level 0 dump: the epoch
vxfs vxdump: Dumping /dev/vx/rdsk/testdg/testvol to /tmp/dumpfile
vxfs vxdump: mapping (Pass I)
vxfs vxdump: mapping (Pass II)
vxfs vxdump: estimated 114 blocks (57KB).
vxfs vxdump: dumping (Pass III)
vxfs vxdump: dumping (Pass IV)
vxfs vxdump: vxdump: 51 tape blocks on 1 volumes(s)
vxfs vxdump: Closing /tmp/dumpfile
vxfs vxdump: vxdump is done
solaris1 #

solaris1 # cd /testrestore ; vxrestore -e ignore -rf/tmp/dumpfile
solaris1 #
(-e ignore is used here to suppress extend attribute warning messages - please see vxrestore main pages for details)

Although using vxrestore to read from /tmp/dumpfile is slower than reading from 'stdin'
it will not require any confirmation interactively. Therefore it can be used with a shell script.

The following commands can be used in a shell script. 'stdout' and 'stderr' messages are re-directed to files:

solaris1 # vxdump 0f /tmp/dumpfile /testmount >&2 2> /tmp/dumpmsg
solaris1 # cd /testrestore ; vxrestore -e ignore -rf/tmp/dumpfile >&2 2> /tmp/restoremsg

Make sure there is sufficient disk space available for vxdump to write to. The procedure is suitable for
relatively small backups. As larger file system backups would require too much temporary disk space
alternative ways to automate backups (like VERITAS NetBackup (tm)) should be considered.


Note: All commands have been tested on Solaris 7 with Veritas File System (VxFS) 3.4 in a Korn Shell environment.

Note: Detailed information on how to use vxdump and vxrestore with their command line options can be found in the manual pages and in the "VERITAS File System 3.4 Administrator's Guide" for Solaris.

brucewoo 发表于 2007-03-29 09:07

Good

zhushuyun 发表于 2008-01-28 17:36

回复 #1 风之幻想 的帖子

不错, 好东西.

twotwotwo 发表于 2008-09-12 17:59

不错不错,顶

wstar 发表于 2008-09-16 17:03

不错。可惜是英文的。

gyh9711 发表于 2011-09-21 09:52

不错不错,很少有机会用到vxrestore,今天需要恢复一个用户数据,这资料,详细,一看基本明白。thanks!

free4us 发表于 2011-09-21 10:08

这么老的帖子都被翻出来了,顶一个!
页: [1]
查看完整版本: 如何使用vxdump和vxrestore(转自veritas)