System Administration Guide

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.

What's New in Backing Up and Restoring File Systems

Use the nisbackup and nisrestore commands to backup and restore a NIS+ master server running the Solaris 2.5 release or later. See Solaris Naming Administration Guide for information on using these commands.

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 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 4.2 User Guide

Backup and restore a NIS+ master server 

nisbackup and nisrestore commands

NIS+ and FNS Administration Guide

Copy, list, and retrieve files on tape 

Copy, list, and retrieve files on diskette 

tar, cpio, or pax command

tar command

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

Copy master disk to a clone disk 

dd 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 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 

Tape Length 

1/2-inch reel tape 

40-45 Mbytes 

2300 feet 

60-Mbyte 1/4-inch streaming cartridge tape 

60 Mbytes 

425 feet 

150-Mbyte 1/4-inch streaming cartridge tape 

150 Mbytes 

700 feet 

2.3-Gbyte 8-mm cartridge tape 

2.3 Gbytes 

6000 feet 

5.0-Gbyte 8-mm cartridge tape 

5.0 Gbytes 

13000 feet 

4-mm cartridge tape (DAT) [Capacity depends on the type of drive and the data being written to the tape.]

-- 

-- 

3.5-inch diskette [You can back up file systems using diskettes, but this is time-consuming and cumbersome.]

1422 blocks (1.44 Mbytes) 

-- 

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 are kept such as mail and accounting.

At regular intervals. 

/usr - partition 62

Installing new software and adding new commands typically affects user file systems. 

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

/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 sends mail to clients' root directories; then you should back up /export more frequently.

/usr - 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 individual 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 file. 

 

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.

 

Automate backups 

 

Use the crontab utility that calls 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 file of each dump record  

Use the -u option.

 

Verify 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

More difficult to retrieve small changes in file systems 

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. 

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. 

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 Backup?

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 many sites, so incremental backups are most often used. In this case, it is recommended that you back up your site to be able 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 a yearly backup 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 (3) 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.

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 

 

With this schedule:

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 

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.

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 five tapes: the level 0, all preceding Friday tapes (three), and the most recent daily tape.

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 2  

 

Week 3  

 

Week 4 

 

Table 33-12 shows how the contents of the tapes can change across two weeks.

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 

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: one for the level 0, four for the Fridays, and four daily tapes, assuming you reuse daily tapes each week, which is not recommended. If you save the weekly tapes for a month, you need 21 tapes.

If you need to restore the complete file system, you need six tapes: the level 0, the most recent Friday tape, and all the daily tapes for that week.

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 

/

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 

/

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  

/

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 

/

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 Recommendations

Table 33-14 provides other recommendations for scheduling backups.

Table 33-14 Other Recommendations 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 level lower. However, with this schedule you should use different tapes 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 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 489472 bytes will 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 later. See Solaris Naming Administration Guide for information on using this command.


How to Do Backups on Cartridge 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. Shut down the system.


    # init 0
    
  3. Bring the system to run level S (single-user mode).


    ok boot -s
    
  4. [Optional] Check the file system for consistency with the fsck command.

    Running the fsck command using the -m option 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
    
  5. If you will be backing up file systems onto a remote tape drive:

    1. Add the following entry to the ./rhosts file of the system that is initiating the backup:


      host root
    2. Verify that the host name added to the /.rhosts file above is accessible via the local /etc/inet/hosts file or available from the NIS or NIS+ name server.

  6. Identify the device name of the tape drive.

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

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

  8. 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/n files

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

    Do an incremental backup 

    1-9 option  

    ufsdump 9ucf /dev/rmt/n files

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

    Back up individual files 

    filename argument

    ufsdump 9ucf /dev/rmt/n /export/home/user1/mail

    "Example--Full Backup, Individual Home Directory"

    Record dumps to /etc/dumpdates file

    -u option (updates file)

    ufsdump 9ucf /dev/rmt/n files

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

    Specify a cartridge tape 

    -c option

    ufsdump 9ucf /dev/rmt/n files

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

    Specify the tape drive 

    -f dump-file

    ufsdump 9ucf /dev/rmt/1 files

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

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

    remote-host: argument

    ufsdump 0ucf mars:/dev/rmt/0 files

    "Example--Full Backup to Remote System (Solaris 2.x Data to Solaris 2.x System)"

  9. When prompted, remove the tape and replace with the next volume.

  10. Label each tape with the volume number, level, date, system name, and file system.

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

  12. 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 (/), Cartridge Tape

