3    Backing Up and Restoring Data

The AdvFS file system provides extended file system backup capabilities with the vdump and vrestore commands. The rvdump and rvrestore commands provide the same capabilities for remote storage devices. In addition, you can use the AdvFS clonefset utility with the vdump command to back up mounted AdvFS filesets. AdvFS fileset clones provide a static snapshot of files for the backup.

This chapter covers the following:

3.1    Overview

You can use the vdump command to back up AdvFS filesets as well as UFS and other standard file systems. This means that you can have a single backup utility for your facility. The dump and restore commands function differently from the vdump and vrestore commands. The dump command works at the inode level so it can handle only UFS files. The vdump command works at the file level. It scans the directories and uses regular POSIX file system calls to access directories and files. See vdump(8) and vrestore(8) for more information.

In this section only the vdump and vrestore commands are discussed, but the rvdump and rvrestore commands can be substituted for remote operation.

Note

You do not have to be root user to use the vdump and vrestore commands. However, you must have write permission for the directory to which you want to restore files. Only the root user can save and restore the AdvFS quota files and the fileset quotas.

Caution

The vrestore command for operating system versions earlier than Version 4.0 does not properly restore information saved by the vdump command for Version 4.0 or later. The vdump and vrestore dump file formats are compatible in Version 4 and Version 5 operating systems.

3.2    Backing Up Data

The vdump command creates a list of fixed-size blocks, called a saveset, as it copies all files that are new or have changed after a certain date to the default storage device or the device that you specify.

A saveset can span multiple tapes or a tape can contain multiple savesets. Savesets on tapes are delimited by file marks that are written when the vdump command closes the saveset.

The vdump command has the following form:

vdump options mount_point

For example, to dump the filesets mounted at /psm to tape:

# vdump -0 -f /dev/tape/tape0_d1 /psm

3.2.1    Unique Features of the vdump Command

The vdump command has a number of functions that the UFS dump command does not have. You can:

3.2.2    Backup Level

You can specify the level of incremental backup in the vdump command. A value of 0 specifies complete fileset backup. A higher number specifies a less complete backup. The vdump(8) reference page describes a plan that cycles dump levels so that complete backups are saved on two tapes at a time.

Quota files and fileset quotas are saved only when you are root user and you specify level 0 backup. You can only back up quotas for locally-mounted systems.

The vdump command operates by checking the file modification date. This might cause problems on a subsequent incremental backup because the file modification date does not change if you rename or move a file and do not modify the data. Thus, if you back up your files then move or rename them, change the modification date using the touch command:

touch file_name

3.2.3    Dumping to Tape

You can place more than one saveset on a single tape by using the vdump command. Set the -N option to specify no rewind or specify a no-rewind device such as /dev/ntape/tape0. This ensures that the tape does not rewind when the vdump command finishes. Issuing another vdump command causes the next saveset to be stored starting at the current tape position.

To restore data from a tape containing more than one saveset, see Section 3.5.4.

If your saveset requires more than one tape to complete, the vdump command prompts you to mount another.

3.2.4    Dumping to Standard Output

When the backup saveset device is the dash (-) character , the vdump command writes to standard output. Thus, you can use the vdump and vrestore commands in a pipeline expression to copy one fileset to another. The following are typical commands; they are equivalent:

# vdump -0f - /usr | vrestore -xf - -D /mnt

# vdump -0 -f - /usr | (cd /mnt; vrestore -x -f -)

The rvdump and rvrestore commands are unable to use the dash (-) character. The output device must be specified.

3.2.5    Dumping Subdirectories

You can selectively back up individual subdirectories of a fileset by specifying the subdirectory by using the vdump -D command. Without the -D option, if you specify a subdirectory instead of a fileset on the command line, the vdump command backs up the entire fileset that contains the named subdirectory. If you specify the -D option, backup is always run at level 0.

3.2.6    Dumping to a File or Disk Partition

You can store your saveset as a file on disk. This feature is useful if you want to do full weekly backups to tape for archiving and incremental backups to disk for quick access. Saving to disk increases the speed of saving and recovery because disks are faster than tape devices.

For example, Monday evening you can save an incremental backup to a file containing Monday's activity. In this example, projects.Monday is the saved file in the fileset backups that contains the saveset for the fileset mounted on /projects.

