System Administration Guide, Volume I

Part IX Backing Up and Restoring Data

This part provides instructions for backing up and restoring data in the Solaris environment. This part contains these chapters.

Chapter 33, Backing Up and Restoring File Systems (Overview)

Provides guidelines and planning information on backing up and restoring data using the ufsdump and ufsrestore commands.

Chapter 34, Backing Up Files and File Systems (Tasks)

Provides step-by-step instructions for backing up individual files and complete file systems from local or remote devices.  

Chapter 35, Restoring Files and File Systems (Tasks)

Provides step-by-step instructions for restoring individual files and complete file systems.  

Chapter 36, The ufsdump and ufsrestore Commands (Reference)

Describes how ufsdump works, and the syntax and options for the ufsdump and ufsrestore commands.

Chapter 37, Copying UFS Files and File Systems (Tasks)

Provides step-by-step instructions for copying file systems to disk, for using the dd, cpio, and tar commands with different backup media, and copying files with a different header format.

Chapter 38, Managing Tape Drives (Tasks)

Provides step-by-step instructions for how to add a tape drive, how to determine the type of tape drive, backup device names, and working with tape drives and magnetic tape cartridges.  

Chapter 33 Backing Up and Restoring File Systems (Overview)

This chapter provides guidelines and planning information on backing up and restoring complete file systems using the ufsdump and ufsrestore commands.

This is a list of overview information in this chapter.

Where to Find Backup and Restore Tasks

Use these references to find step-by-step instructions for backing up and restoring file systems (using the ufsdump and ufsrestore commands).

Definition: Backing Up and Restoring File Systems

Backing up file systems means copying file systems to removable media (such as tape) to safeguard against loss, damage, or corruption. Restoring file systems means copying reasonably-current backup files from removable media to a working directory.

This chapter describes the commands for scheduled backup and restore operations (ufsdump and ufsrestore); however, there are other commands you can use for copying files and file systems for sharing or transporting files. Table 33-1 provides pointers to all commands that copy individual files and/or file systems to media.

Table 33-1 Commands for Copying Files and File Systems

If You Want To ... 

Then Use ... 

And Go To ... 

Back up complete or individual file systems to a local or remote tape device 

ufsdump(1M) command

Chapter 34, Backing Up Files and File Systems (Tasks) or Chapter 36, The ufsdump and ufsrestore Commands (Reference)

Back up complete file systems for all systems on a network from a server 

Solstice BackupTM software

Solstice Backup 5.1 Administration Guide

Backup and restore a NIS+ master server 

nisbackup(1M) and nisrestore(1M) commands

Solaris Naming Administration Guide

Copy, list, and retrieve files on tape 

Copy, list, and retrieve files on diskette 

tar(1), cpio(1), or pax(1) command

tar(1) command

Chapter 37, Copying UFS Files and File Systems (Tasks)

Copy master disk to a clone disk 

dd(1M) command

Chapter 37, Copying UFS Files and File Systems (Tasks)

Restore complete file systems or individual files from removable media to a working directory 

ufsrestore(1M) command

Chapter 35, Restoring Files and File Systems (Tasks)

Why You Should Back Up File Systems

Backing up files is one of the most crucial system administration functions. You should perform regularly-scheduled backups to prevent loss of data due to:

Choosing a Tape Device

Table 33-2 shows typical tape devices used for storing file systems during the backup process. For more detailed information on tape devices, see Chapter 38, Managing Tape Drives (Tasks).

Table 33-2 Typical Media for Backing Up File Systems

Media 

Capacity [Capacity depends on the type of drive and the data being written to the tape.]

1/2-inch reel tape 

140 Mbytes (6250 bpi) 

2.5-Gbyte 1/4 inch cartridge (QIC) tape 

2.5 Gbytes 

DDS3 4-mm cartridge tape (DAT) 

12 - 24 Gbytes 

14-Gbyte 8-mm cartridge tape 

14 Gbytes 

DLTTM 7000 1/2-inch cartridge tape

35 - 70 Gbytes 

Planning Which File Systems to Back Up

You should back up any file systems that are critical to users, including file systems that change frequently. Table 33-3 and Table 33-4 provide general guidelines on the file systems to back up for standalone systems and servers.

Table 33-3 File Systems to Back Up for Standalone Systems

Consider Backing Up These File Systems [Use the df command or look at /etc/vfstab file to find out on which slice a file system is located.] ...

Because ... 

And At This Interval ... 

root (/) - partition 0 [Indicates file systems created by default when installing Solaris software.]

The root (/) file system contains the kernel and may contain the /var directory in which frequently modified files such as mail and accounting are kept.

At regular intervals. 

/usr - partition 62, /opt

Installing new software and adding new commands typically affects the /usr and /opt file systems. /opt is either part of root (/) or is its own file system.

Occasionally. 

/export/home

The /export/home file system contains directories and subdirectories of all users on the standalone system.

More often than root (/) or /usr, perhaps as often as once a day, depending on your site needs.

/export , /var, or other file systems

During installation of Solaris software, you may have created these file systems.  

As your site requires. 

Table 33-4 File Systems to Back Up for Servers

Consider Backing Up These File Systems [Use the df command or look at /etc/vfstab file to find out on which slice a file system is located.] ...

Because ... 

And at This Interval ... 

root (/) - partition 0 [Indicates the file systems created by default when installing Solaris software.]

/export - partition 32

/usr - partition 62

These file systems contain the kernel, major commands, and executables. 

Once a day to once a month depending on your site's needs.  

root (/) - if you frequently add and remove clients and hardware on the network, you have to change important files in root (/), including the kernel configuration file. In this case, you should do a full back up on the root (/) file system between once a week and once a month. If your site keeps users' mail in the /var/mail directory on a mail server (which client systems then mount), you may want to back up root (/) daily (or /var, if it is a separate file system).

/export - the root (/) directory of diskless clients is kept in the /export file system. Because the information it contains is similar to the server's root directory in slice 0, it does not change frequently. You need to back up only occasionally, unless your site delivers mail to client systems; then you should back up /export more frequently.

/usr and /opt - contents are fairly static and only need to be backed up once a week to once a month.

/export/home - partition 72

The /export/home file system contains the home directories and subdirectories of all the users on the system; its files are volatile.

Once a day to once a week. 


Note -

You do not need to back up a server's /export/swap file system.


Overview of the Backup and Restore Commands

The ufsdump and ufsrestore commands are the recommended commands for scheduled backups of complete file systems. Table 33-5 lists the tasks you can perform with them. For information on how these commands work and their syntax, see Chapter 36, The ufsdump and ufsrestore Commands (Reference).

Table 33-5 Tasks You Can Perform With the ufsdump and ufsrestore Commands

With This Command ... 

You Can ... 

Comments 

ufsdump

Back up complete or partial file systems to local or remote tape drives 

The tape device can be on any system in the network to which the user has access. This command works quickly because it is aware of the structure of the UFS file system type, and works directly through the raw device interface. 

 

Back up incremental file system changes 

This enables you to back up only those files that were changed since a previous backup. 

 

Back up groups of systems over the network from a single system 

 

You can run ufsdump from one system on each remote system through a remote shell or remote login, and direct the output to the system on which the drive is located. Or, you can pipe the output to the dd command or a file.

 

Automate backups 

 

Use the crontab utility to run a script that starts the ufsdump command.

 

Restrict user access to backup tables 

Use the -a option.

 

Determine the size of a backup without actually doing the backup 

Use the -S option.

 

Keep a log of when each file system was backed up 

Use the -u option.

 

Verify the contents of the tape against the source file system 

Use the -v option.

ufsrestore

Restore individual or complete file systems from a local or remote tape drive 

 

Choosing the Type of Backup

With the ufsdump command, you can perform full or incremental backups. Table 33-6 lists the differences between these types of backup procedures.

Table 33-6 Differences Between Full and Incremental Backups

Backup Type 

Copies 

Advantages 

Disadvantages 

Full 

A complete file system or directory

Everything is in one place 

Requires large numbers of backup tapes that take a long time to write. Takes longer to retrieve individual files because the drive has to move sequentially to the point on the tape where the file is located. May have to search multiple tapes. 

Incremental 

Only files in the specified file system that have changed since a previous backup

Easier to retrieve small changes in file systems 

Finding which incremental tape contains a file can take time. May have to go back to last full dump. 

Guidelines For Scheduling Backups

A backup schedule is the schedule you establish to run the ufsdump command. This section provides guidelines on the factors to weigh when creating a backup schedule, guidelines on how often to back up file systems, and sample backup schedules.

What Drives a Backup Schedule

The schedule you create depends on:

How Often Should You Do Backups?

If you do not need to minimize time and media spent on backups, you can do full backups every day. However, this is not realistic for most sites, so incremental backups are most often used. In this case, it is recommended that you back up your site enough to restore files from the last four weeks. This requires at least four sets of tapes--one for each week, which you would reuse each month. In addition, you should archive the monthly backups for at least a year, and then keep yearly backups for a number of years.

Using Dump Levels to Create Incremental Backups

The dump level you specify in the ufsdump command (0-9) determines which files are backed up. Specifying dump level 0 creates a full backup. Numbers 1-9 are used to schedule incremental backups, but have no defined meanings. Numbers 1-9 are just a range of numbers used to schedule cumulative or discrete backups. The only meaning levels 1-9 have is in relationship to each other, as a higher or lower number.

The following examples show the flexibility of the incremental dump procedure using levels 1-9.

Dump Levels For Daily, Cumulative Backups

Doing daily, cumulative incremental backups is the most commonly used backup scheme and is recommended for most situations. The following example shows a schedule using a level 9 dump each day, and a level 5 dump on Friday to restart the process.


Note -

In the following example, you could have used other numbers in the 1-9 range to produce the same results. The key is having the same number each day, with any lower number on Friday. For example, you could have specified levels 4, 4, 4, 4, 2 or 7, 7, 7, 7, 5.


Figure 33-1 Incremental Backup: Daily Cumulative

Graphic

Dump Levels For Daily, Discrete Backups

The following example shows a schedule where you capture only a day's work on different tapes. In this case, sequential dump level numbers are used during the week (3,4,5,6) with a lower number (2) on Friday.


Note -

In the following example, you could have used the sequence 6,7,8,9 followed by 2, or 5,6,7,8 followed by 3. Remember, the number themselves have no defined meaning; you attribute meaning by ordering them in a high/low sequence.


Figure 33-2 Incremental Backup: Daily Discrete

Graphic

Sample Backup Schedules

This section provides sample backup schedules. All schedules assume you begin with a full backup (level 0), and that you use the -u option to record each backup.

Example--Daily Cumulative, Weekly Cumulative Backups

Table 33-7 shows the most commonly used incremental backup schedule; it is recommended for most situations. With this schedule:

Table 33-7 Daily Cumulative/Weekly Cumulative Backup Schedule
 

Floating 

Mon 

Tues 

Wed 

Thurs 

Fri 

1st of Month 

 

 

 

 

 

Week 1  

 

Week 2  

 

9  

Week 3  

 

9  

9  

Week 4 

 

Table 33-8 shows how the contents of the tapes can change across two weeks using the previous schedule. Each letter represents a different file.

Table 33-8 Contents of Tapes for Daily/Weekly Cumulative Schedule
 

Mon 

Tues 

Wed 

Thurs 

Fri 

Week 1  

a b 

a b c 