In this example, a full backup of the root (/) file system is made on a 150-Mbyte cartridge tape (/dev/rmt/0).


# init 0
ok boot -s
# ufsdump 0ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Wed Nov 06 15:32:21 1996
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s0 (mars:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 41236 blocks (20.13MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 41200 blocks (20.12MB) on 1 volume at 95 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Nov 06 15:32:21 1996
# ufsrestore tf /dev/rmt/0 (Verification starts here)
         2	.
         3	./lost+found
      5696	./usr
     11392	./export
     17088	./opt
     22784	./var
     28480	./var/sadm
     34176	./var/sadm/install
     39872	./var/sadm/install/admin
     39879	./var/sadm/install/admin/default
                      .
                      .
                      .
    #
# (Press Control-D to bring system to run level 3)

Example--Full Backup, /export/home, 4-mm DAT Tape

In this example, a full backup of the /export/home file system is made on a 4-mm DAT tape.


# ufsdump 0ucf /dev/rmt/0 /export/home
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Wed Nov 06 16:18:08 1996
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (mars:/export/home) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 13504 blocks (6.59MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 13480 blocks (6.58MB) on 1 volume at 92 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Wed Nov 06 16:18:08 1996
# ufsrestore tf /dev/rmt/0
    113920	./x97_sysmgt
    159488	./kryten
    159489	./kryten/.login
    159490	./kryten/.cshrc
    170880	./kryten/directives
    170882	./kryten/directives/directive.2001
    170883	./kryten/directives/directive.450b
    170881	./kryten/directives/directive.115c
    159491	./kryten/tar_file
          .
          .
          .
#

Example--Incremental Backup, root (/)

In this example, an incremental backup of the root (/) file system is made on a 4-mm DAT tape device.


# ufsdump 9ucf /dev/rmt/0 /
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 9 dump: Wed Nov 06 16:14:51 1996
  DUMP: Date of last level 0 dump: Wed Nov 06 15:32:21 1996
  DUMP: Dumping /dev/rdsk/c0t3d0s0 (mars:/) 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: Mapping (Pass II) [directories]
  DUMP: Estimated 3708 blocks (1.81MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 3652 blocks (1.78MB) on 1 volume at 75 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 9 dump on Wed Nov 06 16:14:51 1996
 # ufsrestore tf /dev/rmt/0
         2	   .
     10752	   ./var
     13440	   ./var/sadm
      2689	   ./var/sadm/install
      2690	   ./var/sadm/install/.lockfile
      2766	   ./var/sadm/install/contents
     10753	   ./var/sadm/pkg
      2734	   ./var/adm
      2780	   ./var/adm/sa
      2951	   ./var/adm/sa/sa24
      2735	   ./var/cron
      2885	   ./var/cron/log
      8086	   ./var/spool
      8087	   ./var/spool/locks
      8088	   ./var/tmp
#

Example--Full Backup, Individual Home Directory

In this example, a full backup of the /export/home/kryten directory is made on 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: Wed Nov 06 16:12:41 1996
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (mars:/export/home) to 
/dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 280 blocks (140KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 250 blocks (125KB) on 1 volume at 15 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.x Data to Solaris 2.x System)

In this example, the local /export/home file system on a Solaris 2.x system is backed up to a tape device on a remote Solaris 2.x system called pluto.


# ufsdump 0ucf pluto:/dev/rmt/0 /export/home
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Fri Oct 25 10:30:53 1996
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (/export/home) to (pluto:
/dev/rmt/0).
  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 25 10:30:53 1996
  DUMP: Tape rewinding
  DUMP: 19574 blocks (9.56MB) on 1 volume at 92 KB/sec
  DUMP: DUMP IS DONE
# ufsrestore tf pluto:/dev/rmt/0
         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 (Solaris 2.x Data to Sun 4.1.x System)

In this example, the local /export/home file system on a Solaris 2.x system is backed up to a tape device on a remote SunOS 4.1.x system (mars). Notice the SunOS 4.x-style device name (/dev/rst0) used with the ufsdump command. To run the ufsdump command, you would log in as superuser on the Solaris 2.x system.


# ufsdump 0ucf mars:/dev/rst0 /export/home
  DUMP: Writing 63 Kilobyte records
  DUMP: Date of this level 0 dump: Fri Oct 25 15:06:47 1996
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t3d0s7 (/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 25 15:06:47 1996
  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.x Data to Solaris 2.x)

In this example, the local root (/) file system on a Sun 4.1.x system (mars) is backed up to a remote tape device on a Solaris 2.x system called pluto.


Note -

Notice that when you back up data to a SunOS 4.1.x system, you must use the dump command--not the ufsdump command.



mars# dump 0ucf pluto:/dev/rmt/0 /
  DUMP: Date of this level 0 dump: Tue Oct 25 16:05:19 1996   
  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 25 16:05:19 1996
  DUMP: Tape rewinding
  DUMP: 8690 blocks (4.24MB) on 1 volume
  DUMP: DUMP IS DONE
mars# 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
                      .
                .
                .
mars#

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 from backups created using the ufsdump command into the current working directory. 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 by 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 at the last incremental backup.

Restoring Individual Files and Directories

This section describes how to restore individual files and directories using a local tape drive. See "How to Use a Remote Drive to Restore Files" for information on how to use a remote drive to restore files.

When you restore files in a directory other than the root directory of the file system, ufsrestore recreates the file hierarchy in the current directory. For example, if you restore files to /home1 that were backed up from /home/doc/books the files are restored in the /home1/doc/books directory.

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 it does not support UFS file system attributes such as ACLs.


Using a Remote Drive to Restore Files

You can restore files from a remote drive by adding remote-host: to the front of the tape device name. Here is the syntax:


ufsrestore rf [user@]remote-host:/dev/rmt/unit filename 

For example, to access /dev/rmt/0 on the system venus, type:


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

Restoring File Systems

Things you need to know:

How to Determine Which Tapes to Use

  1. Ask the user the date when the file or file system was lost, or 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 xfs /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. To see if /usr/bin/pwd is in the online archive, type:


# ufsrestore ta archive-name ./bin/pwd

To see if /usr/bin/pwd is on the backup tape, type:


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

How to Restore Files Interactively

  1. Become superuser.

  2. Write-protect the tape.

  3. Put the backup tape in the tape drive.

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


    # cd /var/tmp
    

    If you want to restore the files to a different directory, substitute the directory name for /var/tmp in this step.

  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. 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
    
  11. Quit the ufsrestore program.


    ufsrestore> quit
    

    The shell prompt is displayed.

  12. Verify the files are restored.

    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

In this example, the files /etc/passwd and /etc/shadow are extracted from the backup tape.


# cd /var/tmp
# ufsrestore if /dev/rmt/0
ufsrestore> ls
.:
 .OWdefaults         bin         lib            sbin/
 .Xauthority         dev/        lost+found/    shared/
 .desksetdefaults    devices/    misc/          tmp/
 .fm/                etc/        mnt/           ufsboot
 .mailtool-init      export/     net/           usr/
 .openwin-init       home/       nfs/           var/
 .profile            hsfsboot    opt/           ws/
 .wastebasket/       kadb        proc/
 .xsun.pluto:0       kernel/
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

  1. Become superuser.

  2. Write-protect the tape for safety.

  3. Put the backup tape in the tape drive.

  4. Change to a directory for restoring files temporarily.


    # cd /var/tmp
    

    If you want to restore the files to a different directory, substitute the directory name for /var/tmp in this step.

  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 file is restored.

    1. List the current directory.


      # ls -l filename
      

      A listing for the file is displayed.

    2. Move the file to the proper directory.


      # mv filename /directory/filename
      

Example--Restoring Specific Files

In this example, the passwd and shadow files are restored 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: Wed Nov 06 15:21:10 1996
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
# cd etc
#  mv passwd /etc
# mv shadow /etc
# ls -l etc

How to Use a Remote Drive to Restore Files

You can restore files from a remote drive by adding remote-host: to the front of the tape device name. Here is the syntax:


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

For example, to access a remote tape drive /dev/rmt/0 on the system venus, type:


# ufsrestore rf 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 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 in 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 the next tape.

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

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

  11. Use the ufsrestore command to restore the file system.


    # ufsrestore rvf /dev/rmt/n
    

    The next level tape is restored. If the dump required multiple tapes, you will be prompted to load the next tape.

  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 back up 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.

  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

In this example, the /export/home file system is restored.


# umount /export/home
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7: (y/n)? y
/dev/rdsk/c0t3d0s7:	41040 sectors in 57 cylinders of 9 tracks, 80 sectors
      21.0MB in 4 cyl groups (16 c/g, 5.90MB/g, 2688 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 11632, 23232, 34832,
# mount /dev/dsk/c0t3d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump date: Wed Nov 06 16:21:10 1996
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. Create the tape device entries.


    # tapes
    
  5. Write-protect the tapes.

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


    # ufsrestore rvf /dev/rmt/n
    

    The level 0 tape is restored.

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

  8. Continue to use the ufsrestore command as needed.


    # ufsrestore rvf /dev/rmt/n
    

    The next level tape is restored.

  9. Repeat steps 7 and 8 for each additional tape.

  10. Verify the file system is restored.


    # ls
    
  11. Remove the restoresymtable file.


    # rm restoresymtable
    

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

  12. Change to the root (/) directory.


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


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


    # fsck /dev/rdsk/device-name
    

    The restored file system is checked for consistency.

  15. Create the boot blocks on the root partition by using the installboot 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.

  16. Insert a new tape in the tape drive.

  17. 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.

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

  19. 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/`uname -i`/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 Wed Nov  6 15:32:21 1996
/dev/rdsk/c0t3d0s0               9 Wed Nov  6 16:14:51 1996
/dev/rdsk/c0t3d0s7               0 Wed Nov  6 16:18:08 1996

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 updated 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. On the date that you do a level 0 backup, /etc/dumpdates contains one information line for each backed up file system at each 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 of the remote system. If you specify the device as user@host:device, ufsdump tries to execute as the specified user on the remote system. In this case, the specified user must have a .rhosts file on the remote system to allow the user to access 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.x device name (for example, /dev/rst0). If the system is running Solaris software, use the SunOS 5.x 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 (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. Table 36-1 shows some arguments to the ufsdump command that work well for different types of tape cartridges. 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.

Table 36-1 Arguments to ufsdump to Specify Tape Capacity

Tape 

Arguments 

Diskette 

ufsdump Ds 1422

60-Mbyte cartridge 

ufsdump cdst 1000 425 9

150-Mbyte cartridge 

ufsdump cdst 1000 700 18

1/2-inch tape 

ufsdump dsb 1600 2300 126

2.3-Gbyte 8-mm tape 

ufsdump dsb 54000 6000 126

5.0-Gbyte 8-mm tape 

ufsdump dsb 54000 13000 126

5.0-Gbyte 4-mm tape 

ufsdump b 96

Limitations of the ufsdump Command

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

Table 36-2 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-3 describes the options for the ufsdump command.

Table 36-3 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 per operation. 

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-4.

Table 36-4 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 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 then for each incremental dump. Although intended for a new file system (one just created with the newfs command), the file system may contain files and 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-4, you can choose from the options shown in Table 36-5.

Table 36-5 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 to write to tape per operation. By default, ufsrestore tries to figure out the block size 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. 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 abort. This option tells the command to assume a yes response. 

Commands for Interactive Restore

Table 36-6 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 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.

extract

Extracts the files in the list and restores them to the current working directory on the disk. Specify 1 when asked for a volume number. If you are doing a multitape or multidiskette restore and restoring a small number of files, start with the last tape or diskette.

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 display information on each file as it is extracted.

what

Displays the backup header on 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

"How to Do Backups on Cartridge Tape"

Restore file systems from tape 

ufsrestore

"How to Restore a Complete File System"

Transport files to other systems 

pax, tar, or cpio

"Copying Files and File Systems to Tape"

Copy files or file systems to disk 

dd

"How to Clone a Disk (dd)"

Copy files to diskette 

tar

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


Note -

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


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

Yes 

Yes 

Logical 

pax

Yes 

Yes 

Logical 

dd

No 

Yes 

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 to Disk

Two commands are used to copy file systems to disk:

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

Making a Literal File System Copy

The dd command makes a literal (block) 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.


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 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 with the master disk so that it will recognize the clone disk once it is rebooted.

  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/dsk/device-name of=/dev/dsk/device-name bs=blocksize
    

    if=/dev/dsk/device-name

    Represents the master disk device as the input device. 

    of=/dev/dsk/device-name

    Represents the clone disk device as the output device. 

    bs=blocksize

    Block size. 

  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.

  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
    
  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/dsk/c0t0d0s2 of=/dev/dsk/c0t2d0s2bs=100k
# 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.

During cpio operations, 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 using a combination of the find and cpio commands.


    # find . -print -depth | cpio -pdmu /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. If appropriate, remove the source directory.


    # rm -rf /filesystem1
    
  5. Verify the copy was successful by displaying the destination directory contents.


    # cd filesystem2
    # ls
    

Example--Copying Directories Between File Systems (cpio)


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

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 multiple 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 multiple 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.x systems to SunOS 4.x 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 multiple 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 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)

In this example, three files are copied to a 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. 

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

In this example, the table of contents for the tape in drive 0 contains three files.


$ tar tvf /dev/rmt/0
drwxr-xr-x 101/10       0 Nov  6 16:31 1996 reports/
-rw-r--r-- 101/10       0 Nov  6 16:31 1996 reports/reportA
-rw-r--r-- 101/10       0 Nov  6 16:31 1996 reports/reportB
-rw-r--r-- 101/10       0 Nov  6 16:31 1996 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 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. 

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


    $ ls -l 
    

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

In this example, all files are copied 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 .
    

    -w

    Copies the current directory contents to tape. 

    -f /dev/rmt/0

    Identifies the tape drive. 

  4. Verify the files are copied to tape by using the pax -l command.


    $ pax -l -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 -l -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 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 < /tmp/cpio.file
    
  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)

In this example, all of the files in the directory /export/home/kryten are copied to the tape in tape drive 0.


$ cd /export/home/kryten
$ ls | cpio -oc > /dev/rmt/0
8 blocks
$ cpio -civt < /tmp/cpio.file
drwxr-xr-x  2 kryten  users    0   Oct 24 11:05 1996, letters
drwxr-xr-x  2 kryten  users    0   Oct 24 11:05 1996, memos
drwxr-xr-x  2 kryten  users    0   Nov  8 14:14 1996, 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 a tape into the tape drive.

  2. List the files on 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)

In this example, the table of contents for the tape in drive 0 contains three files.


$ cpio -civt < /dev/rmt/0
drwxr-xr-x  2 rimmer users 0  Oct 28 09:17 1996, answers
drwxr-xr-x  2 rimmer users 0  Oct 28 09:17 1996, sc.directives
drwxr-xr-x  2 rimmer users 0  Oct 28 09:17 1996, 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 output in a format similar to the output from the ls -l 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)

In this example, all files are copied 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 output in a format similar to the output from the ls -l 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)

In this example, all files with suffix chapter are copied from tape 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 tar command 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 bs=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
0+2 records in
0+2 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.

  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)