# vdump -9f /backups/projects.Monday /projects

To restore the copy of a file, revenue, saved to disk in the backup on Monday:

# vrestore -xf /backups/projects.Monday -D /projects revenue

You can also store your saveset on an empty partition. The saveset will not be available under file system control and could be lost if the partition is reassigned. For example, to dump the fileset mounted at /projects to the partition /dev/disk/dsk2g:

# vdump -f /dev/disk/dsk2g -D /projects

Do not back up to the a or c partition because these partitions include block 0, which contains the disk label. The device driver does not overwrite the disk label. If you use the a or c partition, an error message is displayed only if you are using a character or raw device; block special devices does not return an error. It is better to back up to another disk partition that does not contain block 0 if you have the space.

If you want to use the a or c partition and the rest of the disk is empty, you must first clear the disk label using the disklabel -z command. All prior information that existed on the disk is lost. If you do not clear the disk label, the vdump command might appear to save valid savesets, but when the vrestore command attempts to interpret the disk label as part of the saveset, it returns the following message:

vrestore: unable to use save-set; invalid or corrupt format

This is also true for the rvdump and rvrestore commands.

See disklabel(8), vdump(8), vrestore(8), and System Administration for more information.

If you want to copy a complete disk, see System Administration.

3.2.7    Compressing Savesets

You can compress savesets as they are backed up. This reduces the amount of storage required for the backup and allows the dump to run faster on slow devices because less data is written. Use the vdump -C command to request compression. You cannot specify the compression ratio; it is determined by the contents of the dump.

Note

If you are using a tape drive that automatically does hardware compression, using the vdump command with compression might result in a larger saveset than expected. Sometimes, due to compression algorithms, already compressed data gets expanded when an attempt is made to do more compression.

3.2.8    Dumping with Error Protection

You can use the vdump -x command to place checksum blocks on your tape so that the vrestore command can recover damaged blocks. The vdump command creates these blocks every n number of blocks you specify. The valid range of n is 2 to 32; the default is 8. If the vrestore command detects a read error in a block, it uses the other blocks and the checksum block to recreate the bad block.

Dumping with error protection requires saving one extra block for every n blocks. It can correct only one block in each series of n blocks when the blocks are restored. This means there is a trade-off:

3.2.9    Listing Saved Files

You can check your saveset and make sure you have backed up the files you intended. After your backup is complete, run the vrestore -t command to display the files you have saved. This does not initiate the restore procedure.

3.2.10    Dumping and Restoring Files Remotely

The rvdump command backs up files from a single mounted fileset or an AdvFS fileset clone to a remote storage device. You must be able to execute the rsh command on the remote node to which you are dumping. See rsh(8) for server and client access rules.

The rvdump command has the same options as the vdump command, but you must specify the node name for the device that you are backing your files to. The following example dumps a fileset sar to a tape on node rachem:

# rvdump -0f rachem:/dev/tape/tape0 /sar

To restore the fileset from the remote tape drive, enter:

# rvrestore -xf rachem:/dev/tape/tape0 -D /sar

3.3    Cloning for Online Backup

An AdvFS fileset clone is a read-only snapshot of the data in an existing fileset. If you have the optional AdvFS Utilities, you can create a clone. You must be the root user to clone the root fileset.

A clone does not contain all the data at the time it is created. Rather, it is an outline of the data structure. Data in the original fileset that remains unchanged over the life of the clone is never saved in the fileset clone. When you modify the data in your original files, AdvFS saves the data that existed in the original, page by page, into the clone.

You can create a fileset clone for any AdvFS fileset with the command-line interface (see Section 1.7.11) or with the AdvFS GUI (see Section D.4.3). You cannot clone UFS file systems. Only one clone can exist per fileset.

A clone is useful if the files in your system are changing during the time you want to do your backup. It reflects the state of your system at the moment it was created and backing it up does not interfere with current processing.

Note

After you finish your backup, delete the clone. Clones of active filesets continue to grow as the files are changed.

The following example backs up the pssm fileset on line by creating the pssm_clone fileset and backing it up to the default device. The domain in this example is domain1.