a b c d 

a b c d e 

a b c d e f 

Week 2  

g h 

g h i 

g h i j 

a b c d e f g h i j k 

Tape Needs

With this schedule, you will need six tapes (if you want to reuse daily tapes), or nine tapes (if you want to use four different daily tapes): one for the level 0, four for the Fridays, and one or four daily tapes.

If you need to restore a complete file system, you will need the following tapes: the level 0, the most recent Friday tape, and the most recent daily tape since the last Friday tape (if any).

Example--Daily Cumulative, Weekly Incremental Backups

Table 33-9 shows a schedule where each weekday tape accumulates all files that changed since the beginning of the week (or the initial level 0 for the first week), and each Friday's tape contains all the files changed that week.

Table 33-9 Daily Cumulative/Weekly Incremental Backup Schedule
 

Floating 

Mon 

Tues 

Wed 

Thurs 

Fri 

1st of Month 

 

 

 

 

 

Week 1  

 

Week 2  

 

9  

Week 3  

 

9  

9  

Week 4 

 

Table 33-10 shows how the contents of the tapes can change across two weeks using the previous schedule. Each letter represents a different file.

Table 33-10 Contents of Tapes for Daily Cumulative/Weekly Incremental Backup Schedule
 

Mon 

Tues 

Wed 

Thurs 

Fri 

Week 1  

a b 

a b c 

a b c d 

a b c d e 

a b c d e f 

Week 2  

g h 

g h i 

g h i j 

g h i j k 

Tape Needs

With this schedule, you will need six tapes (if you want to reuse daily tapes), or nine tapes (if you want to use four different daily tapes): one for the level 0, four for the Fridays, and one or four daily tapes.

If you need to restore a complete file system, you will need the following tapes: the level 0, all the Friday tapes, and the most recent daily tape since the last Friday tape (if any).

Example--Daily Incremental, Weekly Cumulative Backups

Table 33-11 shows a schedule where each weekday tape contains only the files changed since the previous day, and each Friday's tape contains all files changed since the initial level 0 at the beginning of the month.

Table 33-11 Daily Incremental/Weekly Cumulative Backup Schedule
 

Floating 

Mon 

Tues 

Wed 

Thurs 

Fri 

1st of Month 

 

 

 

 

 

Week 1  

 

Week 2  

 

Week 3  

 

Week 4 

 

Table 33-12 shows how the contents of the tapes can change across two weeks using the previous schedule. Each letter represents a different file.

Table 33-12 Contents of Tapes for Daily/Weekly Cumulative Backup Schedule
 

Mon 

Tues 

Wed 

Thurs 

Fri 

Week 1  

a b 

c d 

e f g 

hi 

a b c d e f g h i 

Week 2  

j k l 

n o 

p q 

a b c d e f g h i j k l m n o p q r s 

Tape Needs

With this schedule you will need at least nine tapes (if you want to reuse daily tapes--not recommended), or 21 tapes (if you save weekly tapes for a month): one for the level 0, four for the Fridays, and four or 16 daily tapes.

If you need to restore the complete file system, you will need the following tapes: the level 0, the most recent Friday tape, and all the daily tapes since the last Friday tape (if any).

Example--Backup Schedule for a Server

Table 33-13 shows an example backup strategy for a heavily-used file server on a small network where users are doing file-intensive work, such as program development or document production. It assumes that the backup period begins on a Sunday and consists of four seven-day weeks.

Table 33-13 Schedule of Backups for a Server Example

Directory 

Date 

Level 

Tape Name 

root (/)

1st Sunday 

n tapes

/usr

1st Sunday 

"  

/export

1st Sunday 

"  

/export/home

1st Sunday 

"  

 

1st Monday 

 

1st Tuesday 

 

1st Wednesday 

 

1st Thursday 

 

1st Friday 

 

1st Saturday 

root (/)

2nd Sunday 

n tapes

/usr

2nd Sunday 

"  

/export

2nd Sunday 

"  

/export/home

2nd Sunday 

"  

 

2nd Monday 

G  

 

2nd Tuesday 

H  

 

2nd Wednesday 

I  

 

2nd Thursday 

J  

 

2nd Friday 

 

2nd Saturday 

L  

root (/)

3rd Sunday 

n tapes  

/usr

3rd Sunday 

"  

/export

3rd Sunday 

"  

/export/home

3rd Sunday 

"  

 

3rd Monday 

 

3rd Tuesday 

N  

 

3rd Wednesday 

O  

 

3rd Thursday 

 

3rd Friday 

 

3rd Saturday 

root (/)

4th Sunday 

n tapes  

/usr

4th Sunday 

"  

/export

4th Sunday 

"  

/export/home

4th Sunday 

"  

 

4th Monday 

 

4th Tuesday 

 

4th Wednesday 

 

4th Thursday 

 

4th Friday 

 

4th Saturday 

With this plan, you use 4n tapes (the number of tapes needed for four full backups of root (/), /usr, /export, and /export/home), plus 24 additional tapes for the incremental backups of /export/home. This plan assumes that each incremental backup uses one tape and you save the tapes for a month.

Here's how this plan works:

  1. On each Sunday, do a full backup (level 0) of root (/), /usr, /export, and /export/home. Save the level 0 tapes for at least 3 months.

  2. On the first Monday of the month, use tape A to do a level 9 backup of /export/home. ufsdump copies all files changed since the previous lower-level backup (in this case, the level 0 backup that you did on Sunday).

  3. On the first Tuesday of the month, use tape B to do a level 9 backup of /export/home. Again, ufsdump copies all files changed since the last lower-level backup--Sunday's level 0 backup.

  4. On the first Wednesday, use tape C to do a level 5 backup. ufsdump copies all files changed since Sunday.

  5. Do the Thursday and Friday level 9 backups on tapes D and E. ufsdump copies all files changed since the last lower-level backup--Wednesday's level 5 backup.

  6. On the first Saturday of the month, do a level 5 backup of /export/home, which copies all files changed since the previous lower-level backup--in this case, the level 0 backup you did on Sunday. Store tapes A-F until the first Monday of the next 4-week period, when you use them again.

  7. Repeat steps 1-6 for the next three weeks, using tapes G-L and 4n tapes for the level 0 on Sunday, and so on.

  8. For each 4-week period, repeat steps 1-7, using a new set of tapes for the level 0s and reusing tapes A-X for the incremental backups. The level 0 tapes could be reused after 3 months.

    This plan lets you save files in their various states for a month. It requires many tapes, but ensures that you have a library of tapes to draw upon. To reduce the number of tapes, you could reuse Tapes A-F each week.

Other Backup Scheduling Suggestions

Table 33-14 provides other suggestions for scheduling backups.

Table 33-14 Other Suggestions for Scheduling Backing Up Systems

If You ... 

Then ... 

Comments 

Need to restore different versions of files (for example, file systems used for word processing) 

  • Do daily incremental backups every working day.

  • Do not reuse the same tape for daily incremental backups.

This schedule saves all files modified that day, as well as those files still on disk that were modified since the last backup of a lower level. However, with this schedule you should use a different tape each day because a file changed on Tuesday, and again on Thursday, goes onto Friday's lower-level backup looking like it did Thursday night--not Tuesday night. If a user needs the Tuesday version, you cannot restore it unless you have a Tuesday backup tape (or a Wednesday backup tape). Similarly, a file that is present on Tuesday and Wednesday, but removed on Thursday, does not appear on the Friday lower-level backup. 

Need to quickly restore a complete file system 

Do lower-level backups more frequently. 

-- 

Are backing up a number of file systems on the same server 

Consider offsetting the schedule for different file systems. 

This way you're not doing all level 0 backups on the same day. 

Need to minimize tapes 

Increase the level of incremental backups done across the week.  

This means only changes from day to day are saved on each daily tape.  

 

Increase the level of backups done at the end of the week.  

This means only changes from week to week (rather than the entire month) are saved on the weekly tapes.  

 

Put each day's and week's incremental backups onto the same tape. 

This is done by using the no rewind option in the ufsdump command.

 

Chapter 34 Backing Up Files and File Systems (Tasks)

This chapter describes the procedures for backing up file systems using the ufsdump command.

This is a list of the step-by-step instructions in this chapter.

For detailed information on syntax, options, and arguments for the ufsdump command, see Chapter 36, The ufsdump and ufsrestore Commands (Reference).

Preparing to Do Backups

Preparing to back up file systems begins with planning, which is described in Chapter 33, Backing Up and Restoring File Systems (Overview) and covers choosing:

This section describes other tasks you may need to perform before backing up file systems including:

How to Find File System Names

  1. Display the contents of the /etc/vfstab file.


    $ more /etc/vfstab
    
  2. Look in the mount point column for the name of the file system.

  3. You will use the mount point in the mount point column when you back up the file system.

Example--Finding File System Names


$ more /etc/vfstab
#device         device            mount    FS   fsck  mount  mount
#to mount       to fsck           point    type pass at boot options
#
/proc             -                  /proc proc   -    no      -
swap              -                  /tmp  tmpfs  -    yes     -
/dev/dsk/c0t3d0s0 /dev/rdsk/c0t3d0s0 /     ufs    1    no      -
/dev/dsk/c0t3d0s1 -                  -     swap   -    no      -
/dev/dsk/c0t1d0s6 /dev/rdsk/c0t1d0s6 /usr  ufs    2    no      -
mars:/share/kit -                    /kit  nfs    -    yes     -
mars:/db/doc    -                  /db/doc nfs    -    yes     -

How to Determine the Number of Tapes for a Full Backup

  1. Become superuser.

  2. Estimate the size of the backup in bytes by using the usfdump S command.


    # ufsdump S filesystem
    

    S

    Displays the estimated number of bytes needed to do the backup. 

  3. Divide the estimated size by the capacity of the tape to see how many tapes you need.

    See Table 33-2 for a list of tape capacities.

Example--Determining Number of Tapes

In this example, the file system of 489,472 bytes will easily fit on a 150-Mbyte tape.


# ufsdump S /export/home
489472

Doing Backups

The following are general guidelines for performing backups:


Note -

Use the nisbackup command to backup a NIS+ master server running the Solaris 2.5 release or compatible versions. See Solaris Naming Administration Guide for information on using this command.


How to Do Backups to Tape