In this example, two files are copied 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.

  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)

In this example, the table of contents for the diskette shows two files:


$ tar tvf /vol/dev/rdiskette0/unlabeled
rw-rw-rw-6693/10  44032 Oct 23 14:54 1996 evaluation.doc
rw-rw-rw-6693/10  43008 Oct 23 14:47 1996 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.

  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)

In this example, all files are copied from the 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

Use the tar command to retrieve individual files from a diskette.


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

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.x 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.x 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. 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 2.5 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 length (or storage capacity) for each.

Table 38-1 Media Storage Capacities

Media 

Capacity 

Tape Length 

1/2-inch tape 

40-45 Mbytes 

2300 feet 

60-Mbyte 1/4-inch cartridge 

60 Mbytes 

425 feet 

150-Mbyte 1/4-inch cartridge 

150 Mbytes 

700 feet 

2.3-Gbyte 8-mm 

2.3 Gbytes 

6000 feet 

5.0-Gbyte 8-mm 

5.0 Gbytes 

13000 feet 

3.5-inch diskette 

1422 blocks (1.44 Mbytes) 

 


Note -

Capacity for 4-mm cartridge tapes depends on the type of drive and the data being written to the tape.


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

The drive writes 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.

Tape drives fall into two categories based on controller type:

Within the /dev/rmt subdirectory is a set of tape device files that support different output densities.

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

