Go to main content

Managing File Systems in Oracle® Solaris 11.4

Exit Print View

Updated: November 2020

Backing Up and Restoring UFS File Systems

This section describes how to backup and restore a UFS file system using the ufsdump and ufsrestore commands. This section also describes how to copy files and file systems using the cpio, tar, and pax commands.

How the ufsdump Command Works

The ufsdump command performs two passes to back up a file system. During the first pass, this command scans the raw device file for the file system, builds a table of directories and files in the memory, and writes the table to a backup media. During the second pass, the ufsdump command goes through the inodes in numerical order, reads the file contents and writes the data to the backup media.

The ufsdump command writes a sequence of fixed-size records. When the ufsdump command receives a notification that a record was partially written, the command assumes that it has reached the physical end of a 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.

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 multi-volume backups.

You need to use the end-of-media options when the ufsdump command does not understand the way the device detects the end-of-media.

To ensure compatibility with the ufsrestore command, the size option can still force the ufsdump command to go to the next removable media before reaching the end of the current media.

Copying Data Using 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 might not be copied. The backup done by the ufsdump command neither copies for free blocks, nor makes an image of the disk slice. If symbolic links point to files on other slices, the link itself is copied. For more information, see the ufsdump(8) man page.

Purpose of the /etc/dumpdates File

You can use the –u option with the ufsdump command to maintain and update the /etc/dumpdates file. Each line in the /etc/dumpdates file shows the following information:

  • Backed up file system

  • Dump level of the last backup

  • Day, date, and time of the backup

A sample of the /etc/dumpdates file is as follows:

# cat /etc/dumpdates
/dev/rdsk/c0t0d0s0               0 Wed Jul 7 13:36:17 2016
/dev/rdsk/c0t0d0s7               0 Thu Jul 8 12:53:12 2016
/dev/rdsk/c0t0d0s7               9 Thu Jul 8 13:41:48 2016

When performing 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. The command then copies all the files that were modified since the date of that lower-level backup to the media. 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 performed. This verification is particularly important if you are having equipment problems. If a backup cannot be completed because of an equipment failure, the backup is not recorded in the /etc/dumpdates file.

If you want 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 in which tape you need to restore the entire file system.

Caution  -  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 Using the 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 devices:

  • Local tape drive

  • Remote tape 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 the dump_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 Drive Backup

Typically, the dump_file argument specifies a raw device file for a tape device. When the ufsdump command writes to an output device, it creates a single backup file that might span multiple tapes.

You can specify a tape device on your system by using a device abbreviation. The first device is always 0. For example, if you have a LTO7 tape connected to a SAS HBA, use the device name, /dev/rmt/0.

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 complete. For example, /dev/rmt/0n.

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.

Remote Tape Drive Backup

You can specify a remote tape device 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 a 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.

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) cannot be used to verify a dump to standard output.

In a pipeline, you can use the ufsdump command to copy a file system by writing to a standard output, and use the ufsrestore command to read from a standard input. For example:

# ufsdump 0f - /dev/rdsk/c0t0d0s7 | (cd /home; ufsrestore xf -)

Specifying Files to Back Up

You must always include file names as the last argument on the command line. This argument specifies the source or content of the backup.

For a file system, specify the raw device file as /dev/rdsk/c0t0d0s7.

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.

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 has the following limitations:

  • Automatically calculates the number of tapes 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.

  • Provides built-in error checking to minimize problems when it backs up an active file system.

  • Backs 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 that they own, which are located on a server.