The following steps provide the general steps for backing up file systems using the ufsdump command. The examples show specific uses of options and arguments.

  1. Become superuser.

  2. Bring the system to run level S (single-user mode).


    # shutdown -g30 -y
    
  3. [Optional] Check the file system for consistency with the fsck command.

    Running the fsck -m command checks for consistency of file systems. For example, power failures can leave files in an inconsistent state. For more information on the fsck command, see Chapter 31, Checking File System Integrity.


    # fsck -m /dev/rdsk/ device-name
    
  4. If you need to back up file systems to a remote tape drive:

    1. On the system to which the tape drive is attached (the tape server), add the following entry to its /.rhosts file.


      host root

      host

      Specifies the name of the system on which you will run ufsdump to perform the backup.

    2. On the tape server, verify that the host added to the /.rhosts file is accessible through the name service.

  5. Identify the device name of the tape drive.

    The default tape drive is /dev/rmt/0.

  6. Insert a tape that is not write protected into the tape drive.

  7. Back up file systems using the ufsdump command.

    Use the following table to select the most common options and arguments for the ufsdump command. See Chapter 36, The ufsdump and ufsrestore Commands (Reference) for other options and arguments.

    To ... 

    Use This Option or Argument ... 

    For Example ... 

    See ... 

    Do a full backup 

    0 option  

    ufsdump 0ucf /dev/rmt/0 /

    "Example--Full Backup, root (/)"

    Do an incremental backup 

    1-9 option  

    ufsdump 9ucf /dev/rmt/0 /

    "Example--Incremental Backup, root (/) "

    Back up individual files 

    Specify a file or directory 

    ufsdump ucf /dev/rmt/0 /export/home/kryten

     

    Record dumps to /etc/dumpdates file

    -u option

    ufsdump 9ucf /dev/rmt/0 /export/home

    "Example--Incremental Backup, root (/) "

    Specify a cartridge tape 

    -c option

    ufsdump 9ucf /dev/rmt/0 /export/home

    "Example--Incremental Backup, root (/) "

    Specify the tape drive 

    -f dump-file

    ufsdump 9ucf /dev/rmt/0 /export/home

    "Example--Incremental Backup, root (/) "

    Back up local file systems to a remote system's tape device 

    remote-system:dump-file

    ufsdump 0ucf pluto:/dev/rmt/0 /export/home

    "Example--Full Backup to Remote System (Solaris 2.6 Data to Solaris 7 System)"

  8. If prompted, remove the tape and replace with the next volume.

  9. Label each tape with the volume number, level, date, system name, disk slice, and file system.

  10. Bring the system back to run level 3 by pressing Control-d.

  11. Verify the backup was successful by using the ufsrestore command to display the tape contents.

    This command is described in Chapter 35, Restoring Files and File Systems (Tasks).

Example--Full Backup, root (/)

The following example shows a full backup of the root (/) file system to a QIC-150 tape (/dev/rmt/0).