Figure 38-1 Tape Drive Device Names

Graphic

You can have both SCSI and non-SCSI tape drives on the same system.

Table 38-3 shows the device abbreviation for different tape controllers/units and media. Note that the first character in the device abbreviation for drive number does not have to be 0 as shown, but could be 1, 2, or 3, and so on, depending on how many tape drives are attached to the system.

Table 38-3 Device Abbreviations for Tape Controllers/Units and Media

Controller  

DriveUnit 

Size  

Format  

Tracks 

Device Name 

Reel 

Xylogics 472 

Fujitsu M2444 

1/2-inch 

1600 bpi 

/dev/rmt/0m

 

 

1/2-inch 

6250 bpi 

/dev/rmt/0h

SCSI front-loaded 

Hewlett-Packard 

1/2-inch 

800 bpi 

/dev/rmt/0m

 

 

 

6250 bpi 

/dev/rmt/0h

Cartridge 

SCSI 

Sysgen 

1/4-inch 

QIC-11 

/dev/rmt/0l

 

 

 

QIC-24 

/dev/rmt/0m

 

 

 

QIC-11 

/dev/rmt/0l

 

 

 

QIC-24 

/dev/rmt/0m

 

Emulex MT-02 

1/4-inch 

QIC-11 

/dev/rmt/0l

 

 

 

