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) [regular files]
vxfs vxdump: mapping (Pass II) [directories]
vxfs vxdump: estimated 114 blocks (57KB).
vxfs vxdump: dumping (Pass III) [directories]
vxfs vxdump: dumping (Pass IV) [regular files]
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 '.'? [yn] 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 '.'? [yn] 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/testvol to stdout
vxfs vxdump: mapping (Pass I) [regular files]
vxfs vxdump: mapping (Pass II) [directories]
vxfs vxdump: estimated 114 blocks (57KB).
vxfs vxdump: dumping (Pass III) [directories]
vxfs vxdump: dumping (Pass IV) [regular files]
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 '.'? [yn]
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) [regular files]
vxfs vxdump: mapping (Pass II) [directories]
vxfs vxdump: estimated 114 blocks (57KB).
vxfs vxdump: dumping (Pass III) [directories]
vxfs vxdump: dumping (Pass IV) [regular files]
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.
阅读(976) | 评论(0) | 转发(0) |