Chapter 26 UFS Backup and Restore Commands (Reference)
This chapter contains reference information on the ufsdump and ufsrestore commands.
This is a list of information in this chapter.
For overview information about performing backups, see Chapter 22, Backing Up and Restoring File Systems (Overview).
For information about backup tasks, see Chapter 23, Backing Up Files and File Systems
(Tasks).
How the ufsdump Command Works
The ufsdump command makes two passes when it backs up a file
system. On the first pass, this command scans the raw device file for the file system
and builds a table of directories and files in memory. Then, this command writes the
table to the backup media. In the second pass, the ufsdump command
goes through the inodes in numerical order, reading the file contents and writing
the data to the backup media.
Determining Device Characteristics
The ufsdump command needs to know only an appropriate tape
block size and how to detect the end of media.
Detecting the End of Media
The ufsdump command writes a sequence of fixed-size records.
When the ufsdump command receives notification that a record was
only partially written, it assumes that it has reached the physical end of the media.
This method works for most devices. If a device is not able to notify the ufsdump command that only a partial record has been written, a media error
occurs as the ufsdump command tries to write another record.
Note –
DAT devices and 8-mm tape devices detect end-of-media. Cartridge
tape devices and 1/2–inch tape devices do not detect end-of-media.
The ufsdump command automatically detects the end-of-media
for most devices. Therefore, you do not usually need to use the -c, -d, -s, and -t options to perform multivolume
backups.
The only times you need to use the end-of-media options are under the following
conditions:
To ensure compatibility with the restore command, the size
option can still force the ufsdump command to go to the next tape
or diskette before reaching the end of the current tape or diskette.
Copying Data With the ufsdump Command
The ufsdump command copies data only from the raw disk slice.
If the file system is still active, any data in memory buffers is probably not copied.
The backup done by the ufsdump command does not copy free blocks,
nor does it make an image of the disk slice. If symbolic links point to files on other
slices, the link itself is copied.
Purpose of the /etc/dumpdates File
The ufsdump command, when used with the -u option,
maintains and updates the /etc/dumpdates file. Each line in the /etc/dumpdates file shows the following information:
-
The file system backed up
-
The dump level of the last backup
-
The day, date, and time of the backup
For example:
/dev/rdsk/c0t0d0s7 0 Wed Oct 8 10:30:52 2003
/dev/rdsk/c0t0d0s0 0 Tue Oct 6 10:12:13 2003
/dev/rdsk/c0t0d0s0 9 Wed Oct 8 10:26:14 2003
|
When you do an incremental
backup, the ufsdump command checks the /etc/dumpdates file to find the date of the most recent backup of the next lower dump
level. Then, this command copies to the media all files that were modified since the
date of that lower-level backup. After the backup is complete, a new information line,
which describes the backup you just completed, replaces the information line for the
previous backup at that level.
Use the /etc/dumpdates file to verify that backups are
being done. This verification is particularly important if you are having equipment
problems. If a backup cannot be completed because of equipment failure, the backup
is not recorded in the /etc/dumpdates file.
If you need to restore an entire disk, check the /etc/dumpdates file
for a list of the most recent dates and levels of backups so that you can determine
which tapes you need to restore the entire file system.
Note –
The /etc/dumpdates file is a text file that can be
edited. However, edit it only at your own risk. If you make changes to the file that
do not match your archive tapes, you might be unable to find the tapes (or files)
you need.
Backup Device (dump-file)
Argument
The dump-file argument (to the -f option)
specifies the destination of the backup. The destination can be one of the following:
-
Local tape drive
-
Local diskette drive
-
Remote tape drive
-
Remote diskette drive
-
Standard output
Use this argument when the destination is not the default local tape drive /dev/rmt/0. If you use the -f option, then you must specify
a value for thedump-file argument.
Note –
The dump-file argument can also point to a
file on a local disk or on a remote disk. If done by mistake, this usage can fill
up a file system.
Local Tape or Diskette Drive
Typically, the dump-file argument specifies a raw
device file for a tape device or diskette. When the ufsdump command
writes to an output device, it creates a single backup file that might span multiple
tapes or diskettes.
You specify a tape device or a diskette on your system by using a device abbreviation.
The first device is always 0. For example, if you have a SCSI tape controller and
one QIC-24 tape drive that uses medium-density formatting, use this device name:
/dev/rmt/0m
When you specify a tape device name, you can also type the letter “n”
at the end of the name to indicate that the tape drive should not rewind after the
backup is completed. For example:
/dev/rmt/0mn
Use the “no-rewind” option if you want to put more than one file
onto the tape. If you run out of space during a backup, the tape does not rewind before
the ufsdump command asks for a new tape. For a complete description
of device naming conventions, see Backup Device Names.
Remote Tape or Diskette Drive
You specify a remote tape device or a remote diskette by using the syntax host:device. The ufsdump command writes to the remote device when superuser on the local
system has access to the remote system. If you usually run the ufsdump command
as superuser, the name of the local system must be included in the /.rhosts file on the remote system. If you specify the device as user@host:device,
the ufsdump command tries to access the device on the remote system
as the specified user. In this case, the specified user must be included in the /.rhosts file on the remote system.
Use the naming convention for the device that matches the operating system for
the system on which the device resides, not the system from which you run the ufsdump command. If the drive is on a system that is running a previous
SunOS release (for example, 4.1.1), use the SunOS 4.1 device name (for example, /dev/rst0). If the system is running Solaris software, use the SunOS 5.9
convention (for example, /dev/rmt/0).
Using Standard Output With the ufsdump Command
When you specify a dash (-) as the dump-file argument, the ufsdump command writes to standard
output.
Note –
The -v option (verify) does not work when the dump-file argument is standard output.
You can use the ufsdump and ufsrestore commands
in a pipeline to copy a file system by writing to standard output with the ufsdump command and reading from standard input with the ufsrestore command. For example:
# ufsdump 0f - /dev/rdsk/c0t0d0s7 | (cd /home; ufsrestore xf -)
|
Specifying Files to Back Up
You must always include filenames as the last argument
on the command line. This argument specifies the source or contents of the backup.
For a file system, specify the raw device file as follows:
/dev/rdsk/c0t0d0s6
You can specify the file system by its mount point directory (for example, /export/home), as long as an entry for it exists in the /etc/vfstab file.
For a complete description of device– naming conventions, see Backup Device Names.
For individual files or directories, type one or more names separated by spaces.
Note –
When you use the ufsdump command to back up one or
more directories or files (rather than a complete file system), a level 0 backup is
done. Incremental backups do not apply.
Specifying Tape Characteristics
If you do not specify any tape characteristics, the ufsdump command
uses a set of defaults. You can specify the tape cartridge (c),
density (d), size (s), and number of tracks
(t). Note that you can specify the options in any order, as long
as the arguments that follow match the order of the options.
Limitations of the ufsdump Command
The ufsdump command
cannot do the following:
-
Automatically calculate the number of tapes or diskettes that are
needed for backing up file systems. You can use the dry run mode (S option)
to determine how much space is needed before actually backing up file systems.
-
Provide built-in error checking to minimize problems when it backs
up an active file system.
-
Back up files that are remotely mounted from a server. Files on the
server must be backed up on the server itself. Users are denied permission to run
the ufsdump command on files they own that are located on a server.
Options and Arguments for the ufsdump Command
This section describes in detail the options and arguments for the ufsdump command. The syntax for the ufsdump command is
as follows:
/usr/sbin/ufsdump options arguments filenames
|
-
options
-
Is a single string of one-letter option names.
-
arguments
-
Identifies option arguments and might consist of multiple strings.
The option letters and their associated arguments must be in the same order.
-
filenames
-
Identifies the files to back up. These arguments must always come
last, each separated by a space.
Default ufsdump Options
If you run the ufsdump command without any options, use this
syntax:
The ufsdump command uses these options and arguments, by
default:
ufsdump 9uf /dev/rmt/0 filenames
|
These options do a level 9 incremental backup to the default tape drive at its
preferred density.
Options for the ufsdump Command
The following table describes the options for the ufsdump command.
Table 26–1 Options for the
ufsdump Command
|
Option
|
Description
|
|
0–9
|
Dump level. Level 0 is for a full backup of the complete file system or file
systems specified by filenames. Levels 1–9 are for
incremental backups of files that have changed since the last lower-level backup.
|
|
a archive-file
|
Archive file. Specifies a file that stores (archives) a backup table of contents.
The file can be understood only by the ufsrestore command. This
command uses the table of contents to determine whether a file to be restored is present
in a backup file, and if so, on which volume of the media the file resides.
|
|
b factor
|
Blocking factor. Specifies the number of 512-byte blocks to write to tape at
a time.
|
|
c
|
Cartridge. Identifies the backup media as cartridge tape. When end-of-media
detection applies, this option sets the block size to 126.
|
|
d bpi
|
Tape density. Specifies the tape density. Use this option only when the ufsdump command cannot detect the end of the media.
|
|
D
|
Diskette. Identifies the backup media as a diskette.
|
|
f dump-file
|
Dump file. Writes the files to the destination that is specified by dump-file instead of the default device. If the file is specified as user@system:device, the ufsdump command attempts
to execute as the specified user on the remote system. The specified user must have
a /.rhosts file on the remote system that allows the user who
is invoking the command on the local system to access the remote system.
|
|
l
|
Autoload. Use this option if you have an autoloading (stackloader) tape drive.
When the end of a tape is reached, this option takes the drive offline and waits up
to two minutes for the tape drive to be ready again. If the drive is ready within
two minutes, the autoload continues. If the drive is not ready after two minutes,
autoload prompts the operator to load another tape.
|
|
n
|
Notify. When intervention is needed, this option sends a message to all terminals
of all users in the sys group.
|
|
o
|
Offline. When the command is finished with a tape or diskette, this option takes
the drive offline, rewinds (if tape), and if possible removes the media. For example,
this option ejects a diskette or removes an 8-mm autoloaded tape.
|
|
s size
|
Size. Specifies the size of the backup media. For tapes, the size is specified
in feet. For diskettes, the size is specified by the number of 1024–byte blocks..
Use this option only when the ufsdump command cannot detect the
end of the media.
|
|
S
|
Size. Estimates the size of the backup. Determines the amount of space that
is needed to perform the backup, without actually doing it. Outputs a single number
that indicates the estimated size of the backup in bytes.
|
|
t tracks
|
Tracks. Specifies the number of tracks for a 1/4-inch cartridge tape. Use this
option only when the ufsdump command cannot detect the end of the
media.
|
|
u
|
Update. Updates the dump record. A completed backup of a file system adds an
entry to the /etc/dumpdates file. The entry indicates the device
name for the file system's disk slice, the dump level (0–9), and the date. No
record is written when you do not use the u option or when you
back up individual files or directories. If a record already exists for a backup at
the same level, it is replaced.
|
|
v
|
Verify. After each tape or diskette is written, verifies the contents of the
media against the source file system. If any discrepancies occur, prompts the operator
to mount new media, then repeats the process. Use this option only on an unmounted
file system, because any activity in the file system causes the ufsdump command
to report discrepancies.
|
|
w
|
Warning. Lists the file systems that appear in the /etc/dumpdates file that have not been backed up within a day. When you use this option,
all other options are ignored.
|
|
W
|
Warning with highlight. Shows all the file systems that appear in the /etc/dumpdates file and highlights those file systems that have not been
backed up within a day. When you use this option, all other options are ignored.
|
Note –
The /etc/vfstab file does not contain information
about how often to back up a file system.
The ufsdump Command and Security
Issues
If you are concerned about security, you should do the following:
-
Require superuser access for the ufsdump command.
-
Ensure superuser access entries are removed from /.rhosts files on clients and servers if you are doing centralized backups.
For general information on security, see System Administration Guide: Security Services.
Options and Arguments for the ufsrestore Command
The syntax of the ufsrestore command is as
follows:
/usr/sbin/ufsrestore options arguments filenames
|
-
options
-
Is a single string of one-letter option names. You must choose one
and only one of these options: i, r, R, t, or x. The additional options
listed in Table 26–3 are optional.
-
arguments
-
Follows the option string with the arguments that match the options.
The option letters and their associated arguments must be in the same order.
-
filenames
-
Specifies the file or files to be restored as arguments to the x or t options. These arguments must always come last,
separated by spaces.
You must use one (and only one) of the ufsrestore command
options described in the following table.
Table 26–2 One Required Option for the
ufsrestore Command
|
Option
|
Description
|
|
i
|
Interactive. Runs the ufsrestore command in interactive mode.
In this mode, you can use a limited set of shell-like commands to browse the contents
of the media and select individual files or directories to restore. For a list of
interactive commands, see Table 26–4.
|
|
r
|
Recursive. Restores the entire contents of the media into the current working
directory (which should be the top level of the file system). Information used to
restore incremental backups on top of the full backup (for example, restoresymtable) is also included. To completely restore a file system, use this option
to restore the full (level 0) backup and each subsequent incremental backup. Although
this option is intended for a new file system (that was just created with the newfs command), files not on the backup media are preserved.
|
|
R
|
Resume restoring. Prompts for the volume from which to resume restoring and
restarts from a checkpoint. You rerun the ufsrestore command with
this option after a full restore (r option) is interrupted.
|
|
x [filenames]
|
Extract. Selectively restores the files you specify by the filenames argument. filenames can be a list of files
and directories, each separated by a space. All files under a specified directory
are restored unless you also use the h option. If you omit filenames or enter “.” for the root
directory, all files on all volumes of the media (or from standard input) are restored.
Existing files are overwritten, and warnings are displayed.
|
|
t [filenames]
|
Table of contents. Checks the files that are specified in the filenames argument against the media. For each file, lists the full
file name and the inode number (if the file is found) or indicates that the file is
not on the “volume” (meaning any volume in a multivolume backup). If you
do not enter the filenames argument, all files on all volumes
of the media are listed (without distinguishing on which volume files are located).
If you also use the h option, only the directory files that
are specified in filenames, not their contents, are checked
and listed. The table of contents is read from the first volume of the media, or,
if you use the a option, from the specified archive file. This
option is mutually exclusive with the x and r options.
|
Additional ufsrestore options are described in the following
table. These options are optional.
Table 26–3 Additional Options for the
ufsrestore Command
|
Option
|
Description
|
|
a archive-file [filenames]
|
Archive file. Takes the backup table of contents from the specified archive-file instead of from the media (first volume). You can use this
option with the t, i, or x options
to see if files are on the media without having to mount any media. If you use this
option with the x and interactive (i) extract
options, you are prompted to mount the appropriate volume before extracting the file
or files.
|
|
b factor
|
Blocking factor. Specifies number of 512-byte blocks read at a time from a tape.
By default, the ufsrestore command tries to figure out the block
size that was used when the tape was being written to.
|
|
d
|
Debug. Turns on debugging messages.
|
|
f backup-file
|
Backup file. Reads the files from the source indicated by backup-file, instead of from the default device file /dev/rmt/0m.
If you use the f option, you must specify a value for backup-file. When backup-file is of the form system:device, the ufsrestore command reads from
the remote device. You can also use the backup-file argument
to specify a file on a local or remote disk. If thebackup-file consistes
of `-', the files are read from standard input.
|
|
h
|
Turns off directory expansion. Only the directory file you specify is extracted
or listed.
|
|
m
|
Restores specified files into the current directory on the disk, regardless
of where they are located in the backup hierarchy. Also, renames the specified files
with their inode number. For example, if the current working directory is /files, a file in the backup named ./dready/fcs/test with
inode number 42 is restored as /files/42. This option is useful
only when you are extracting a few files.
|
|
s n
|
Skip. Skips to the nth backup file on the media (first
volume). This option is useful when you put more than one backup on a single tape.
|
|
v
|
Verbose. Displays the names and inode numbers of each file as it is restored.
|
|
y
|
Specifies that the command continues when errors occur while reading the media,
trying to skip over bad blocks instead of stopping and asking whether to continue.
This option tells the command to assume a yes response.
|
The following table describes ufsrestore's interactive commands.
Table 26–4 Commands for Interactive Restore
|
Option
|
Description
|
|
ls [directory-name]
|
Lists the contents of either the current directory or the specified directory.
Directories are marked by a / suffix. Entries in the current
list to be restored (extracted) are marked by an * prefix. Inode
numbers are shown if the verbose option (v) is used.
|
|
cd directory-name
|
Changes to the specified directory in the backup hierarchy.
|
|
add [filename]
|
Adds the current directory or the specified file or directory to the list of
files to extract (restore). If you do not use the h option, all
files in a specified directory and its subdirectories are added to the list. All the
files you want to restore to a directory might not be on a single backup tape or diskette.
You might need to restore from multiple backups at different levels to get the latest
versions of all the files.
|
|
delete [filename]
|
Deletes the current directory or the specified file or directory from the list
of files to extract (restore). If you do not use the h option,
all files in the specified directory and its subdirectories are deleted from the list.
The files and directories are deleted only from the extract list you are building.
They are not deleted from the media or the file system.
|
|
extract
|
Extracts the files in the list and restores them relative to the current working
directory on the disk. When you are asked for a volume number for a single-volume
backup, specify 1. If you are doing a multiple tape or multiple
diskette restore and restoring a small number of files, start instead with the last
tape or diskette.
|
|
help
|
Displays a list of commands that you can use in interactive mode.
|
|
pwd
|
Displays the path name of the current working directory in the backup hierarchy.
|
|
q
|
Quits interactive mode without restoring any additional files.
|
|
setmodes
|
Lets you set the mode for files to be restored to match the mode of the root
directory of the file system from which they were backed up. You are prompted with: set owner/mode for '.' [yn]? Type y (for yes) to set
the mode (permissions, owner, times) of the current directory to match the root directory
of the file system from which they were backed up. Use this mode when you restore
a complete file system.
Type n (for no) to leave the mode of the current directory
unchanged. Use this mode when you restore part of a backup to a directory other than
the directory from which the files were backed up.
|
|
verbose
|
Turns on or off the verbose option (which can also be typed as v on
the command line outside of interactive mode). When verbose is on, the interactive ls command lists inode numbers, and the ufsrestore command
displays information on each file as it is extracted.
|
|
what
|
Displays the backup header from the tape or diskette.
|