QIC-24 

/dev/rmt/0m

 

 

 

QIC-11 

/dev/rmt/0l

 

 

 

QIC-24 

/dev/rmt/0m

 

Archive QIC-150 

1/4-inch 

QIC-150 

18 

/dev/rmt/0h

 

Wangtek QIC-150 

1/4-inch 

QIC-150 

18 

/dev/rmt/0h

 

Desktop Backup Pack 

1/4-inch 

QIC-150 

18 

/dev/rmt/0h

 

Exabyte 8200 (2.3 GB) 

8 mm 

8 mm 

Helical Scan 

/dev/rmt/0m

 

Exabyte 8500 (2.3 GB) 

8 mm 

8 mm 

Helical Scan 

/dev/rmt/0l

 

Exabyte 8500 (5 GB) 

8 mm 

8 mm 

Helical Scan 

/dev/rmt/0m

 

Archive Python 

4 mm 

4 mm 

Helical Scan 

/dev/rmt/0

Rack-Mounted Non-SCSI 1/2-Inch Reel Drives

For 1/2-inch rack-mounted tape drives with either a Tapemaster or Xylogics 472 controller, substitute the density from Table 38-4 for the A variable in the device name (/dev/rmt/XA).

Table 38-4 Designating Density for Rack-Mounted 1/2-inch Tape Drives