# clonefset domain1 pssm pssm_clone
# mkdir /pssm_clone
# mount -t advfs domain1#pssm_clone /pssm_clone
# vdump -0 -u -C /pssm_clone

To remove the pssm_clone fileset, enter:

# umount /pssm_clone
# rmfset domain1#pssm_clone

3.4    Cloning to Back Up Databases

If your database has an online backup utility, use it to back up the database. If it does not, you can back up databases with database down time limited to the short time it takes to create the fileset clone. Backing up a database with an AdvFS fileset clone is the same as backing up any other fileset. You get the same benefits (see Section 3.3).

To back up a database with a clone:

  1. Shut down the database so that all database buffers are flushed and the fileset has a complete, consistent copy of the database files.

  2. Clone the fileset and mount the clone.

  3. Reactivate the database.

  4. When you want to back up the fileset clone, run a backup procedure.

  5. Unmount and delete the clone.

Caution

Use only the database's own utilities to back up an active database. You can use the vdump and vrestore commands on a fileset clone that contains the database.

If your database files are spread over multiple AdvFS filesets, you should create a clone on each fileset at the same time. This ensures a consistent back up of all the database information.

3.5    Restoring Data

The vrestore command restores files by processing the blocks from a saveset created by using the vdump command. The vrestore command does not work on a saveset created by the UFS dump command.

You do not have to be root user to run the vrestore command, but you must have write privilege for the directory you restore to. Only the root user can restore quota files and fileset quotas. See vrestore(8) for details.

3.5.1    Unique Features of the vrestore Command

The vrestore command performs a number of activities that the UFS restore command does not. You can:

3.5.2    Restoring Files

The vrestore command allows you to select specific files and directories to be restored. It can restore data from a file, a pipe, magnetic tapes, or disks.

Use the same version of the vdump and vrestore utilities. If your version of the vrestore utility is unable to read the format of your saveset, you get an error message.

Before you run the vrestore command, you can list the names and sizes of all files in the saveset by running the command using the -t option. The restore operation is not performed.

You can also display the files and directories saved by running the vrestore -i command. You can select individual files or directories to restore.

Restoring data from an AdvFS fileset clone is the same as restoring data from any other fileset.

Start with the full backup if you are restoring an entire fileset. Then restore later incremental backups on top of this to retrieve files that have changed since the full backup was created. Files that were deleted after the full backup was performed are restored. It is necessary to delete these files manually.

3.5.3    Restoring Quotas

You can restore AdvFS user and group quota files either to an AdvFS fileset or to a UFS file system. If you are restoring AdvFS quota files to a UFS file system, quotas must be activated on the UFS file system. AdvFS fileset quotas cannot be restored to a UFS file system because there is no UFS analog to AdvFS fileset quotas. You must be root user to restore quotas.

3.5.4    Restoring from a Tape with Many Savesets

To restore to the current working directory from a tape containing multiple savesets, use the mt fsf n command (forward space n savesets or files) option to locate the saveset you want to restore. Then use the vrestore command.

The following example selects and restores the fourth saveset on a tape:

# mt fsf 3
# vrestore -xf /dev/ntape/tape0

If you do not know the location of the saveset directory you want to restore, run the vrestore -i command. When you have reached the saveset you want, use the interactive shell to specify the files you want to retrieve.

You can use the vrestore -x command followed by the file names to selectively restore files from your saveset. You can specify a destination path other than the current directory for the restored files.

The following example restores the file named data_file from the /mnt/fdump saveset. It is restored to the /mnt directory.

# vrestore -f /mnt/fdump -D /mnt -x data_file
vrestore: Date of the vdump save-set: Sat Jun 20 15:27:36 2001
 

If your restore operation requires more than one tape, the vrestore utility notifies you to mount another.

3.6    AdvFS and NetWorker

NetWorker for Tru64 UNIX provides scheduled, online, automated backup. Use NetWorker with AdvFS as a comprehensive backup solution. NetWorker can automatically back up multiple servers in a heterogeneous environment. It has a graphical interface and several scheduling options.

If users will access filesets during the backup process, use the AdvFS clonefset utility to clone all filesets for backup and mount the fileset clones. (You can create a script to accomplish this task.) Then, set up NetWorker to automatically back up the fileset clones on a convenient schedule.