# shutdown -g30 -y
# ufsdump 0ucf /dev/rmt/0 /
   DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Jun 09 10:14:54 1998
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s0 (pluto:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 73708 blocks (35.99MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 73582 blocks (35.93MB) on 1 volume at 100 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Tue Jun 09 10:14:54 1998
# ufsrestore tf /dev/rmt/0
         2	.
         3	./lost+found
      5696	./usr
     11392	./export
     17088	./export/home
     22784	./export/root
     28480	./export/swap
     34176	./opt
     39872	./var
     45568	./var/sadm
     51264	./var/sadm/install
     56960	./var/sadm/install/admin
     57011	./var/sadm/install/admin/default
                      .
                      .
                      .
# 
(Press Control-d to bring system to run level 3)

Example--Incremental Backup, root (/)

The following example shows an incremental backup of the root (/) file system to a 4-mm DAT tape (/dev/rmt/0).


# ufsdump 9ucf /dev/rmt/0 /
DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 9 dump: Tue Jun 09 11:04:41 1998
  DUMP: Date of last level 0 dump: Tue Jun 09 10:14:54 1998
  DUMP: Dumping /dev/rdsk/c0t3d0s0 (pluto:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 1502 blocks (751KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 1384 blocks (692KB) on 1 volume at 51 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 9 dump on Tue Jun 09 11:04:41 1998
# ufsrestore tf /dev/rmt/0
     39872	./var
     62671	./var/adm
     39915	./var/adm/sa
     40018	./var/adm/sa/sa09
     62810	./var/adm/sulog
     62888	./var/adm/pacct
     91154	./var/cron
     91311	./var/cron/log
      5716	./var/mail
      5835	./var/mail/adm
     45585	./var/spool
     51388	./var/spool/mqueue
     91155	./var/tmp
			.
			.
			.

Example--Full Backup, Individual Home Directory

The following example shows a full backup of the /export/home/kryten directory to a 4-mm DAT tape.


# ufsdump 0ucf /dev/rmt/0 /export/home/kryten
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Jun 09 11:12:44 1998
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (pluto:/export/home) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 232 blocks (116KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 124 blocks (62KB) on 1 volume at 8 KB/sec
  DUMP: DUMP IS DONE
# ufsrestore tf /dev/rmt/0
         2	   .
      2688	   ./kryten
      5409	   ./kryten/letters
      5410	   ./kryten/letters/letter1
      5411	   ./kryten/letters/letter2
      5412	   ./kryten/letters/letter3
      2689	   ./kryten/.profile
      8096	   ./kryten/memos
        30	   ./kryten/reports
        31	   ./kryten/reports/reportA
        32	   ./kryten/reports/reportB
        33	   ./kryten/reports/reportC
#

Example--Full Backup to Remote System (Solaris 2.6 Data to Solaris 7 System)

The following example shows a full backup of a local /export/home file system on a Solaris 2.6 system to a tape device on a remote Solaris 7 system called pluto.


# ufsdump 0ucf pluto:/dev/rmt/0 /export/home
  # ufsdump 0ucf pluto:/dev/rmt/0 /export/home
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Jun 09 13:54:27 1998
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (venus:/export/home) to pluto:/dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 38310 blocks (18.71MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 38302 blocks (18.70MB) on 1 volume at 98 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Tue Jun 09 13:54:27 1998
# # ufsrestore tf pluto:/dev/rmt/0
         2	.
         3	./lost+found
     34180	./kryten
     34182	./kryten/.login
     34183	./kryten/.cshrc
     51266	./kryten/letters
     51272	./kryten/letters/letter1
     51273	./kryten/letters/letter2
     51274	./kryten/letters/letter3
     57032	./kryten/memos
     74095	./kryten/reports
     74096	./kryten/reports/reportA
     74097	./kryten/reports/reportB
     74098	./kryten/reports/reportC
			.
			.
			.
#

Example--Full Backup to Remote System (Solaris 2.7 Data to SunOS 4.1.3 System)

The following example shows a full backup of a local /export/home file system on a Solaris 7 system to a tape device on a remote SunOS 4.1.3 system (mars).


Note -

Notice the SunOS 4.x-style device name (/dev/rst0) used with the ufsdump command.



# ufsdump 0ucf mars:/dev/rst0 /export/home
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Fri Oct 24 15:06:47 1997
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (earth:/export/home) to (mars:/dev/rst0).
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 19574 blocks (9.56MB)
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: level 0 dump on Fri Oct 24 15:06:47 1997
  DUMP: Tape rewinding
  DUMP: 19574 blocks (9.56MB) on 1 volume
  DUMP: DUMP IS DONE
#
 
 ufsrestore tf mars:/dev/rst0
         2      .
         3      ./lost+found
      2688      ./kryten
      5409      ./kryten/letters
      5410      ./kryten/letters/letter1
      5411      ./kryten/letters/letter2
      5412      ./kryten/letters/letter3
      2689      ./kryten/.profile
      8096      ./kryten/memos
        30      ./kryten/reports
        31      ./kryten/reports/reportA
        32      ./kryten/reports/reportB
        33      ./kryten/reports/reportC
                .
                .
                .
#

Example--Full Backup to Remote System (SunOS 4.1.3 Data to Solaris 7)

The following example shows a full backup of a local root (/) file system on a Sun 4.1.3 system (mars) to a remote tape device on a Solaris 7 system called pluto.


Note -

Notice that when you back up data on a system running SunOS 4.1.3 or a compatible version, you must use the dump command--not the ufsdump command.



# dump 0ucf pluto:/dev/rmt/0 /
  DUMP: Date of this level 0 dump: Tue Oct 21 16:05:19 1997   
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rsd2a (/) to /dev/rmt/0 on host pluto
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 8686 blocks (4.24MB) on 0.10 tape(s).
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: level 0 dump on Tue Oct 21 16:05:19 1997
  DUMP: Tape rewinding
  DUMP: 8690 blocks (4.24MB) on 1 volume
  DUMP: DUMP IS DONE
# restore tf pluto:/dev/rmt/0
         2      .
         3      ./lost+found
      3776      ./export
      7552      ./home
     11328      ./usr
     15104      ./pcfs
      3777      ./tftpboot
      3778      ./tftpboot/tftpboot
      3794      ./tftpboot/boot.sun4c.sunos.4.1.3
      7553      ./etc
      7554      ./etc/sendmail.cf
      7555      ./etc/aliases
      7556      ./etc/aliases.dir
      7557      ./etc/aliases.pag
      7558      ./etc/holidays
      7559      ./etc/dumpdates
                      .
                .
                .
#

Chapter 35 Restoring Files and File Systems (Tasks)

This chapter describes the procedures for restoring file systems.

This is a list of step-by-step instructions in this chapter.

This chapter describes how to use the ufsrestore(1M) command to restore files and file systems that were backed up using the ufsdump command. See Chapter 37, Copying UFS Files and File Systems (Tasks) for information about other commands you can use to archive, restore, copy, or move files and file systems.

Preparing to Restore Files and File Systems

The ufsrestore command copies files to disk, relative to the current working directory, from backups created using the ufsdump command. You can use ufsrestore to reload an entire file system hierarchy from a level 0 dump and incremental dumps that follow it or to restore one or more single files from any dump tape. If ufsrestore is run as superuser, files are restored with their original owner, last modification time, and mode (permissions).

Before you start to restore files or file systems, you need to know:

Determining the Disk Device Name

If you have properly labeled your backup tapes, you should be able to use the disk device name (/dev/rdsk/devicename) from the tape label. See "How to Find File System Names" for more information.

Determining the Type of Tape Drive You Will Use

You must use a tape drive that is compatible with the backup media to restore the files. The format of the backup media determines which drive you must use to restore files. For example, if your backup media is 8-mm tape, you must use an 8-mm tape drive to restore the files.

Determining the Tape Device Name

You may have specified the tape device name (/dev/rmt/n) as part of the backup tape label information. If you are using the same drive to restore a backup tape, you can use the device name from the label. See Chapter 38, Managing Tape Drives (Tasks) for more information on media devices and device names.

Restoring Complete File Systems

Occasionally, a file system becomes so damaged that you must completely restore it. Typically, you need to restore a complete file system after a disk head crash. You may need to replace the hardware before you can restore the software. See Chapter 23, SPARC: Adding a Disk (Tasks) or Chapter 24, x86: Adding a Disk (Tasks) for information on how to replace a disk. Fully restoring a file system such as /export/home can take a lot of time. If you have consistently backed up file systems, you can restore them to their state as of the last incremental backup.

Restoring Individual Files and Directories

When you back up files and directories, they are saved relative to the file system in which they belong. When you restore files and directories, ufsrestore recreates the file hierarchy in the current working directory. For example, files backed up from the /export/doc/books directory (where /export is the file system), would be saved relative to /export. In other words, the book1 file in the docs directory would be saved as ./doc/books/book1 on the tape. Later on, if you restored the ./doc/books/book1 file to the /var/tmp directory, the file would be restored to /var/tmp/doc/books/book1.

When restoring individual files and directories, it is a good idea to restore them to a temporary location, such as the /var/tmp directory. After you verify them, you can move the files to their proper locations. You can restore individual files and directories to their original locations. If you do so, be sure you are not overwriting newer files with older versions from the backup tape.


Note -

Do not restore files in the /tmp directory even temporarily. The /tmp directory is usually mounted as a TMPFS file system and TMPFS does not support UFS file system attributes such as ACLs.


Restoring Files and File Systems

Things you need to know:

How to Determine Which Tapes to Use

  1. Ask the user the approximate date the files to be recovered were last modified.

  2. Refer to your backup plan to find the date of the last backup that would have the file or file system on it.

    To retrieve the most recent version of a file, work backward through the incremental backups from highest to lowest level and most recent to least recent, unless the user requests otherwise.

  3. If you have online archive files, use the ufsrestore command to identify correct media.


    # ufsrestore ta archive-name ./path/filename ./path/filename
    

    t

    List each file that appears on the tape. 

    a

    Reads the table of contents from the online archive file instead of the tape. 

    archive-name

    Identifies the online archive file name. 

    ./path/filename

    Identifies the file name(s) you are looking for on the online archive. If successful, ufsrestore will print out the inode number and file name. If unsuccessful, ufsrestore will print an error message.

  4. Insert the media containing the backups in the drive and use the ufsrestore command to verify the correct media.


    # ufsrestore tf device-name ./path/filename ./path/filename
    

    Be sure to use the complete path for the filename(s). If a file is in the backup, its name and inode number is listed. Otherwise, a message says it is not on the volume.

  5. If you have multiple dump files on the same tape, use the s /dev/rmt/n option to position the tape at the dump you want to use.


    # ufsrestore tfs /dev/rmt/n tape_number
    

Example--Determining Which Tapes to Use

If you use ufsdump to dump the /usr file system, the table of contents lists only the files and directories under /usr. The following example checks if /usr/bin/pwd is in the online archive.


# ufsrestore ta archive-name ./bin/pwd

The following example checks if /usr/bin/pwd is on the backup tape.


# ufsrestore tf /dev/rmt/n ./bin/pwd

How to Restore Files Interactively

  1. Become superuser.

  2. Write-protect the tape.

  3. Insert the volume 1 tape into the tape drive.

  4. Change to a directory that will be used to restore the files temporarily.


    # cd /var/tmp
    

    To avoid conflicts with other users, you may want to create and change to a subdirectory, such as /var/tmp/restore, in which to restore the files.

    If you are restoring a hierarchy, you should restore the files in a temporary directory on the same file system where the files will reside, so you can use the mv command to move the entire hierarchy where it belongs after it is restored.

  5. Use the ufsrestore command to start the interactive restoration.

    Some informational messages and the ufsrestore> prompt are displayed.


    # ufsrestore if /dev/rmt/n
    
  6. Create a list of files to be restored.

    1. List the contents of a directory.


      ufsrestore> ls directory
      
    2. Change to a directory.


      ufsrestore> cd directory-name
      
    3. Create a list of files and directories you want to restore.


      ufsrestore> add filename filename
      
    4. (Optional) If you need to remove a directory or file name from the list of files to be restored, use the delete command.


      ufsrestore> delete filename
      
  7. (Optional) Turn on verbose mode to display the file names as they are being restored.


    ufsrestore> verbose
    
  8. Use the extract command after the list is complete.


    ufsrestore> extract
    

    The ufsrestore command asks you which volume number to use.

  9. Type the volume number and press Return. If you have only one volume, type 1 and press Return.


    Specify next volume #: 1
    

    The files and directories in the list are extracted and restored to the current working directory.

  10. To keep the mode of the current directory unchanged, enter n at the set owner/mode prompt.


    set owner/mode for `.'? [yn] n
    

    A delay will occur while ufsrestore performs its final cleanup.

  11. Quit the ufsrestore program.


    ufsrestore> quit
    

    The shell prompt is displayed.

  12. Verify the restored files.

    1. List the restored files and directories.


      # ls -l
      

      A list of files and directories is displayed.

    2. Check the list to be sure all the files and directories you specified in the list have been restored.

    3. Move the files to the proper directories.

Example--Restoring Files Interactively

The following example extracts the files /etc/passwd and /etc/shadow from the backup tape.


# cd /var/tmp
# ufsrestore if /dev/rmt/0
ufsrestore> ls
.:
 .cpr_config   etc/          lost+found/   sbin/         usr/
 TT_DB/        export/       mnt/          sccs/         var/
 b/            home/         net/          share/        vol/
 bin           kernel/       opt/          shared/       ws/
 dev/          lib           platform/     src/          xfn/
 devices/      license/      proc/         tmp/
ufsrestore> cd etc
ufsrestore> add passwd shadow
ufsrestore> verbose
verbose mode on
ufsrestore> extract
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start 
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./etc/shadow
extract file ./etc/passwd
Add links
Set directory mode, owner, and times.
set owner/mode for `.'? [yn] n
ufsrestore> quit
# 

How to Restore Specific Files Non-Interactively

  1. Become superuser.

  2. Write-protect the tape for safety.

  3. Insert the volume 1 tape into the tape drive.

  4. Change to a directory for restoring files temporarily.


    # cd /var/tmp
    

    To avoid conflicts with other users, you may want to create and change to a subdirectory, such as /var/tmp/restore, in which to restore the files.

    If you are restoring a hierarchy, you should restore the files in a temporary directory on the same file system where the files will reside, so you can use the mv command to move the entire hierarchy where it belongs after it is restored.

  5. Use the ufsrestore command to restore the file.


    # ufsrestore xvf /dev/rmt/n filename ...

    x

    Tells ufsrestore to copy specific files or directories in the filename argument.

    v

    Displays the file names as they are restored. 

    f /dev/rmt/n

    Identifies the tape device name. 

    filename ...

    One or more individual file or directory names separated by spaces, for example: ./export/home/user1/mail ./export/home/user2/mail.

  6. Type the volume number where files are located and press Return.


    Specify next volume #: 1
    

    The file is restored to the current working directory.

  7. To keep the mode of the current directory unchanged, type n and press Return at the set owner/mode prompt.


    set owner/mode for '.'? [yn] n
    
  8. Verify the restored files.

    1. List the restored files and directories.


      # ls -l
      

      A list of files and directories is displayed.

    2. Check the list to be sure all the files and directories you specified in the list have been restored.

    3. Move the files to the proper directories.

Example--Restoring Specific Files Non-Interactively

The following example restores the passwd and shadow files to the /var/tmp directory.


# cd /var/tmp
# ufsrestore xvf /dev/rmt/0 ./etc/passwd ./etc/shadow
Verify volume and initialize maps
Media block size is 126
Dump   date: Tue Jun 09 14:30:16 1998
Dumped from: the epoch
Level 0 dump of / on pluto:/dev/dsk/c0t3d0s0
Label: none
Extract directories from tape
Initialize symbol table.
Warning: ./etc: File exists
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start 
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./etc/passwd
Add links
Set directory mode, owner, and times.
set owner/mode for `.'? [yn] n
Directories already exist, set modes anyway? [yn] n
# cd etc
#  mv passwd /etc
# mv shadow /etc
# ls -l etc

How to Restore Files Using a Remote Tape Drive

You can restore files from a remote tape drive by adding remote-host: to the front of the tape device name when using the ufsrestore command.


ufsrestore xf [user@]remote-host:/dev/rmt/n filename 

Example--Restoring Files Using a Remote Drive

The following example restores files using a remote tape drive /dev/rmt/0 on the system venus.


# ufsrestore xf venus:/dev/rmt/0 filename

How to Restore a Complete File System


Note -

You cannot use this procedure to restore root (/) or /usr. See "How to Restore the root (/) and /usr File Systems" for instructions on restoring these file systems.


  1. Become superuser.

  2. If necessary, unmount the file system.


    # umount /dev/rdsk/device-name
    
  3. Create the new file system with the newfs(1M) command.


    # newfs /dev/rdsk/device-name
    

    You are asked if you want to construct a new file system on the raw device. Verify that the device-name is correct so you don't wipe out the wrong file system.

  4. Confirm that the new file system should be created.


    newfs: construct a new file system /dev/rdsk/cwtxdysz:(y/n)? y
    

    The new file system is created.

  5. Mount the new file system on a temporary mount point.


    # mount /dev/dsk/device-name /mnt
    
  6. Change to the /mnt directory.


    # cd /mnt
    

    You have changed to the mount-point directory.

  7. Write-protect the tapes.

  8. Insert the first volume of the level 0 tape into the tape drive.

  9. Use the ufsrestore command to restore the files on the tapes.


    # ufsrestore rvf /dev/rmt/n
    

    The level 0 dump is restored. If the dump required multiple tapes, you will be prompted to load each tape in order.

  10. Remove the tape and load the next level tape in the drive.

    Always restore tapes starting with 0 and continuing until you reach the highest level.

  11. Repeat Step 7 through Step 10 for each level of dump, from the lowest to the highest level.

  12. Verify the file system is restored.


    # ls
    
  13. Remove the restoresymtable file.


    # rm restoresymtable
    

    The restoresymtable file created by ufsrestore is removed.

  14. Change to another directory.


    # cd /
    
  15. Unmount the newly restored file system.


    # umount /mnt
    
  16. Remove the last tape and insert a new tape that is not write-protected in the tape drive.

  17. Use the ufsdump command to make a level 0 backup of the newly restored file system.


    # ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name
    

    You should always do an immediate backup of a newly created file system, because ufsrestore repositions the files and changes the inode allocation (the restored file system will appear to have changed since the previous backup).

  18. Mount the restored file system.


    # mount /dev/dsk/device-name mount-point
    

    The restored file system is mounted and available for use.

  19. Verify the restored and mounted file system is available.


    # ls mount-point
    

Example--Restoring a Complete File System

The following example restores the /export/home file system.


# umount /export/home
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7: (y/n)? y
/dev/rdsk/c0t3d0s7:		410400 sectors in 270 cylinders of 19 tracks, 80 sectors
		200.4MB in 17 cyl groups (16 c/g, 11.88MB/g, 5696 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 24432, 48832, 73232, 97632, 122032, 146432, 170832, 195232, 219632,
 244032, 268432, 292832, 317232, 341632, 366032, 390432,
# mount /dev/dsk/c0t3d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump   date: Tue Jun 09 15:01:03 1998
Dumped from: the epoch
Level 0 dump of /export/home on pluto:/dev/dsk/c0t3d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Warning: ./lost+found: File exists
Make node ./kryten
Make node ./kryten/letters
Make node ./kryten/memos
Make node ./kryten/reports
Make node ./rimmer
Make node ./rimmer/sc.directives
Make node ./rimmer/tests
Make node ./rimmer/answers
Extract new leaves.
Check pointing the restore
# ls
# rm restoresymtable
# cd /
# umount /mnt
# ufsdump 0ucf /dev/rmt/0 /export/home
                    .
 
                    .
 
                    .
# mount /dev/dsk/c0t3d0s7 /export/home
# ls /export/home

How to Restore the root (/) and /usr File Systems

  1. Add a new system disk to the system where the root (/) and /usr file systems will be restored.

    For a detailed description about adding a system disk, refer to Chapter 23, SPARC: Adding a Disk (Tasks) or Chapter 24, x86: Adding a Disk (Tasks).

  2. Mount the new file system on a temporary mount point.


    # mount /dev/dsk/device-name /mnt
    
  3. Change to the /mnt directory.


    # cd /mnt
    
  4. Write-protect the tapes.

  5. Use the ufsrestore command to restore the root file system.


    # ufsrestore rvf /dev/rmt/n
    

    The level 0 tape is restored.

  6. Remove the tape and load the next level tape in the drive.

    Always restore tapes starting with 0 and continuing from lowest to highest level.

  7. Continue to use the ufsrestore command as needed.


    # ufsrestore rvf /dev/rmt/n
    

    The next level tape is restored.

  8. Repeat Step 6 and Step 7 for each additional tape.

  9. Verify the file system is restored.


    # ls
    
  10. Remove the restoresymtable file.


    # rm restoresymtable
    

    Removes the restoresymtable file that is created and used by ufsrestore to check point the restore.

  11. Change to the root (/) directory.


    # cd /
    
  12. Unmount the newly created file system.


    # umount /mnt
    
  13. Check the new file system.


    # fsck /dev/rdsk/device-name
    

    The restored file system is checked for consistency.

  14. Create the boot blocks on the root partition by using the installboot(1M) command.


    # installboot  /usr/platform/`uname-i`/lib/fs/ufs/bootblk /dev/rdsk/devicename
    

    See "Example--Restoring the root (/) File System on a SPARC System" for an example of using the installboot command on a SPARC system or "Example--Restoring the root (/) File System on an x86 System" for an example of using the installboot command on an x86 system.

  15. Insert a new tape in the tape drive.

  16. Back up the new file system.


    # ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name
    

    A level 0 backup is performed. Always do an immediate backup of a newly created file system because ufsrestore repositions the files and changes the inode allocation.

  17. Repeat steps 5 through 18 for the /usr file system, if necessary.

  18. Reboot the system.


    # init 6
    

    The system is rebooted.

Example--Restoring the root (/) File System on a SPARC System


# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# installboot /usr/platform/sun4m/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6

Example--Restoring the root (/) File System on an x86 System


# mount /dev/dsk/c0t3d0s0 /mnt
# cd /mnt
# tapes
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# fsck /dev/rdsk/c0t3d0s0
# installboot /usr/platform/`uname -i`/lib/fs/ufs/pboot  /usr/platform/`uname -i`/lib/fs/
ufs/bootblk /dev/rdsk/c0t3d0s0
# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0
# init 6

Chapter 36 The ufsdump and ufsrestore Commands (Reference)

This chapter contains reference information on the ufsdump and ufsrestore commands.

This is a list of reference information in this chapter.

How ufsdump Works

The ufsdump command makes two passes when backing up a file system. On the first pass, it scans the raw device file for the file system and builds a table of directories and files in memory. It then writes the table to the backup media. In the second pass, ufsdump goes through the inodes in numerical order, reading the file contents and writing the data to the media.

Determining Device Characteristics

The ufsdump command needs to know only an appropriate block size and how to detect the end of media.

Detecting the End of Media

ufsdump writes a sequence of fixed-size records. When ufsdump 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 ufsdump that only a partial record has been written, a media error occurs as ufsdump tries to write.


Note -

DAT devices and 8mm tape devices detect end-of-media. Cartridge tape devices and 1/2-inch tape devices do not detect end-of-media.


Copying Data

The ufsdump command copies data only from the raw disk slice. If the file system is still active, anything in memory buffers is probably not copied. The backup done by ufsdump 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.

The Role of the /etc/dumpdates File

The ufsdump command, when used with the -u option, maintains and updates the /etc/dumpdates file. Each line in /etc/dumpdates shows the file system backed up, the level of the last backup, and the day, date, and time of the backup. Here is a typical /etc/dumpdates file from a file server:


/dev/rdsk/c0t3d0s0               0 Tue Jun  9 14:30:16 1998
/dev/rdsk/c0t3d0s0               9 Tue Jun  9 11:04:41 1998
/dev/rdsk/c0t3d0s7               0 Tue Jun  9 13:54:27 1998

When you do an incremental backup, the ufsdump command consults /etc/dumpdates to find the date of the most recent backup of the next lower level. Then it 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, describing 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, but edit it only at your own risk. If you make changes to the file that do not match your archive tapes, you may not be able 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, which can be one of the following:

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 dump-file.


Note -

The dump-file argument can also point to a file on a local or remote disk, which, if used by mistake, can fill up a file system.


Local Tape or Diskette Drive

Typically, dump-file specifies a raw device file for a tape or diskette drive. When ufsdump writes to an output device, it creates a single backup file which may span multiple tapes or diskettes.

You specify the tape or diskette device on your system 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 ufsdump asks for a new tape. See "Backup Device Names" for a complete description of device naming conventions.

Remote Tape or Diskette Drive

You specify a remote tape or diskette drive using the syntax host:device. ufsdump writes to the remote device when root on the local system has access to the remote system. If you usually run ufsdump as root, 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, ufsdump 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.7 convention (for example, /dev/rmt/0).


Note -

You must specify remote devices explicitly with the dump-file argument. In previous SunOS releases, the rdump command directed the output to the remote device defined by the dumphost alias. ufsdump does not have an rufsdump counterpart.


Standard Output

When you specify a dash (-) as the dump-file argument, ufsdump writes to the 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 the standard output with ufsdump and reading from the standard input with ufsrestore, as shown in this example:


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

Specifying Files to Back Up

You must always include files-to-backup as the last argument on the command line. This argument specifies the source or contents of the backup. It usually identifies a file system but can also identify individual files or directories.

For a file system, specify the raw device file for a disk slice. It includes the disk controller abbreviation (c), the target number (t) for SCSI devices only, a number indicating the disk number (d), and the slice number (s). For example, if you have a SCSI disk controller on your standalone system (or server) and you want to back up /usr located in slice 6, specify the device as follows:

/dev/rdsk/c0t0d0s6

You can specify the file system by its mount point directory (for example, /home), as long as there is an entry for it in the /etc/vfstab file.

See "Backup Device Names" for a complete description of device naming conventions.

For individual files or directories, type one or more names separated by spaces.


Note -

When you use ufsdump to back up one or more directories or files (rather than a whole file system), a level 0 backup is done. Incremental backups do not apply.


End-of-Media Detection

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 time you need to use the end-of-media options is when ufsdump does not understand the way the device detects the end-of-media or you are going to restore the files on a system with an older version of the restore command. To ensure compatibility with older versions of the restore command, the size option can still force ufsdump to go to the next tape or diskette before reaching the end of the current tape or diskette.

Specifying Tape Characteristics

If you do not specify any tape characteristics, the ufsdump command uses a set of defaults. You can specify 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

Table 36-1 lists tasks you cannot perform with the ufsdump command.

Table 36-1 Tasks You Cannot Perform With the ufsdump Command

The ufsdump Command Does Not ...

Comments 

Automatically calculate the number of tapes or diskettes needed for backing up file systems 

You can use the dry run mode (S option) to determine the amount of space that is needed before actually backing up file systems. 

Provide built-in error checking to minimize problems when backing up an active file system 

-- 

Enable you to 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 ufsdump 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:


/usr/sbin/ufsdump [options] [arguments] files-to-back-up

options

Is a single string of one-letter option names. 

arguments

Identifies option arguments and may be multiple strings. The option letters and the arguments that go with them must be in the same order  

files-to-back-up

Identifies the files to back up and these arguments must always come last. 

Default Command Options

If you run the ufsdump command without any options, use this syntax:


# ufsdump files-to-back-up

ufsdump uses these options, by default:


ufsdump 9uf /dev/rmt/0 files-to-back-up

These options do a level 9 incremental backup to the default tape drive at its preferred density.

Options for the ufsdump Command

Table 36-2 describes the options for the ufsdump command.

Table 36-2 Options for the ufsdump Command

Option 

Description 

0-9

Backup level. Level 0 is for a full backup of the whole file system specified by files-to-backup. Levels 1-9 are for incremental backups of files that have changed since the last lower-level backup.

a archive-file

Archive file. Store (archive) a backup table of contents in a specified file on the disk. The file can be understood only by ufsrestore, which uses it to determine whether a file to be restored is present in a backup file, and if so, on which volume of the media it resides.

b factor

Blocking factor. The number of 512-byte blocks to write to tape at a time. 

c

Cartridge. Back up to cartridge tape. When end-of-media detection applies, this option sets the block size to 126. 

d bpi

Tape density. You need to use this option only when ufsdump cannot detect the end of the media.

D

Diskette. Back up to diskette. 

f dump-file

Dump file. Write the files to the destination specified by dump-file instead of the default device. If the file is specified as user@system:device, ufsdump 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 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, it continues. If it is not ready after two minutes, it prompts the operator to load another tape. 

n

Notify. When intervention is needed, send a message to all terminals of all users in the sys group.

o

Offline. When finished with a tape or diskette, take the drive offline, rewind (if tape), and if possible remove the media (for example, eject a diskette or remove 8-mm autoloaded tape). 

s size

Size. Specify the length of tapes in feet or number of 1024-byte blocks for diskettes. You need to use this option only when ufsdump cannot detect the end of the media.

S

Estimate size of backup. Determine the amount of space that is needed to perform the backup, without actually doing it, and output a single number indicating the estimated size of the backup in bytes. 

t tracks

Tracks. Specify the number of tracks for 1/4-inch cartridge tape. You need to use this option only when ufsdump cannot detect the end of the media.

u

Update the dump record. For a completed backup on a file system, add an entry to the /etc/dumpdates file. The entry indicates the device name for the file system's disk slice, the backup 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, verify the contents of the media against the source file system. If any discrepancies occur, prompt the operator to mount new media, then repeat the process. Use this option on an unmounted file system only, because any activity in the file system causes it to report discrepancies. 

w

Warning. List the file systems appearing in /etc/dumpdates that have not been backed up within a day. When you use this option all other options are ignored.

W

Warning with highlight. Show all the file systems that appear in /etc/dumpdates and highlight 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:

Options and Arguments for the ufsrestore Command

Command Syntax

The syntax of the ufsrestore command is:


ufsrestore [options][arguments][filename ...]

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.

arguments

Follows the option string with the arguments that match the options. The option names and the arguments that go with them must be in the same order. 

filename

Specifies files to be restored as arguments to the x or t options, and must always come last.

Options and Arguments

You must use one (and only one) of the ufsrestore options shown in Table 36-3.

Table 36-3 One Required Option for the ufsrestore Command

Option 

Description 

i

Interactive. Runs ufsrestore in an 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. See "Commands for Interactive Restore" for a list of available commands.

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 dumps on top of the full dump (e.g., restoresymtable) is also included. To completely restore a file system, use this option to restore the full (level 0) dump and each subsequent incremental dump. Although intended for a new file system (one 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 [filename...]

 

Extract. Selectively restores the files you specify by the filename argument. filename can be a list of files and directories. All files under a specified directory are restored unless you also use the h option also. If you omit filename 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 [filename...]

Table of contents. Checks the files specified in the filename argument against the media. For each file, lists the full file name and the inode number (if the file is found) or indicates the file is not on the "volume" (meaning any volume in a multivolume dump). If you do not enter the filename 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 specified in filename, 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.

In addition to one of the options shown in Table 36-3, you can choose from the options shown in Table 36-4.

Table 36-4 Additional Options for the ufsrestore Command

Option 

Description 

a archive-file [filename...]

Takes the dump table of contents from the specified archive-file instead of from the media (first volume). You can use this option in combination with the t, i, or x options to check for the files in the dump without having to mount any media. If you use it with the x and interactive extract options, you will be prompted to mount the appropriate volume before extracting the file(s).

b factor

Blocking factor. Number of 512-byte blocks read from tape at a time. By default, ufsrestore tries to figure out the block size that was used in writing the tape.

d

Debug. Turn 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, ufsrestore reads from the remote device. You can also use the backup-file argument to specify a file on a local or remote disk. If backup-file is `-', 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 and renames them 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

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

Continues when errors occur reading the media and tries to skip over bad blocks instead of stopping and asking whether to continue. This option tells the command to assume a yes response. 

Commands for Interactive Restore

Table 36-5 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 and entries in the current list to be restored (extracted) are marked by an * prefix. Inode numbers are shown if the verbose option 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. Note that 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 revisions 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. Note that 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. Specify 1 when asked for a volume number for a single-volume backup. If you are doing a multitape or multidiskette restore and restoring a small number of files, start with the last tape or diskette instead.

help

Displays a list of commands 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 restoring a whole file system. Type n (for no) to leave the mode of the current directory unchanged. Use this mode when restoring part of a backup to a directory other than the one from which the files were backed up.

verbose

Turns on or off the verbose option (which can also be entered 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. 

Chapter 37 Copying UFS Files and File Systems (Tasks)

This chapter describes how to copy UFS files and file systems to disk, tape, and diskettes using various backup commands.

This is a list of the step-by-step instructions in this chapter.

Commands for Copying File Systems

When you need to back up and restore complete file systems, use the ufsdump and ufsrestore commands described in Chapter 36, The ufsdump and ufsrestore Commands (Reference). When you want to copy or move individual files, portions of file systems, or complete file systems, you can use the procedures described in this chapter as an alternative to ufsdump and ufsrestore.

Table 37-1 describes when to use the various backup commands.

Table 37-1 When to Use Various Backup Commands

If You Want To ... 

Then Use ... 

Reference 

Back up file systems to tape 

ufsdump(1M)

"How to Do Backups to Tape"

Restore file systems from tape 

ufsrestore(1M)

"How to Restore a Complete File System"

Transport files to other systems 

pax(1), tar(1), or cpio(1)

"Copying Files and File Systems to Tape"

Copy files or file systems between disks 

dd(1M)

"How to Clone a Disk (dd)"

Copy files to diskette 

tar(1)

"How to Copy Files to a Single Formatted Diskette (tar)"

Table 37-2 describe various backup and restore commands.

Table 37-2 Summary of Various Backup Commands

Command Name 

Aware of File System Boundaries? 

Support Multi-Volume Backups? 

Physical or Logical Copy? 

volcopy

Yes 

Yes 

Physical 

tar

No 

No 

Logical 

cpio

No 

Yes 

Logical 

pax

Yes 

Yes 

Logical 

dd

Yes 

No 

Physical 

ufsdump/ufsrestore

Yes 

Yes 

Logical 

The following sections describe the advantages and disadvantages of each method and provide examples of how to use the commands.

Copying File Systems Between Disks

Two commands are used to copy file systems between disks:

The next section describes how to use the dd command to copy file systems between disks.

Making a Literal File System Copy

The dd command makes a literal (block-level) copy of a complete UFS file system to another file system or to a tape. By default, the dd command copies its standard input to its standard output.


Note -

Do not use the dd command with variable-length tape drives without specifying an appropriate block size.


You can specify a device name in place of the standard input or the standard output or both. In this example, contents of the diskette are copied to a file in the /tmp directory:


$ dd < /floppy/floppy0 > /tmp/output.file
2400+0 records in
2400+0 records out

The dd command reports on the number of blocks it reads and writes. The number after the + is a count of the partial blocks that were copied. The default block size is 512 bytes.

The dd command syntax is different from most other commands. Options are specified as keyword=value pairs, where keyword is the option you want to set and value is the argument for that option. For example, you can replace the standard input and output with this syntax:


$ dd if=input-file of=output-file

For example, to use the keyword=value pairs instead of the redirect symbols in the previous example, you would type:


$ dd if=/floppy/floppy0 of=/tmp/output.file

How to Clone a Disk (dd)

  1. Make sure the source and destination disks have the same disk geometry.

  2. Become superuser.

  3. Create the /reconfigure file on the system so the system will recognize the clone disk to be added when it reboots.


    # touch /reconfigure
    
  4. Shut down the system.


    # init 0
    
  5. Attach the clone disk to the system.

  6. Boot the system.


    ok boot
    
  7. Use the dd command to copy the master disk to the clone disk.


    # dd if=/dev/rdsk/device-name of=/dev/rdsk/device-name bs=blocksize
    

    if=/dev/rdsk/device-name

    Represents the overlap slice of the master disk device, usually slice 2. 

    of=/dev/rdsk/device-name

    Represents the overlap slice of the clone disk device, usually slice 2. 

    bs=blocksize

    Block size, such as 128 Kbytes or 256 Kbytes. A large block size value will decrease the time to copy. 

  8. Check the new file system.


    # fsck /dev/rdsk/device-name
    
  9. Mount the clone disk's root (/) file system.


    # mount /dev/dsk/device-name /mnt
    
  10. Edit the clone disk's /etc/vfstab to reference the correct device names.

    For example, changing all instances of c0t3d0 with c0t1d0.

  11. Unmount the clone disk's root (/) file system.


    # umount /mnt
    
  12. Shut down the system.


    # init 0
    
  13. Boot from the clone disk to single-user mode.


    # boot diskn -s
    

    Note -

    The installboot command is not needed for the clone disk because the boot blocks are copied as part of the overlap slice.


  14. Unconfigure the clone disk.


    # sys-unconfig
    

    The system is shut down after it is unconfigured.

  15. Boot from the clone disk again and provide its system information, such as host name, time zone, etc.


    # boot diskn
    
  16. Log in as superuser to verify the system information once the system is booted.


    hostname console login:

Example--Cloning a Disk (dd)


# init 0
ok boot
# dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t2d0s2 bs=128k
# fsck /dev/rdsk/c0t2d0s2
# mount /dev/dsk/c0t2d0s2 /mnt 
# cd /mnt/etc
# vi vfstab
(Modify entries for the new disk)
# cd /
# umount /mnt
# init 0
# boot disk2 -s
# sys-unconfig
# boot disk2

Copying Directories Between File Systems using the cpio Command

You can use the cpio (copy in and out) command to copy individual files, groups of files, or complete file systems. This section describes how to use the cpio command to copy complete file systems.

The cpio command is an archiving program that takes a list of files and copies them into a single, large output file. It inserts headers between the individual files to facilitate recovery. You can use the cpio command to copy complete file systems to another slice, another system, or to a media device such as tape or diskette.

Because the cpio command recognizes end-of-media and prompts you to insert another volume, it is the most effective command (other than ufsdump) to use to create archives that require multiple tapes or diskettes.

With cpio, you frequently use commands like ls and find to list and select the files you want to copy and then pipe the output to the cpio command.

How to Copy Directories Between File Systems (cpio)

  1. Become superuser.

  2. Change to the appropriate directory.


    # cd filesystem1
    
  3. Copy the directory tree from filesystem1 to filesystem2 by using a combination of the find and cpio commands.


    # find . -print -depth | cpio -pdm filesystem2
    

    Starts in the current working directory. 

    -print

    Prints the file names. 

    -depth

    Descends the directory hierarchy and prints file names on the way back up. 

    -p

    Creates a list of files. 

    -d

    Creates directories as needed. 

    -m

    Sets the correct modification times on directories. 

    The files from the directory name you specify are copied, and symbolic links are preserved.

    You may also specify the -u option. This option forces an unconditional copy. Otherwise older files will not replace newer files. This may be useful if an exact copy of a directory is desired, and some of the files being copied may already exist in the target directory.

  4. Verify the copy was successful by displaying the destination directory contents.


    # cd filesystem2
    # ls
    
  5. If appropriate, remove the source directory.


    # rm -rf filesystem1
    

Example--Copying Directories Between File Systems (cpio)


# cd /data1
# find . -print -depth | cpio -pdm /data2
19013 blocks
# cd /data2
# ls
# rm -rf /data1

See cpio(1) for more information.

Copying Files and File Systems to Tape

The pax, tar, and cpio commands can be used to copy files and file systems to tape. The command you choose depends on how much flexibility and precision you require for the copy. Because all three commands use the raw device, you do not need to format or make a file system on tapes before you use them.

Table 37-3 Advantages and Disadvantages of cpio, pax, and tar Commands

Command 

Function 

Advantages 

Disadvantages 

pax

Copy files, special files, or file systems that require multiple tape volumes or when you want to copy files to and from POSIX-compliant systems 

  • Better portability than the tar or cpio commands for POSIX-compliant systems

  • Multi-vendor support

See disadvantages for tar command, except that pax can create multi-tape volumes

tar

Copy files and directory subtrees to a single tape 

  • Available on most UNIX operating systems

  • Public domain versions are readily available

  • Is not aware of file system boundaries

  • Full pathname length cannot exceed 255 characters

  • Does not copy empty directories or special files such as device files

  • Cannot be used to create multi-tape volumes

cpio

Copy files, special files, or file systems that require multiple tape volumes or when you want to copy files from SunOS 5.7 systems to SunOS 4.0/4.1 systems 

  • Packs data onto tape more efficiently than tar

  • Skips over any bad spots in a tape when restoring.

  • Provides options for writing files with different header formats (tar, ustar, crc, odc, bar) for portability between different system types

  • Creates multi-tape volumes

 

The tape drive and device name you use depend on the hardware and configuration for each system. See "Choosing Which Media to Use" for more information about tape drives and device names.

Copying Files to Tape With tar

Things you should know before copying files to tape with the tar command:

How to Copy Files to a Tape (tar)

  1. Change to the directory that contains the files you want to copy.

  2. Insert a write-enabled tape into the tape drive.

  3. Copy the files to tape with the tar command.


    $ tar cvf /dev/rmt/n filename  ...

    c

    Indicates you want to create an archive. 

    v

    Displays the name of each file as it is archived. 

    f /dev/rmt/n

    Indicates that the archive should be written to the specified device or file. 

    filename ...

    Indicates the files and directories you want to copy. 

    The file names you specify are copied to the tape, overwriting any existing files on the tape.

  4. Remove the tape from the drive and write the names of the files on the tape label.

  5. Verify that the files copied are on the tape using the tar command with the t option, which displays the tape's contents. See "How to List the Files on a Tape (tar)" for more information on listing files on a tar tape.


    $ tar tvf /dev/rmt/n
    

Example--Copying Files to a Tape (tar)

The following example copies three files to the tape in tape drive 0.


$ cd /export/home/kryten
$ ls reports
reportA reportB reportC
$ tar cvf /dev/rmt/0 reports
a reports/ 0 tape blocks
a reports/reportA 2 tape blocks
a reports/reportB 5 tape blocks
a reports/reportC 6 tape blocks
$ tar tvf /dev/rmt/n 

How to List the Files on a Tape (tar)

  1. Insert a tape into the tape drive.

  2. Display the tape contents with the tar command.


    $ tar tvf /dev/rmt/n
    

    t

    Lists the table of contents for the files on the tape. 

    v

    Used with the t option, and provides detailed information about the files on the tape.

    f /dev/rmt/n

    Indicates the tape device. 

    filename ...

    Indicates the files and directories you want to retrieve. 

Example--Listing the Files on a Tape (tar)

The following example lists the files on the tape in drive 0.


$ tar tvf /dev/rmt/0
drwxr-xr-x 101/10       0 Jun  9 15:40 1998 reports/
-rw-r--r-- 101/10       0 Jun  9 15:40 1998 reports/reportA
-rw-r--r-- 101/10       0 Jun  9 15:40 1998 reports/reportB
-rw-r--r-- 101/10       0 Jun  9 15:40 1998 reports/reportC

How to Retrieve Files From a Tape (tar)

  1. Change to the directory where you want to put the files.

  2. Insert the tape into the tape drive.

  3. Retrieve files from the tape using the tar command.


    $ tar xvf /dev/rmt/n [filename ...]

    x

    Indicates that files should be extracted from the specified archive file. All of the files on the tape in the specified drive are copied to the current directory. 

    v

    Displays the name of each file as it is archived. 

    f /dev/rmt/n

    Indicates the tape device containing the archive. 

    filename

    Specifies a file to retrieve. 

  4. Verify the files are copied by listing the contents of the current directory.


    $ ls -l 
    

Example--Retrieving the Files on a Tape (tar)

The following example retrieves all the files from the tape in drive 0.


$ cd /var/tmp
$ tar xvf /dev/rmt/0
x reports/, 0 bytes, 0 tape blocks
x reports/reportA, 0 bytes, 0 tape blocks
x reports/reportB, 0 bytes, 0 tape blocks
x reports/reportC, 0 bytes, 0 tape blocks
x reports/reportD, 0 bytes, 0 tape blocks
$ ls -l

Note -

The names of the files extracted from the tape must exactly match the names of the files stored on the archive. If you have any doubts about the names or paths of the files, first list the files on the tape. See "How to List the Files on a Tape (tar)" for instructions.


See tar(1) for more information.

Copying Files to a Tape With pax

This section describes how to copy files with the pax command.

How to Copy Files to a Tape (pax)

  1. Change to the directory that contains the files you want to copy.

  2. Insert a write-enabled tape into the tape drive.

  3. Copy the files to tape with the pax command.


    $ pax -w -f /dev/rmt/0 filename ...

    -w

    Enables the write mode. 

    -f /dev/rmt/0

    Identifies the tape drive. 

    filename ...

    Indicates the files and directories you want to copy. 

  4. Verify the files are copied to tape.


    $ pax -f /dev/rmt/0
    
  5. Remove the tape from the drive and write the names of the files on the tape label.

Example--Copying Files to a Tape (pax)


$ pax -w -f /dev/rmt/0 .
$ pax -f /dev/rmt/0
filea fileb filec

See pax(1) for more information.

How to Copy All Files in a Directory to a Tape (cpio)

  1. Insert a tape that is not write-protected into the tape drive.

  2. Copy files to a tape using the ls and cpio commands.


    $ ls | cpio -oc > /dev/rmt/n
    

    ls

    Provides the cpio command with a list of file names.

    cpio -oc

    Specifies that cpio should operate in copy-out mode (-o) and write header information in ASCII character format (-c). This ensures portability to other vendor's systems.

    > /dev/rmt/n

    Specifies the output file. 

    All of the files in the directory are copied to the tape in the drive you specify, overwriting any existing files on the tape. The total number of blocks copied is displayed.

  3. Verify the files are copied to tape by using the following cpio command.


    $ cpio -civt < /dev/rmt/0
    
  4. Remove the tape from the drive and write the names of the files on the tape label.

Example--Copying All Files in a Directory to a Tape (cpio)

The following example copies all of the files in the directory /export/home/kryten to the tape in tape drive 0.


$ cd /export/home/kryten
$ ls | cpio -oc > /dev/rmt/0
8 blocks
$ cpio -civt < /dev/rmt/0
drwxr-xr-x  2 kryten  users    0   Jun  9 15:56 1998, letters
drwxr-xr-x  2 kryten  users    0   Jun  9 15:56 1998, memos
drwxr-xr-x  2 kryten  users    0   Jun  9 15:55 1998, reports
8 blocks
$

How to List the Files on a Tape (cpio)


Note -

Listing the table of contents takes as long as it does to read the archive file because the cpio command must process the entire archive.


  1. Insert an archive tape into the tape drive.

  2. List the files on the tape using the cpio command.


    $ cpio -civt < /dev/rmt/n
    

    -c

    Specifies that cpio should read files in ASCII character format.

    -i

    Specifies that cpio should operate in copy-in mode (even though its only listing files at this point).

    -v

    Displays the output in a format similar to the output from the ls -l command.

    -t

    Lists the table of contents for the files on the tape in the tape drive you specify. 

    < /dev/rmt/n

    Specifies the input file of an existing cpio archive.

Example--Listing the Files on a Tape (cpio)

The following example lists the files on the tape in drive 0.


$ cpio -civt < /dev/rmt/0
drwxr-xr-x  2 rimmer users 0  Jun  9 16:07 1998, answers
drwxr-xr-x  2 rimmer users 0  Jun  9 16:07 1998, sc.directives
drwxr-xr-x  2 rimmer users 0  Jun  9 16:07 1998, tests
8 blocks

How to Retrieve All Files From a Tape (cpio)

If the archive was created using relative path names, the input files are built as a directory within the current directory when you retrieve the files. If, however, the archive was created with absolute path names, the same absolute paths are used to recreate the file on your system.


Caution - Caution -

Using absolute path names can be dangerous because you may overwrite existing files on your system.


  1. Change to the directory where you want to put the files.

  2. Insert the tape into the tape drive.

  3. Copy all files from the tape to the current directory using the cpio command.


    $ cpio -icvd < /dev/rmt/n
    

    -i

    Reads in the contents of the tape. 

    -c

    Specifies that cpio should read files in ASCII character format.

    -v

    Displays the files being retrieved in a format similar to the output from the ls command.

    -d

    Create directories as needed. 

    < /dev/rmt/n

    Specifies the output file. 

  4. Verify the files are copied by listing the contents of the current directory.


    $ ls -l
    

Example--Retrieving All Files From a Tape (cpio)

The following example retrieves all files from the tape in drive 0.


$ cd /var/tmp
cpio -icvd < /dev/rmt/0
answers 
sc.directives 
tests
8 blocks
$ ls -l

How to Retrieve Specific Files From a Tape (cpio)

  1. Change to the directory where you want to put the files.

  2. Insert the tape into the tape drive.

  3. Retrieve a subset of files from a tape using the cpio command.


    $ cpio -icv "*file" < /dev/rmt/n
    

    -i

    Reads in the contents of the tape. 

    -c

    Specifies that cpio should read headers in ASCII character format.

    -v

    Displays the files as they are retrieved in a format similar to the output from the ls command.

    "*file"

    Specifies that all of the files that match the pattern are copied to the current directory. You can specify multiple patterns, but each must be enclosed in double quotation marks. 

    < /dev/rmt/n

    Specifies the input file. 

  4. Verify the files are copied by listing the contents of the current directory.


    $ ls -l
    

Example--Retrieving Specified Files From a Tape (cpio)

The following example retrieves all files with the suffix chapter from the tape in drive 0.


$ cd /home/smith/Book
$ cpio -icv "*chapter" < /dev/rmt/0
Boot.chapter 
Directory.chapter 
Install.chapter 
Intro.chapter
31 blocks
$ ls -l

See cpio(1) for more information.

How to Copy Files to a Remote Tape Drive (tar and dd)

  1. The following prerequisites must be met to use a remote tape drive:

    • The local hostname (and optionally the username of the user doing the copy) must appear in the remote system's /etc/hosts.equiv file, or the user doing the copy must have his or her home directory accessible on the remote machine, and have the local machine name in $HOME/.rhosts. See hosts.equiv(4) for more information.

    • An entry for the remote system must be in the local system's /etc/inet/hosts file or in the name service hosts file.

  2. To test whether or not you have the appropriate permission to execute a remote command, try the following.


    $ rsh remotehost echo test
    

    If "test" is echoed back to you, you have permission to execute remote commands. If "Permission denied" is echoed, check your setup as described in step 1 above.

  3. To copy files to a remote tape drive use the tar and dd commands.


    $ tar cf - files | rsh remotehost dd of=/dev/rmt/n obs=blocksize
    

    tar cf

    Creates a tape archive and specifies the tape device. 

    - (Hyphen)

    Represents a placeholder for the tape device. 

    files

    Identifies files to be copied. 

    | rsh remotehost

    Pipe the tar command's output to a remote shell to copy the files.

    dd of=/dev/rmt/n

    Represents the output device. 

    obs=blocksize

    Represents the blocking factor. 

  4. Remove the tape from the drive and write the names of the files on the tape label.

Example--Copying Files to a Remote Tape Drive (tar and dd)


# tar cvf - * | rsh mercury dd of=/dev/rmt/0 obs=126b
a answers/ 0 tape blocks
a answers/test129 1 tape blocks
a sc.directives/ 0 tape blocks
a sc.directives/sc.190089 1 tape blocks
a tests/ 0 tape blocks
a tests/test131 1 tape blocks
6+9 records in
0+1 records out

How to Extract Files From a Remote Tape Drive

  1. Change to a temporary directory.


    $ cd /var/tmp
    
  2. To extract files to a remote tape drive use the tar and dd commands.


    $ rsh remotehost dd if=/dev/rmt/n | tar xvBpf -
    

    rsh remotehost

    Is a remote shell that is started to extract the files from the tape device using the dd command.

    dd if=/dev/rmt/n

    Indicates the input device. 

    | tar xvBpf -

    Pipes the output of the dd command to the tar command used to restored the files.

  3. Verify that the files have been extracted.


    $ ls -l /var/tmp
    

Example--Extracting Files From a Remote Tape Drive


$ rsh mercury dd if=/dev/rmt/0 | tar xvBpf -
x answers/, 0 bytes, 0 tape blocks
x answers/test129, 48 bytes, 1 tape blocks
20+0 records in
20+0 records out
x sc.directives/, 0 bytes, 0 tape blocks
x sc.directives/sc.190089, 77 bytes, 1 tape blocks
x tests/, 0 bytes, 0 tape blocks
x tests/test131, 84 bytes, 1 tape blocks
$ ls -l /var/tmp

Copying Files and File Systems to Diskette

Before you can copy files or file systems to diskette, you must format the diskette. See Chapter 13, Formatting and Using Diskettes From the Command Line (Tasks) for information on how to format a diskette.

Use the tar command to copy UFS files to a single formatted diskette.

Use the cpio command if you need to copy UFS files to multiple formatted diskettes. cpio recognizes end-of-media and prompts you to insert the next volume.


Note -

Using the cpio command to copy UFS files to multiple formatted diskettes is not a straightforward procedure because of Volume Management.


Use double-sided high-density 3.5-inch diskettes (diskettes are marked "DS, HD").

Things You Should Know When Copying Files to Diskettes

How to Copy Files to a Single Formatted Diskette (tar)

  1. Change to the directory that contains the files you want to copy.

  2. Insert a formatted diskette that is not write-protected into the drive.

  3. Make the diskette available using the volcheck command.


    $ volcheck
    
  4. Unmount any file system on the diskette and reformat it.


    $ fdformat -U /vol/dev/aliases/floppy0
    
  5. Copy the files to diskette using the tar command.


    $ tar cvf /vol/dev/rdiskette0/unlabeled filename ...

    The file names you specify are copied to the diskette, overwriting any existing files on the diskette.

  6. Verify that the files copied are on the diskette using the tar command with the -t option, which displays the diskette's contents. See "How to List the Files on a Diskette (tar)" for more information on listing files.


    $ tar tvf /vol/dev/rdiskette0/unlabeled 
    
  7. Remove the diskette from the drive.

  8. Write the names of the files on the diskette label.

Example--Copying Files to a Single Formatted Diskette (tar)

The following example copies two files to a diskette.


$ cd /home/smith
$ ls evaluation*
evaluation.doc   evaluation.doc.backup
$ tar cvf /vol/dev/rdiskette0/unlabeled evaluation*
a evaluation.doc 86 blocks
a evaluation.doc.backup 84 blocks
$ tar tvf /vol/dev/rdiskette0/unlabeled

How to List the Files on a Diskette (tar)

  1. Insert a diskette into the drive.

  2. Run volcheck to make the diskette available.


    $ volcheck
    
  3. Use the tar command to list the files on a diskette.


    $ tar tvf /vol/dev/rdiskette0/unlabeled
    

Example--Listing the Files on a Diskette (tar)

The following example lists the files on a diskette.


$ tar tvf /vol/dev/rdiskette0/unlabeled
rw-rw-rw-6693/10  44032 Jun  9 15:45 evaluation.doc
rw-rw-rw-6693/10  43008 Jun  9 15:55 evaluation.doc.backup
$

See tar(1) for more information.

If you need a multiple-volume interchange utility, use the cpio command. The tar command is only a single-volume utility.

How to Retrieve Files From a Diskette (tar)

  1. Change to the directory where you want to put the files.

  2. Insert the diskette into the drive.

  3. Run volcheck to make the diskette available.


    $ volcheck
    
  4. Use the tar command to retrieve files from a diskette.


    $ tar xvf /vol/dev/rdiskette0/unlabeled
    

    All of the files on the diskette are copied to the current directory.

  5. Verify the files have been retrieved by listing the contents of the current directory.


    $ ls -l
    
  6. Remove the diskette from the drive.

Examples--Retrieving Files From a Diskette (tar)

The following example retrieves all the files from a diskette.


$  /home/smith/Evaluations
$ tar xvf /vol/dev/rdiskette0/unlabeled
x evaluation.doc, 44032 bytes, 86 tape blocks
x evaluation.doc.backup, 43008 bytes, 84 tape blocks
$ ls -l

The following example retrieves an individual file from a diskette.


$ tar xvf /vol/dev/rdiskette0/unlabeled evalutation.doc
x evaluation.doc, 44032 bytes, 86 tape blocks
$ ls -l

The file names you specify are extracted from the diskette and placed in the current working directory.

How to Archive Files to Multiple Diskettes

If you are copying large files or file systems onto diskettes, you want to be prompted to replace a full diskette with another formatted diskette. The cpio command provides this capability. The cpio commands you use are the same as you would use to copy files to tape, except you would specify /vol/dev/aliases/floppy0 as the device instead of the tape device name. See "How to Copy All Files in a Directory to a Tape (cpio)" for information on how to use cpio.

Copying Files With a Different Header Format

Archives created with the SunOS 5.7 cpio command may not be compatible with older SunOS releases. The cpio command allows you to create archives that can be read with several other formats. You specify these formats using the -H option and one of these arguments:

The syntax for using the header options is:


cpio -o -H header-option < file-list > output-archive

How to Create an Archive for Older SunOS Releases

Use the cpio command to create the archive.


$ cpio -oH odc < file-list > /dev/rmt/n

The -H values have the same meaning for input as they do for output. If the archive was created using the -H option, you must use the same option when the archive is read back in or the cpio command will fail, as shown below.

Example--Creating an Archive for Older SunOS Releases


$ find . -print | cpio -oH tar > /tmp/test
 
113 blocks
$ cpio -iH bar < /tmp/test
cpio: Invalid header "bar" specified
USAGE:
        cpio -i[bcdfkmrstuvBSV6] [-C size] [-E file] [-H hdr]
            [-I file [-M msg]] [-R id] [patterns]
        cpio -o[acvABLV] [-C size] [-H hdr] [-O file [-M msg]]
        cpio -p[adlmuvLV] [-R id] directory

When you create an archive using different options, always write the command syntax on the media label along with the names of the files or file system on the archive.

If you do not know which cpio options were used when an archive was created, all you can do is experiment with different combinations of the options to see which ones allow the archive to be read.

See cpio(1) for a complete list of options.

Retrieving Files Created With the bar Command

To retrieve files from diskettes that were archived using the SunOS 4.0/4.1 bar command, use the -H bar option to cpio.


Note -

You can only use the -H bar option with -i to retrieve files. You cannot create files with the bar header option.


How to Retrieve bar Files From a Diskette

  1. Change to the directory where you want to put the files.

  2. Insert the diskette into the drive.

  3. Run volcheck to make the diskette available.


    $ volcheck
    
  4. Use the cpio command to retrieve bar files from a diskette.

    All the files on the diskette are copied to the current directory.


    $ cpio -ivH bar < /vol/dev/rdiskette/unlabeled
    

Chapter 38 Managing Tape Drives (Tasks)

This chapter describes how to manage tape drives.

This is a list of the step-by-step instructions in this chapter.

Choosing Which Media to Use

You typically back up Solaris systems using:

You can perform backups using diskettes, but this is time-consuming and cumbersome.

The media you choose depends on the availability of the equipment that supports it and of the media (usually tape) that you use to store the files. Although you must do the backup from a local system, you can write the files to a remote device.

Table 38-1 shows typical media used for backing up file systems and shows the storage capacity for each.

Table 38-1 Media Storage Capacities

Media 

Capacity [Capacity depends on the type of drive and the data being written to the tape.]

1/2-inch reel tape 

140 Mbytes (6250 bpi) 

2.5-Gbyte 1/4 inch cartridge (QIC) tape 

2.5 Gbytes 

DDS3 4-mm cartridge tape (DAT) 

12 - 24 Gbytes 

14-Gbyte 8-mm cartridge tape 

14 Gbytes 

DLTTM 7000 1/2-inch cartridge tape

35 - 70 Gbytes 

Backup Device Names

You specify a tape or diskette drive to use for backup by supplying a logical device name. This name points to the subdirectory containing the "raw" device file and includes the logical unit number of the drive. Tape drive naming conventions use a logical, not a physical, device name. Table 38-2 shows this naming scheme.

Table 38-2 Basic Device Names for Backup Devices

Device Type 

Name 

Tape 

/dev/rmt/n

Diskette 

/vol/dev/rdiskette0/unlabeled

In general, you specify a tape drive device as shown in Figure 38-1.

Figure 38-1 Tape Drive Device Names

Graphic

If you don't specify the density, a tape drive will typically write at its "preferred" density, which usually means the highest density it supports. Most SCSI drives can automatically sense the density or format on the tape and read it accordingly. To determine the different densities that are supported for a drive, look at the /dev/rmt subdirectory, which includes the set of tape device files that support different output densities for each tape.

Also, a SCSI controller can have a maximum of seven SCSI tape drives.

Specifying the Default Density for a Tape Drive

Normally, you specify a tape drive by its logical unit number, which may run from 0 to n. Table 38-3 describes how to specify tape device names using default density settings.

Table 38-3 Specifying Default Densities for a Tape Drive

To Specify The ... 

Use ... 

First drive, rewinding 

/dev/rmt/0

First drive, nonrewinding 

/dev/rmt/0n

Second drive, rewinding 

/dev/rmt/1

Second drive, nonrewinding 

/dev/rmt/1n

By default, the drive writes at its "preferred" density, which is usually the highest density it supports. If you do not specify a tape device, the command writes to drive number 0 at the default density the device supports.

Specifying Different Densities for a Tape Drive

To transport a tape to a system whose tape drive supports only a certain density, specify a device name that writes at the desired density. Table 38-4 describes how to specify different densities for a tape drive.

Table 38-4 Specifying Different Densities for a Tape Drive

To Specify The ... 

Use ... 

First drive, low density, rewinding 

/dev/rmt/0l

First drive, low density, nonrewinding 

/dev/rmt/0ln

Second drive, medium density, rewinding 

/dev/rmt/1m

Second drive, nonrewinding, medium density 

/dev/rmt/1mn

The unit and density characters are shown in Figure 38-1.

Displaying Tape Drive Status

You can use the status option with the mt command to get status information about tape drives. The mt command reports information about any tape drives described in the /kernel/drv/st.conf file.

How to Display Tape Drive Status

  1. Load a tape into the drive you want information about.

  2. Display tape drive status with the mt command.


    # mt -f /dev/rmt/n status
    
  3. Repeat steps 1-2, substituting tape drive numbers 1, 2, 3, and so on to display information about all available tape drives.

Example-- Displaying Tape Drive Status

The following example shows status for a QIC-150 tape drive (/dev/rmt/0) and an Exabyte tape drive (/dev/rmt/1).


$ mt -f /dev/rmt/0 status
Archive QIC-150 tape drive:
   sense key(0x0)= No Additional Sense   residual= 0   retries= 0
   file no= 0   block no= 0
$ mt -f /dev/rmt/1 status
Exabyte EXB-8200 8mm tape drive:
sense key(0x0)= NO Additional Sense residual= 0  retries= 0
file no= 0   block no= 0

The following example shows a quick way to poll a system and locate all of its tape drives.


$ for drive in 0 1 2 3 4 5 6 7
> do
> mt -f /dev/rmt/$drive status
> done
Archive QIC-150 tape drive:
   sense key(0x0)= No Additional Sense   residual= 0   retries= 0
   file no= 0   block no= 0
/dev/rmt/1: No such file or directory
/dev/rmt/2: No such file or directory
/dev/rmt/3: No such file or directory
/dev/rmt/4: No such file or directory
/dev/rmt/5: No such file or directory
/dev/rmt/6: No such file or directory
/dev/rmt/7: No such file or directory
$ 

Handling Magnetic Tape Cartridges

If errors occur when reading a tape, retension the tape, clean the tape drive, and then try again.

How to Retension a Magnetic Tape Cartridge

Retension a magnetic tape cartridge with the mt command.


$ mt -f /dev/rmt/n retension
 

Example--How to Retension a Magnetic Tape Drive

The following example retensions the tape in drive /dev/rmt/1.


$ mt -f /dev/rmt/1 retension
$

Note -

Do not retension non-QIC tape drives.


How to Rewind a Magnetic Tape Cartridge

To rewind a magnetic tape cartridge, use the mt command.


$ mt -f /dev/rmt/n rewind

Example--Rewinding a Magnetic Tape Cartridge

The following example rewindes the tape in drive /dev/rmt/1.


$ mt -f /dev/rmt/1 rewind

Guidelines for Drive Maintenance and Media Handling

A backup tape that cannot be read is useless. It is a good idea to clean and check your tape drives periodically to ensure correct operation. See your hardware manuals for instructions on procedures for cleaning a tape drive. You can check your tape hardware by:

Be aware that hardware can fail in ways that the system does not report.

Always label your tapes after a backup. If you have planned a backup strategy similar to those suggested in Chapter 33, Backing Up and Restoring File Systems (Overview), you should indicate on the label "Tape A," "Tape B," and so forth. This label should never change. Every time you do a backup, make another tape label containing the backup date, the name of the machine and file system backed up, backup level, the tape number (1 of n, if it spans multiple volumes), plus any information specific to your site. Store your tapes in a dust-free safe location, away from magnetic equipment. Some sites store archived tapes in fireproof cabinets at remote locations.

You should create and maintain a log that tracks which media (tape volume) stores each job (backup) and the location of each backed-up file.