Character 

Density 

null

Default "preferred" (highest) density (usually 6250 bpi uncompressed) 

l

800 bpi 

m

1600 bpi 

h

6250 bpi 

u

6250 bpi compressed 

If you omit the density character, the tape is usually written at its highest density, not compressed.

SCSI 1/4-Inch Cartridge and 1/2-Inch Front-Loaded Reel Drives

For SCSI 1/4-inch cartridge and 1/2-inch front-loaded reel drives, substitute the density from Table 38-5for the A variable in the device name (/dev/rmt/XA).

Table 38-5 Designating Format or Density for SCSI Tape Drives

Character 

Density 

1/4-Inch Cartridge 

Density 

1/2-Inch Front-Loaded Reel-to-Reel 

null

Default preferred (highest) density 

Default preferred (highest) density 

l

QIC-11 format 

800 bpi 

m

QIC-24 format 

1600 bpi 

h

QIC-150 

6250 bpi 

u

Reserved 

Reserved 

For 1/4-inch cartridges, density is specified by the format in which the data is written: the QIC format. The QIC-11 and QIC-24 format write approximately 1000 bytes per inch on each track. The density for QIC-150 is somewhat higher. The "preferred" density for a 60-Mbyte 1/4-inch cartridge drive is QIC-24 and for a 150-Mbyte 1/4-inch cartridge drive is QIC-150.

An 18-track drive can write only QIC-150; it cannot be switched to write QIC-24 or QIC-11. Format selection is only useful for drives that can write both QIC-24 and QIC-11.

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-6 describes how to specify tape device names using default density settings.

Table 38-6 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/1m

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-7 describes how to specify different densities for a tape drive.

Table 38-7 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.

Determining Tape Drive Types

You can use the status option with the mt command to get status information about the Xylogics 472 1/2-inch tape drive and the Exabyte EXB-8200 8-mm tape drive.

The mt command also reports information about these 1/4-inch tape drives:

How to Determine the Type of a Tape Drive

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

  2. Display tape drive information 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--Determining the Type of a Tape Drive

This 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

Here is an quick way to poll a system and locate all tape drives. In this example, the tape drive is at 0.


$ 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
$ 

How to Show the Status of a Magnetic Tape Drive

To display tape drive status information, use the mt command.


$ mt -f /dev/rmt/n status

Status for the tape drive you specify is displayed.

Examples--Showing the Status of a Magnetic Tape Drive

In the following example, there is no tape in drive /dev/rmt/1.


$ mt -f /dev/rmt/1 status
/dev/rmt/1: no tape loaded or drive offline
$

In this example, the status is shown for the tape in drive /dev/rmt/1.


$ mt -f /dev/rmt/1 status
Archive QIC-150 tape drive:
   sense key(0x6)= unit attention   residual= 0   retries= 0
   file no= 0   block no= 0
$

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

In this example, the tape in drive /dev/rmt/1 is retensioned.


$ 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

In this example, the tape in drive /dev/rmt/1 is rewound.


$ 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.