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. |
Provides step-by-step instructions for backing up individual files and complete file systems from local or remote devices. |
|
Provides step-by-step instructions for restoring individual files and complete file systems. |
|
Describes how ufsdump works, and the syntax and options for the ufsdump and ufsrestore commands. |
|
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. |
|
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. |
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.
Use these references to find step-by-step instructions for backing up and restoring file systems (using the ufsdump and ufsrestore commands).
Backing up file systems means copying file systems to removable media (such as tape) to safeguard against loss, damage, or corruption. Restoring file systems means copying reasonably-current backup files from removable media to a working directory.
This chapter describes the commands for scheduled backup and restore operations (ufsdump and ufsrestore); however, there are other commands you can use for copying files and file systems for sharing or transporting files. Table 33-1 provides pointers to all commands that copy individual files and/or file systems to media.
Table 33-1 Commands for Copying Files and File Systems
If You Want To ... |
Then Use ... |
And Go To ... |
---|---|---|
Back up complete or individual file systems to a local or remote tape device |
ufsdump(1M) command |
Chapter 34, Backing Up Files and File Systems (Tasks) or Chapter 36, The ufsdump and ufsrestore Commands (Reference) |
Back up complete file systems for all systems on a network from a server |
Solstice BackupTM software |
Solstice Backup 5.1 Administration Guide |
Backup and restore a NIS+ master server |
nisbackup(1M) and nisrestore(1M) commands | |
Copy, list, and retrieve files on tape Copy, list, and retrieve files on diskette |
tar(1), cpio(1), or pax(1) command tar(1) command | |
Copy master disk to a clone disk |
dd(1M) command | |
Restore complete file systems or individual files from removable media to a working directory |
ufsrestore(1M) command |
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:
System crashes
Accidental deletion of files
Hardware failures
Natural disasters (for example, fire, hurricanes)
Problems when reinstalling or upgrading a system
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
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 SystemsTable 33-4 File Systems to Back Up for Servers
You do not need to back up a server's /export/swap file system.
The ufsdump and ufsrestore commands are the recommended commands for scheduled backups of complete file systems. Table 33-5 lists the tasks you can perform with them. For information on how these commands work and their syntax, see Chapter 36, The ufsdump and ufsrestore Commands (Reference).
Table 33-5 Tasks You Can Perform With the ufsdump and ufsrestore Commands
With This Command ... |
You Can ... |
Comments |
---|---|---|
ufsdump |
Back up complete or partial file systems to local or remote tape drives |
The tape device can be on any system in the network to which the user has access. This command works quickly because it is aware of the structure of the UFS file system type, and works directly through the raw device interface. |
|
Back up incremental file system changes |
This enables you to back up only those files that were changed since a previous backup. |
|
Back up groups of systems over the network from a single system
|
You can run ufsdump from one system on each remote system through a remote shell or remote login, and direct the output to the system on which the drive is located. Or, you can pipe the output to the dd command or a file. |
|
Automate backups
|
Use the crontab utility to run a script that starts the ufsdump command. |
|
Restrict user access to backup tables |
Use the -a option. |
|
Determine the size of a backup without actually doing the backup |
Use the -S option. |
|
Keep a log of when each file system was backed up |
Use the -u option. |
|
Verify the contents of the tape against the source file system |
Use the -v option. |
ufsrestore |
Restore individual or complete file systems from a local or remote tape drive |
|
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
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.
The schedule you create depends on:
Your need to minimize the number of tapes
Time available for doing backups
Time available to do a full restore of a damaged file system
Time available for retrieving individual files that get accidentally deleted
If you do not need to minimize time and media spent on backups, you can do full backups every day. However, this is not realistic for most sites, so incremental backups are most often used. In this case, it is recommended that you back up your site enough to restore files from the last four weeks. This requires at least four sets of tapes--one for each week, which you would reuse each month. In addition, you should archive the monthly backups for at least a year, and then keep yearly backups for a number of years.
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.
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.
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.
The following example shows a schedule where you capture only a day's work on different tapes. In this case, sequential dump level numbers are used during the week (3,4,5,6) with a lower number (2) on Friday.
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.
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.
Table 33-7 shows the most commonly used incremental backup schedule; it is recommended for most situations. With this schedule:
All files that have changed since the lower-level backup at the end of the previous week are saved each day.
For each weekday level 9 backup, the previous level 0 or level 5 is the closest backup at a lower level. Therefore, each weekday tape contains all the files changed since the end of the previous week (or the initial level 0 for the first week).
For each Friday level 5 backup, the nearest lower-level backup is the level 0 done at the beginning of the month. Therefore, each Friday's tape contains all the files changed during the month to that point.
Floating |
Mon |
Tues |
Wed |
Thurs |
Fri |
|
---|---|---|---|---|---|---|
1st of Month |
0 |
|
|
|
|
|
Week 1 |
9 |
9 |
9 |
9 |
5 |
|
Week 2 |
9 |
9 |
9 |
9 |
5 |
|
Week 3 |
9 |
9 |
9 |
9 |
5 |
|
Week 4 |
9 |
9 |
9 |
9 |
5 |
Table 33-8 shows how the contents of the tapes can change across two weeks using the previous schedule. Each letter represents a different file.
Table 33-8 Contents of Tapes for Daily/Weekly Cumulative Schedule
Mon |
Tues |
Wed |
Thurs |
Fri |
|
---|---|---|---|---|---|
Week 1 |
a b |
a b c |
a b c d |
a b c d e |
a b c d e f |
Week 2 |
g |
g h |
g h i |
g h i j |
a b c d e f g h i j k |
With this schedule, you will need six tapes (if you want to reuse daily tapes), or nine tapes (if you want to use four different daily tapes): one for the level 0, four for the Fridays, and one or four daily tapes.
If you need to restore a complete file system, you will need the following tapes: the level 0, the most recent Friday tape, and the most recent daily tape since the last Friday tape (if any).
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 |
0 |
|
|
|
|
|
Week 1 |
9 |
9 |
9 |
9 |
3 |
|
Week 2 |
9 |
9 |
9 |
9 |
4 |
|
Week 3 |
9 |
9 |
9 |
9 |
5 |
|
Week 4 |
9 |
9 |
9 |
9 |
6 |
Table 33-10 shows how the contents of the tapes can change across two weeks using the previous schedule. Each letter represents a different file.
Table 33-10 Contents of Tapes for Daily Cumulative/Weekly Incremental Backup Schedule
Mon |
Tues |
Wed |
Thurs |
Fri |
|
---|---|---|---|---|---|
Week 1 |
a b |
a b c |
a b c d |
a b c d e |
a b c d e f |
Week 2 |
g |
g h |
g h i |
g h i j |
g h i j k |
With this schedule, you will need six tapes (if you want to reuse daily tapes), or nine tapes (if you want to use four different daily tapes): one for the level 0, four for the Fridays, and one or four daily tapes.
If you need to restore a complete file system, you will need the following tapes: the level 0, all the Friday tapes, and the most recent daily tape since the last Friday tape (if any).
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 |
0 |
|
|
|
|
|
Week 1 |
3 |
4 |
5 |
6 |
2 |
|
Week 2 |
3 |
4 |
5 |
6 |
2 |
|
Week 3 |
3 |
4 |
5 |
6 |
2 |
|
Week 4 |
3 |
4 |
5 |
6 |
2 |
Table 33-12 shows how the contents of the tapes can change across two weeks using the previous schedule. Each letter represents a different file.
Table 33-12 Contents of Tapes for Daily/Weekly Cumulative Backup Schedule
Mon |
Tues |
Wed |
Thurs |
Fri |
|
---|---|---|---|---|---|
Week 1 |
a b |
c d |
e f g |
hi |
a b c d e f g h i |
Week 2 |
j k l |
m |
n o |
p q |
a b c d e f g h i j k l m n o p q r s |
With this schedule you will need at least nine tapes (if you want to reuse daily tapes--not recommended), or 21 tapes (if you save weekly tapes for a month): one for the level 0, four for the Fridays, and four or 16 daily tapes.
If you need to restore the complete file system, you will need the following tapes: the level 0, the most recent Friday tape, and all the daily tapes since the last Friday tape (if any).
Table 33-13 shows an example backup strategy for a heavily-used file server on a small network where users are doing file-intensive work, such as program development or document production. It assumes that the backup period begins on a Sunday and consists of four seven-day weeks.
Table 33-13 Schedule of Backups for a Server Example
Directory |
Date |
Level |
Tape Name |
---|---|---|---|
root (/) |
1st Sunday |
0 |
n tapes |
/usr |
1st Sunday |
0 |
" |
/export |
1st Sunday |
0 |
" |
/export/home |
1st Sunday |
0 |
" |
|
1st Monday |
9 |
A |
|
1st Tuesday |
9 |
B |
|
1st Wednesday |
5 |
C |
|
1st Thursday |
9 |
D |
|
1st Friday |
9 |
E |
|
1st Saturday |
5 |
F |
root (/) |
2nd Sunday |
0 |
n tapes |
/usr |
2nd Sunday |
0 |
" |
/export |
2nd Sunday |
0 |
" |
/export/home |
2nd Sunday |
0 |
" |
|
2nd Monday |
9 |
G |
|
2nd Tuesday |
9 |
H |
|
2nd Wednesday |
5 |
I |
|
2nd Thursday |
9 |
J |
|
2nd Friday |
9 |
K |
|
2nd Saturday |
5 |
L |
root (/) |
3rd Sunday |
0 |
n tapes |
/usr |
3rd Sunday |
0 |
" |
/export |
3rd Sunday |
0 |
" |
/export/home |
3rd Sunday |
0 |
" |
|
3rd Monday |
9 |
M |
|
3rd Tuesday |
9 |
N |
|
3rd Wednesday |
5 |
O |
|
3rd Thursday |
9 |
P |
|
3rd Friday |
9 |
Q |
|
3rd Saturday |
5 |
R |
root (/) |
4th Sunday |
0 |
n tapes |
/usr |
4th Sunday |
0 |
" |
/export |
4th Sunday |
0 |
" |
/export/home |
4th Sunday |
0 |
" |
|
4th Monday |
9 |
S |
|
4th Tuesday |
9 |
T |
|
4th Wednesday |
5 |
U |
|
4th Thursday |
9 |
V |
|
4th Friday |
9 |
W |
|
4th Saturday |
5 |
X |
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:
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.
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).
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.
On the first Wednesday, use tape C to do a level 5 backup. ufsdump copies all files changed since Sunday.
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.
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.
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.
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.
Table 33-14 provides other suggestions for scheduling backups.
Table 33-14 Other Suggestions for Scheduling Backing Up Systems
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 back up file systems begins with planning, which is described in Chapter 33, Backing Up and Restoring File Systems (Overview) and covers choosing:
A tape drive
Which file systems to back up
The type of backup (full or incremental)
A backup schedule
This section describes other tasks you may need to perform before backing up file systems including:
Finding names of file systems to back up
Determining the number of tapes for a full backup
Display the contents of the /etc/vfstab file.
$ more /etc/vfstab |
Look in the mount point column for the name of the file system.
You will use the mount point in the mount point column when you back up the file system.
$ 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 - |
Become superuser.
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. |
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.
In this example, the file system of 489,472 bytes will easily fit on a 150-Mbyte tape.
# ufsdump S /export/home 489472 |
The following are general guidelines for performing backups:
Use single-user mode or unmount the file system.
Be aware that backing up file systems when there are directory-level operations (such as creating, removing, and renaming files) and file-level activity occurring means that some data will not be included in the backup.
You can run the ufsdump command from a single system and remotely back up groups of systems across the network through remote shell or remote login, and direct the output to the system on which the tape drive is located. (Typically, the tape drive is located on the system from which you run the ufsdump command, but it does not have to be.)
Another way to back up files to a remote drive is to pipe the output from the ufsdump command to the dd command. See Chapter 37, Copying UFS Files and File Systems (Tasks) for information about using the dd command.
If you are doing remote backups across the network, the system with the tape drive must have entries in its /.rhosts file for each client that will be using the drive. Also, the system initiating the backup must be included in the /.rhosts file on each system it will back up.
To specify a remote drive on a system, use the naming convention that matches the OS release of the system with the remote tape drive. For example, use /dev/rst0 for a remote drive on a system running the SunOS 4.1.1 release or compatible versions; use /dev/rmt/0 for a system running the Solaris 7 release or compatible versions.
Use the nisbackup command to backup a NIS+ master server running the Solaris 2.5 release or compatible versions. See Solaris Naming Administration Guide for information on using this command.
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.
Become superuser.
Bring the system to run level S (single-user mode).
# shutdown -g30 -y |
[Optional] Check the file system for consistency with the fsck command.
Running the fsck -m command checks for consistency of file systems. For example, power failures can leave files in an inconsistent state. For more information on the fsck command, see Chapter 31, Checking File System Integrity.
# fsck -m /dev/rdsk/ device-name |
If you need to back up file systems to a remote tape drive:
On the system to which the tape drive is attached (the tape server), add the following entry to its /.rhosts file.
host root |
host |
Specifies the name of the system on which you will run ufsdump to perform the backup. |
On the tape server, verify that the host added to the /.rhosts file is accessible through the name service.
Identify the device name of the tape drive.
The default tape drive is /dev/rmt/0.
Insert a tape that is not write protected into the tape drive.
Back up file systems using the ufsdump command.
Use the following table to select the most common options and arguments for the ufsdump command. See Chapter 36, The ufsdump and ufsrestore Commands (Reference) for other options and arguments.
To ... |
Use This Option or Argument ... |
For Example ... |
See ... |
---|---|---|---|
Do a full backup |
0 option |
ufsdump 0ucf /dev/rmt/0 / | |
Do an incremental backup |
1-9 option |
ufsdump 9ucf /dev/rmt/0 / | |
Back up individual files |
Specify a file or directory |
ufsdump ucf /dev/rmt/0 /export/home/kryten |
|
Record dumps to /etc/dumpdates file |
-u option |
ufsdump 9ucf /dev/rmt/0 /export/home | |
Specify a cartridge tape |
-c option |
ufsdump 9ucf /dev/rmt/0 /export/home | |
Specify the tape drive |
-f dump-file |
ufsdump 9ucf /dev/rmt/0 /export/home | |
Back up local file systems to a remote system's tape device |
remote-system:dump-file |
ufsdump 0ucf pluto:/dev/rmt/0 /export/home |
"Example--Full Backup to Remote System (Solaris 2.6 Data to Solaris 7 System)" |
If prompted, remove the tape and replace with the next volume.
Label each tape with the volume number, level, date, system name, disk slice, and file system.
Bring the system back to run level 3 by pressing Control-d.
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).
The following example shows a full backup of the root (/) file system to a QIC-150 tape (/dev/rmt/0).
# shutdown -g30 -y # ufsdump 0ucf /dev/rmt/0 / DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: Tue Jun 09 10:14:54 1998 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t3d0s0 (pluto:/) to /dev/rmt/0. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 73708 blocks (35.99MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: Tape rewinding DUMP: 73582 blocks (35.93MB) on 1 volume at 100 KB/sec DUMP: DUMP IS DONE DUMP: Level 0 dump on Tue Jun 09 10:14:54 1998 # ufsrestore tf /dev/rmt/0 2 . 3 ./lost+found 5696 ./usr 11392 ./export 17088 ./export/home 22784 ./export/root 28480 ./export/swap 34176 ./opt 39872 ./var 45568 ./var/sadm 51264 ./var/sadm/install 56960 ./var/sadm/install/admin 57011 ./var/sadm/install/admin/default . . . # (Press Control-d to bring system to run level 3) |
The following example shows an incremental backup of the root (/) file system to a 4-mm DAT tape (/dev/rmt/0).
# ufsdump 9ucf /dev/rmt/0 / DUMP: Writing 63 Kilobyte records DUMP: Date of this level 9 dump: Tue Jun 09 11:04:41 1998 DUMP: Date of last level 0 dump: Tue Jun 09 10:14:54 1998 DUMP: Dumping /dev/rdsk/c0t3d0s0 (pluto:/) to /dev/rmt/0. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Mapping (Pass II) [directories] DUMP: Mapping (Pass II) [directories] DUMP: Mapping (Pass II) [directories] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 1502 blocks (751KB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: Tape rewinding DUMP: 1384 blocks (692KB) on 1 volume at 51 KB/sec DUMP: DUMP IS DONE DUMP: Level 9 dump on Tue Jun 09 11:04:41 1998 # ufsrestore tf /dev/rmt/0 39872 ./var 62671 ./var/adm 39915 ./var/adm/sa 40018 ./var/adm/sa/sa09 62810 ./var/adm/sulog 62888 ./var/adm/pacct 91154 ./var/cron 91311 ./var/cron/log 5716 ./var/mail 5835 ./var/mail/adm 45585 ./var/spool 51388 ./var/spool/mqueue 91155 ./var/tmp . . . |
The following example shows a full backup of the /export/home/kryten directory to a 4-mm DAT tape.
# ufsdump 0ucf /dev/rmt/0 /export/home/kryten DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: Tue Jun 09 11:12:44 1998 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t3d0s7 (pluto:/export/home) to /dev/rmt/0. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 232 blocks (116KB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: Tape rewinding DUMP: 124 blocks (62KB) on 1 volume at 8 KB/sec DUMP: DUMP IS DONE # ufsrestore tf /dev/rmt/0 2 . 2688 ./kryten 5409 ./kryten/letters 5410 ./kryten/letters/letter1 5411 ./kryten/letters/letter2 5412 ./kryten/letters/letter3 2689 ./kryten/.profile 8096 ./kryten/memos 30 ./kryten/reports 31 ./kryten/reports/reportA 32 ./kryten/reports/reportB 33 ./kryten/reports/reportC # |
The following example shows a full backup of a local /export/home file system on a Solaris 2.6 system to a tape device on a remote Solaris 7 system called pluto.
# ufsdump 0ucf pluto:/dev/rmt/0 /export/home # ufsdump 0ucf pluto:/dev/rmt/0 /export/home DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: Tue Jun 09 13:54:27 1998 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t3d0s7 (venus:/export/home) to pluto:/dev/rmt/0. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 38310 blocks (18.71MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: Tape rewinding DUMP: 38302 blocks (18.70MB) on 1 volume at 98 KB/sec DUMP: DUMP IS DONE DUMP: Level 0 dump on Tue Jun 09 13:54:27 1998 # # ufsrestore tf pluto:/dev/rmt/0 2 . 3 ./lost+found 34180 ./kryten 34182 ./kryten/.login 34183 ./kryten/.cshrc 51266 ./kryten/letters 51272 ./kryten/letters/letter1 51273 ./kryten/letters/letter2 51274 ./kryten/letters/letter3 57032 ./kryten/memos 74095 ./kryten/reports 74096 ./kryten/reports/reportA 74097 ./kryten/reports/reportB 74098 ./kryten/reports/reportC . . . # |
The following example shows a full backup of a local /export/home file system on a Solaris 7 system to a tape device on a remote SunOS 4.1.3 system (mars).
Notice the SunOS 4.x-style device name (/dev/rst0) used with the ufsdump command.
# ufsdump 0ucf mars:/dev/rst0 /export/home DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: Fri Oct 24 15:06:47 1997 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t3d0s7 (earth:/export/home) to (mars:/dev/rst0). DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 19574 blocks (9.56MB) DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: level 0 dump on Fri Oct 24 15:06:47 1997 DUMP: Tape rewinding DUMP: 19574 blocks (9.56MB) on 1 volume DUMP: DUMP IS DONE # ufsrestore tf mars:/dev/rst0 2 . 3 ./lost+found 2688 ./kryten 5409 ./kryten/letters 5410 ./kryten/letters/letter1 5411 ./kryten/letters/letter2 5412 ./kryten/letters/letter3 2689 ./kryten/.profile 8096 ./kryten/memos 30 ./kryten/reports 31 ./kryten/reports/reportA 32 ./kryten/reports/reportB 33 ./kryten/reports/reportC . . . # |
The following example shows a full backup of a local root (/) file system on a Sun 4.1.3 system (mars) to a remote tape device on a Solaris 7 system called pluto.
Notice that when you back up data on a system running SunOS 4.1.3 or a compatible version, you must use the dump command--not the ufsdump command.
# dump 0ucf pluto:/dev/rmt/0 / DUMP: Date of this level 0 dump: Tue Oct 21 16:05:19 1997 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rsd2a (/) to /dev/rmt/0 on host pluto DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 8686 blocks (4.24MB) on 0.10 tape(s). DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: level 0 dump on Tue Oct 21 16:05:19 1997 DUMP: Tape rewinding DUMP: 8690 blocks (4.24MB) on 1 volume DUMP: DUMP IS DONE # restore tf pluto:/dev/rmt/0 2 . 3 ./lost+found 3776 ./export 7552 ./home 11328 ./usr 15104 ./pcfs 3777 ./tftpboot 3778 ./tftpboot/tftpboot 3794 ./tftpboot/boot.sun4c.sunos.4.1.3 7553 ./etc 7554 ./etc/sendmail.cf 7555 ./etc/aliases 7556 ./etc/aliases.dir 7557 ./etc/aliases.pag 7558 ./etc/holidays 7559 ./etc/dumpdates . . . # |
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.
The ufsrestore command copies files to disk, relative to the current working directory, from backups created using the ufsdump command. You can use ufsrestore to reload an entire file system hierarchy from a level 0 dump and incremental dumps that follow it or to restore one or more single files from any dump tape. If ufsrestore is run as superuser, files are restored with their original owner, last modification time, and mode (permissions).
Before you start to restore files or file systems, you need to know:
Which tapes (or diskettes) you need
The raw device name on which you want to restore the file system
The type of tape drive you will use
The device name (local or remote) for the tape drive
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.
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.
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.
Occasionally, a file system becomes so damaged that you must completely restore it. Typically, you need to restore a complete file system after a disk head crash. You may need to replace the hardware before you can restore the software. See Chapter 23, SPARC: Adding a Disk (Tasks) or Chapter 24, x86: Adding a Disk (Tasks) for information on how to replace a disk. Fully restoring a file system such as /export/home can take a lot of time. If you have consistently backed up file systems, you can restore them to their state as of the last incremental backup.
When you back up files and directories, they are saved relative to the file system in which they belong. When you restore files and directories, ufsrestore recreates the file hierarchy in the current working directory. For example, files backed up from the /export/doc/books directory (where /export is the file system), would be saved relative to /export. In other words, the book1 file in the docs directory would be saved as ./doc/books/book1 on the tape. Later on, if you restored the ./doc/books/book1 file to the /var/tmp directory, the file would be restored to /var/tmp/doc/books/book1.
When restoring individual files and directories, it is a good idea to restore them to a temporary location, such as the /var/tmp directory. After you verify them, you can move the files to their proper locations. You can restore individual files and directories to their original locations. If you do so, be sure you are not overwriting newer files with older versions from the backup tape.
Do not restore files in the /tmp directory even temporarily. The /tmp directory is usually mounted as a TMPFS file system and TMPFS does not support UFS file system attributes such as ACLs.
Things you need to know:
Which tapes have the files to be restored
The path name of the files to be restored
Ask the user the approximate date the files to be recovered were last modified.
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.
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. |
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.
If you have multiple dump files on the same tape, use the s /dev/rmt/n option to position the tape at the dump you want to use.
# ufsrestore tfs /dev/rmt/n tape_number |
If you use ufsdump to dump the /usr file system, the table of contents lists only the files and directories under /usr. The following example checks if /usr/bin/pwd is in the online archive.
# ufsrestore ta archive-name ./bin/pwd |
The following example checks if /usr/bin/pwd is on the backup tape.
# ufsrestore tf /dev/rmt/n ./bin/pwd |
Become superuser.
Write-protect the tape.
Insert the volume 1 tape into the tape drive.
Change to a directory that will be used to restore the files temporarily.
# cd /var/tmp |
To avoid conflicts with other users, you may want to create and change to a subdirectory, such as /var/tmp/restore, in which to restore the files.
If you are restoring a hierarchy, you should restore the files in a temporary directory on the same file system where the files will reside, so you can use the mv command to move the entire hierarchy where it belongs after it is restored.
Use the ufsrestore command to start the interactive restoration.
Some informational messages and the ufsrestore> prompt are displayed.
# ufsrestore if /dev/rmt/n |
Create a list of files to be restored.
List the contents of a directory.
ufsrestore> ls directory |
Change to a directory.
ufsrestore> cd directory-name |
Create a list of files and directories you want to restore.
ufsrestore> add filename filename |
(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 |
(Optional) Turn on verbose mode to display the file names as they are being restored.
ufsrestore> verbose |
Use the extract command after the list is complete.
ufsrestore> extract |
The ufsrestore command asks you which volume number to use.
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.
To keep the mode of the current directory unchanged, enter n at the set owner/mode prompt.
set owner/mode for `.'? [yn] n |
A delay will occur while ufsrestore performs its final cleanup.
Quit the ufsrestore program.
ufsrestore> quit |
The shell prompt is displayed.
Verify the restored files.
The following example extracts the files /etc/passwd and /etc/shadow from the backup tape.
# cd /var/tmp # ufsrestore if /dev/rmt/0 ufsrestore> ls .: .cpr_config etc/ lost+found/ sbin/ usr/ TT_DB/ export/ mnt/ sccs/ var/ b/ home/ net/ share/ vol/ bin kernel/ opt/ shared/ ws/ dev/ lib platform/ src/ xfn/ devices/ license/ proc/ tmp/ ufsrestore> cd etc ufsrestore> add passwd shadow ufsrestore> verbose verbose mode on ufsrestore> extract Extract requested files You have not read any volumes yet. Unless you know which volume your file(s) are on you should start with the last volume and work towards the first. Specify next volume #: 1 extract file ./etc/shadow extract file ./etc/passwd Add links Set directory mode, owner, and times. set owner/mode for `.'? [yn] n ufsrestore> quit # |
Become superuser.
Write-protect the tape for safety.
Insert the volume 1 tape into the tape drive.
Change to a directory for restoring files temporarily.
# cd /var/tmp |
To avoid conflicts with other users, you may want to create and change to a subdirectory, such as /var/tmp/restore, in which to restore the files.
If you are restoring a hierarchy, you should restore the files in a temporary directory on the same file system where the files will reside, so you can use the mv command to move the entire hierarchy where it belongs after it is restored.
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. |
Type the volume number where files are located and press Return.
Specify next volume #: 1 |
The file is restored to the current working directory.
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 |
Verify the restored files.
The following example restores the passwd and shadow files to the /var/tmp directory.
# cd /var/tmp # ufsrestore xvf /dev/rmt/0 ./etc/passwd ./etc/shadow Verify volume and initialize maps Media block size is 126 Dump date: Tue Jun 09 14:30:16 1998 Dumped from: the epoch Level 0 dump of / on pluto:/dev/dsk/c0t3d0s0 Label: none Extract directories from tape Initialize symbol table. Warning: ./etc: File exists Extract requested files You have not read any volumes yet. Unless you know which volume your file(s) are on you should start with the last volume and work towards the first. Specify next volume #: 1 extract file ./etc/passwd Add links Set directory mode, owner, and times. set owner/mode for `.'? [yn] n Directories already exist, set modes anyway? [yn] n # cd etc # mv passwd /etc # mv shadow /etc # ls -l etc |
You can restore files from a remote tape drive by adding remote-host: to the front of the tape device name when using the ufsrestore command.
ufsrestore xf [user@]remote-host:/dev/rmt/n filename |
The following example restores files using a remote tape drive /dev/rmt/0 on the system venus.
# ufsrestore xf venus:/dev/rmt/0 filename |
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.
If necessary, unmount the file system.
# umount /dev/rdsk/device-name |
Create the new file system with the newfs(1M) command.
# newfs /dev/rdsk/device-name |
You are asked if you want to construct a new file system on the raw device. Verify that the device-name is correct so you don't wipe out the wrong file system.
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.
Mount the new file system on a temporary mount point.
# mount /dev/dsk/device-name /mnt |
Change to the /mnt directory.
# cd /mnt |
You have changed to the mount-point directory.
Write-protect the tapes.
Insert the first volume of the level 0 tape into the tape drive.
Use the ufsrestore command to restore the files on the tapes.
# ufsrestore rvf /dev/rmt/n |
The level 0 dump is restored. If the dump required multiple tapes, you will be prompted to load each tape in order.
Remove the tape and load the next level tape in the drive.
Always restore tapes starting with 0 and continuing until you reach the highest level.
Repeat Step 7 through Step 10 for each level of dump, from the lowest to the highest level.
Verify the file system is restored.
# ls |
Remove the restoresymtable file.
# rm restoresymtable |
The restoresymtable file created by ufsrestore is removed.
Change to another directory.
# cd / |
Unmount the newly restored file system.
# umount /mnt |
Remove the last tape and insert a new tape that is not write-protected in the tape drive.
Use the ufsdump command to make a level 0 backup of the newly restored file system.
# ufsdump 0uf /dev/rmt/n /dev/rdsk/device-name |
You should always do an immediate backup of a newly created file system, because ufsrestore repositions the files and changes the inode allocation (the restored file system will appear to have changed since the previous backup).
Mount the restored file system.
# mount /dev/dsk/device-name mount-point |
The restored file system is mounted and available for use.
Verify the restored and mounted file system is available.
# ls mount-point |
The following example restores the /export/home file system.
# umount /export/home # newfs /dev/rdsk/c0t3d0s7 newfs: construct a new file system /dev/rdsk/c0t3d0s7: (y/n)? y /dev/rdsk/c0t3d0s7: 410400 sectors in 270 cylinders of 19 tracks, 80 sectors 200.4MB in 17 cyl groups (16 c/g, 11.88MB/g, 5696 i/g) super-block backups (for fsck -F ufs -o b=#) at: 32, 24432, 48832, 73232, 97632, 122032, 146432, 170832, 195232, 219632, 244032, 268432, 292832, 317232, 341632, 366032, 390432, # mount /dev/dsk/c0t3d0s7 /mnt # cd /mnt # ufsrestore rvf /dev/rmt/0 Verify volume and initialize maps Media block size is 126 Dump date: Tue Jun 09 15:01:03 1998 Dumped from: the epoch Level 0 dump of /export/home on pluto:/dev/dsk/c0t3d0s7 Label: none Begin level 0 restore Initialize symbol table. Extract directories from tape Calculate extraction list. Warning: ./lost+found: File exists Make node ./kryten Make node ./kryten/letters Make node ./kryten/memos Make node ./kryten/reports Make node ./rimmer Make node ./rimmer/sc.directives Make node ./rimmer/tests Make node ./rimmer/answers Extract new leaves. Check pointing the restore # ls # rm restoresymtable # cd / # umount /mnt # ufsdump 0ucf /dev/rmt/0 /export/home . . . # mount /dev/dsk/c0t3d0s7 /export/home # ls /export/home |
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).
Mount the new file system on a temporary mount point.
# mount /dev/dsk/device-name /mnt |
Change to the /mnt directory.
# cd /mnt |
Write-protect the tapes.
Use the ufsrestore command to restore the root file system.
# ufsrestore rvf /dev/rmt/n |
The level 0 tape is restored.
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.
Continue to use the ufsrestore command as needed.
# ufsrestore rvf /dev/rmt/n |
The next level tape is restored.
Verify the file system is restored.
# ls |
Remove the restoresymtable file.
# rm restoresymtable |
Removes the restoresymtable file that is created and used by ufsrestore to check point the restore.
Change to the root (/) directory.
# cd / |
Unmount the newly created file system.
# umount /mnt |
Check the new file system.
# fsck /dev/rdsk/device-name |
The restored file system is checked for consistency.
Create the boot blocks on the root partition by using the installboot(1M) command.
# installboot /usr/platform/`uname-i`/lib/fs/ufs/bootblk /dev/rdsk/devicename |
See "Example--Restoring the root (/) File System on a SPARC System" for an example of using the installboot command on a SPARC system or "Example--Restoring the root (/) File System on an x86 System" for an example of using the installboot command on an x86 system.
Insert a new tape in the tape drive.
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.
Repeat steps 5 through 18 for the /usr file system, if necessary.
Reboot the system.
# init 6 |
The system is rebooted.
# mount /dev/dsk/c0t3d0s0 /mnt # cd /mnt # tapes # ufsrestore rvf /dev/rmt/0 # ls # rm restoresymtable # cd / # umount /mnt # fsck /dev/rdsk/c0t3d0s0 # installboot /usr/platform/sun4m/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0 # ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t3d0s0 # init 6 |
# 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 |
This chapter contains reference information on the ufsdump and ufsrestore commands.
This is a list of reference information in this chapter.
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.
The ufsdump command needs to know only an appropriate block size and how to detect 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.
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.
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 ufsdump command, when used with the -u option, maintains and updates the /etc/dumpdates file. Each line in /etc/dumpdates shows the file system backed up, the level of the last backup, and the day, date, and time of the backup. Here is a typical /etc/dumpdates file from a file server:
/dev/rdsk/c0t3d0s0 0 Tue Jun 9 14:30:16 1998 /dev/rdsk/c0t3d0s0 9 Tue Jun 9 11:04:41 1998 /dev/rdsk/c0t3d0s7 0 Tue Jun 9 13:54:27 1998 |
When you do an incremental backup, the ufsdump command consults /etc/dumpdates to find the date of the most recent backup of the next lower level. Then it copies to the media all files that were modified since the date of that lower-level backup. After the backup is complete, a new information line, describing the backup you just completed, replaces the information line for the previous backup at that level.
Use the /etc/dumpdates file to verify that backups are being done. This verification is particularly important if you are having equipment problems. If a backup cannot be completed because of equipment failure, the backup is not recorded in the /etc/dumpdates file.
If you need to restore an entire disk, check the /etc/dumpdates file for a list of the most recent dates and levels of backups so that you can determine which tapes you need to restore the entire file system.
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.
The dump-file argument (to the -f option) specifies the destination of the backup, which can be one of the following:
Local tape drive or diskette drive
Remote tape drive or diskette drive
Standard output
Use this argument when the destination is not the default local tape drive /dev/rmt/0. If you use the -f option, then you must specify a value for dump-file.
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.
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.
You specify a remote tape or diskette drive using the syntax host:device. ufsdump writes to the remote device when root on the local system has access to the remote system. If you usually run ufsdump as root, the name of the local system must be included in the /.rhosts file on the remote system. If you specify the device as user@host:device, ufsdump tries to access the device on the remote system as the specified user. In this case, the specified user must be included in the /.rhosts file on the remote system.
Use the naming convention for the device that matches the operating system for the system on which the device resides, not the system from which you run the ufsdump command. If the drive is on a system that is running a previous SunOS release (for example, 4.1.1), use the SunOS 4.1 device name (for example, /dev/rst0). If the system is running Solaris software, use the SunOS 5.7 convention (for example, /dev/rmt/0).
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.
When you specify a dash (-) as the dump-file argument, ufsdump writes to the standard output.
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 -) |
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.
When you use ufsdump to back up one or more directories or files (rather than a whole file system), a level 0 backup is done. Incremental backups do not apply.
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.
If you do not specify any tape characteristics, the ufsdump command uses a set of defaults. You can specify tape cartridge (c), density (d), size (s), and number of tracks (t). Note that you can specify the options in any order as long as the arguments that follow match the order of the options.
Table 36-1 lists tasks you cannot perform with the ufsdump command.
Table 36-1 Tasks You Cannot Perform With the ufsdump Command
The ufsdump Command Does Not ... |
Comments |
---|---|
Automatically calculate the number of tapes or diskettes needed for backing up file systems |
You can use the dry run mode (S option) to determine the amount of space that is needed before actually backing up file systems. |
Provide built-in error checking to minimize problems when backing up an active file system |
-- |
Enable you to back up files that are remotely mounted from a server |
Files on the server must be backed up on the server itself. Users are denied permission to run ufsdump on files they own that are located on a server. |
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. |
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.
Table 36-2 describes the options for the ufsdump command.
Table 36-2 Options for the ufsdump Command
Option |
Description |
---|---|
0-9 |
Backup level. Level 0 is for a full backup of the whole file system specified by files-to-backup. Levels 1-9 are for incremental backups of files that have changed since the last lower-level backup. |
a archive-file |
Archive file. Store (archive) a backup table of contents in a specified file on the disk. The file can be understood only by ufsrestore, which uses it to determine whether a file to be restored is present in a backup file, and if so, on which volume of the media it resides. |
b factor |
Blocking factor. The number of 512-byte blocks to write to tape at a time. |
c |
Cartridge. Back up to cartridge tape. When end-of-media detection applies, this option sets the block size to 126. |
d bpi |
Tape density. You need to use this option only when ufsdump cannot detect the end of the media. |
D |
Diskette. Back up to diskette. |
f dump-file |
Dump file. Write the files to the destination specified by dump-file instead of the default device. If the file is specified as user@system:device, ufsdump attempts to execute as the specified user on the remote system. The specified user must have a /.rhosts file on the remote system that allows the user invoking the command on the local system to access the remote system. |
l |
Autoload. Use this option if you have an autoloading (stackloader) tape drive. When the end of a tape is reached, this option takes the drive offline and waits up to two minutes for the tape drive to be ready again. If the drive is ready within two minutes, it continues. If it is not ready after two minutes, it prompts the operator to load another tape. |
n |
Notify. When intervention is needed, send a message to all terminals of all users in the sys group. |
o |
Offline. When finished with a tape or diskette, take the drive offline, rewind (if tape), and if possible remove the media (for example, eject a diskette or remove 8-mm autoloaded tape). |
s size |
Size. Specify the length of tapes in feet or number of 1024-byte blocks for diskettes. You need to use this option only when ufsdump cannot detect the end of the media. |
S |
Estimate size of backup. Determine the amount of space that is needed to perform the backup, without actually doing it, and output a single number indicating the estimated size of the backup in bytes. |
t tracks |
Tracks. Specify the number of tracks for 1/4-inch cartridge tape. You need to use this option only when ufsdump cannot detect the end of the media. |
u |
Update the dump record. For a completed backup on a file system, add an entry to the /etc/dumpdates file. The entry indicates the device name for the file system's disk slice, the backup level (0-9), and the date. No record is written when you do not use the u option or when you back up individual files or directories. If a record already exists for a backup at the same level, it is replaced. |
v |
Verify. After each tape or diskette is written, verify the contents of the media against the source file system. If any discrepancies occur, prompt the operator to mount new media, then repeat the process. Use this option on an unmounted file system only, because any activity in the file system causes it to report discrepancies. |
w |
Warning. List the file systems appearing in /etc/dumpdates that have not been backed up within a day. When you use this option all other options are ignored. |
W |
Warning with highlight. Show all the file systems that appear in /etc/dumpdates and highlight those file systems that have not been backed up within a day. When you use this option all other options are ignored. |
The /etc/vfstab file does not contain information about how often to back up a file system.
If you are concerned about security:
Require root access for the ufsdump command.
Ensure root access entries are removed from /.rhosts files on clients and servers if doing centralized backups.
For general information on security, see "Managing System Security (Overview)" in System Administration Guide, Volume II.
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. |
You must use one (and only one) of the ufsrestore options shown in Table 36-3.
Table 36-3 One Required Option for the ufsrestore Command
Option |
Description |
---|---|
i |
Interactive. Runs ufsrestore in an interactive mode. In this mode, you can use a limited set of shell-like commands to browse the contents of the media and select individual files or directories to restore. See "Commands for Interactive Restore" for a list of available commands. |
r |
Recursive. Restores the entire contents of the media into the current working directory (which should be the top level of the file system). Information used to restore incremental dumps on top of the full dump (e.g., restoresymtable) is also included. To completely restore a file system, use this option to restore the full (level 0) dump and each subsequent incremental dump. Although intended for a new file system (one just created with the newfs command), files not on the backup media are preserved. |
R |
Resume restoring. Prompts for the volume from which to resume restoring and restarts from a checkpoint. You rerun the ufsrestore command with this option after a full restore (r option) is interrupted. |
x [filename...]
|
Extract. Selectively restores the files you specify by the filename argument. filename can be a list of files and directories. All files under a specified directory are restored unless you also use the h option also. If you omit filename or enter "." for the root directory, all files on all volumes of the media (or from standard input) are restored. Existing files are overwritten, and warnings are displayed. |
t [filename...] |
Table of contents. Checks the files specified in the filename argument against the media. For each file, lists the full file name and the inode number (if the file is found) or indicates the file is not on the "volume" (meaning any volume in a multivolume dump). If you do not enter the filename argument, all files on all volumes of the media are listed (without distinguishing on which volume files are located). If you also use the h option, only the directory files specified in filename, not their contents, are checked and listed. The table of contents is read from the first volume of the media, or, if you use the a option, from the specified archive file. This option is mutually exclusive with the x and r options. |
In addition to one of the options shown in Table 36-3, you can choose from the options shown in Table 36-4.
Table 36-4 Additional Options for the ufsrestore Command
Option |
Description |
---|---|
a archive-file [filename...] |
Takes the dump table of contents from the specified archive-file instead of from the media (first volume). You can use this option in combination with the t, i, or x options to check for the files in the dump without having to mount any media. If you use it with the x and interactive extract options, you will be prompted to mount the appropriate volume before extracting the file(s). |
b factor |
Blocking factor. Number of 512-byte blocks read from tape at a time. By default, ufsrestore tries to figure out the block size that was used in writing the tape. |
d |
Debug. Turn on debugging messages. |
f backup-file |
Backup file. Reads the files from the source indicated by backup-file, instead of from the default device file /dev/rmt/0m. If you use the f option, you must specify a value for backup-file. When backup-file is of the form system:device, ufsrestore reads from the remote device. You can also use the backup-file argument to specify a file on a local or remote disk. If backup-file is `-', the files are read from standard input. |
h |
Turns off directory expansion. Only the directory file you specify is extracted or listed. |
m |
Restores specified files into the current directory on the disk regardless of where they are located in the backup hierarchy and renames them with their inode number. For example, if the current working directory is /files, a file in the backup named ./dready/fcs/test with inode number 42, is restored as /files/42. This option is useful only when you are extracting a few files. |
s n |
Skips to the nth backup file on the media (first volume). This option is useful when you put more than one backup on a single tape. |
v |
Verbose. Displays the names and inode numbers of each file as it is restored. |
y |
Continues when errors occur reading the media and tries to skip over bad blocks instead of stopping and asking whether to continue. This option tells the command to assume a yes response. |
Option |
Description |
---|---|
ls [directory-name] |
Lists the contents of either the current directory or the specified directory. Directories are marked by a / suffix and entries in the current list to be restored (extracted) are marked by an * prefix. Inode numbers are shown if the verbose option is used. |
cd directory-name |
Changes to the specified directory in the backup hierarchy. |
add [filename] |
Adds the current directory or the specified file or directory to the list of files to extract (restore). If you do not use the h option, all files in a specified directory and its subdirectories are added to the list. Note that all the files you want to restore to a directory might not be on a single backup tape or diskette. You might need to restore from multiple backups at different levels to get the latest revisions of all the files. |
delete [filename] |
Deletes the current directory or the specified file or directory from the list of files to extract (restore). If you do not use the h option, all files in the specified directory and its subdirectories are deleted from the list. Note that the files and directories are deleted only from the extract list you are building. They are not deleted from the media or the file system. |
extract |
Extracts the files in the list and restores them relative to the current working directory on the disk. Specify 1 when asked for a volume number for a single-volume backup. If you are doing a multitape or multidiskette restore and restoring a small number of files, start with the last tape or diskette instead. |
help |
Displays a list of commands you can use in interactive mode. |
pwd |
Displays the path name of the current working directory in the backup hierarchy. |
q |
Quits interactive mode without restoring any additional files. |
setmodes |
Lets you set the mode for files to be restored to match the mode of the root directory of the file system from which they were backed up. You are prompted with: set owner/mode for '.' [yn]? Type y (for yes) to set the mode (permissions, owner, times) of the current directory to match the root directory of the file system from which they were backed up. Use this mode when restoring a whole file system. Type n (for no) to leave the mode of the current directory unchanged. Use this mode when restoring part of a backup to a directory other than the one from which the files were backed up. |
verbose |
Turns on or off the verbose option (which can also be entered as v on the command line outside of interactive mode). When verbose is on, the interactive ls command lists inode numbers and the ufsrestore command displays information on each file as it is extracted. |
what |
Displays the backup header from the tape or diskette. |
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.
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 | ||
Restore file systems from tape | ||
Transport files to other systems | ||
Copy files or file systems between disks | ||
Copy files to diskette |
Table 37-2 describe various backup and restore commands.
Table 37-2 Summary of Various Backup Commands
Command Name |
Aware of File System Boundaries? |
Support Multi-Volume Backups? |
Physical or Logical Copy? |
---|---|---|---|
volcopy |
Yes |
Yes |
Physical |
tar |
No |
No |
Logical |
cpio |
No |
Yes |
Logical |
pax |
Yes |
Yes |
Logical |
dd |
Yes |
No |
Physical |
ufsdump/ufsrestore |
Yes |
Yes |
Logical |
The following sections describe the advantages and disadvantages of each method and provide examples of how to use the commands.
Two commands are used to copy file systems between disks:
volcopy
dd
The next section describes how to use the dd command to copy file systems between disks.
The dd command makes a literal (block-level) copy of a complete UFS file system to another file system or to a tape. By default, the dd command copies its standard input to its standard output.
Do not use the dd command with variable-length tape drives without specifying an appropriate block size.
You can specify a device name in place of the standard input or the standard output or both. In this example, contents of the diskette are copied to a file in the /tmp directory:
$ dd < /floppy/floppy0 > /tmp/output.file 2400+0 records in 2400+0 records out |
The dd command reports on the number of blocks it reads and writes. The number after the + is a count of the partial blocks that were copied. The default block size is 512 bytes.
The dd command syntax is different from most other commands. Options are specified as keyword=value pairs, where keyword is the option you want to set and value is the argument for that option. For example, you can replace the standard input and output with this syntax:
$ dd if=input-file of=output-file |
For example, to use the keyword=value pairs instead of the redirect symbols in the previous example, you would type:
$ dd if=/floppy/floppy0 of=/tmp/output.file |
Make sure the source and destination disks have the same disk geometry.
Become superuser.
Create the /reconfigure file on the system so the system will recognize the clone disk to be added when it reboots.
# touch /reconfigure |
Shut down the system.
# init 0 |
Attach the clone disk to the system.
Boot the system.
ok boot |
Use the dd command to copy the master disk to the clone disk.
# dd if=/dev/rdsk/device-name of=/dev/rdsk/device-name bs=blocksize |
if=/dev/rdsk/device-name |
Represents the overlap slice of the master disk device, usually slice 2. |
of=/dev/rdsk/device-name |
Represents the overlap slice of the clone disk device, usually slice 2. |
bs=blocksize |
Block size, such as 128 Kbytes or 256 Kbytes. A large block size value will decrease the time to copy. |
Check the new file system.
# fsck /dev/rdsk/device-name |
Mount the clone disk's root (/) file system.
# mount /dev/dsk/device-name /mnt |
Edit the clone disk's /etc/vfstab to reference the correct device names.
For example, changing all instances of c0t3d0 with c0t1d0.
Unmount the clone disk's root (/) file system.
# umount /mnt |
Shut down the system.
# init 0 |
Boot from the clone disk to single-user mode.
# boot diskn -s |
The installboot command is not needed for the clone disk because the boot blocks are copied as part of the overlap slice.
Unconfigure the clone disk.
# sys-unconfig |
The system is shut down after it is unconfigured.
Boot from the clone disk again and provide its system information, such as host name, time zone, etc.
# boot diskn |
Log in as superuser to verify the system information once the system is booted.
hostname console login: |
# init 0 ok boot # dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t2d0s2 bs=128k # fsck /dev/rdsk/c0t2d0s2 # mount /dev/dsk/c0t2d0s2 /mnt # cd /mnt/etc # vi vfstab (Modify entries for the new disk) # cd / # umount /mnt # init 0 # boot disk2 -s # sys-unconfig # boot disk2 |
You can use the cpio (copy in and out) command to copy individual files, groups of files, or complete file systems. This section describes how to use the cpio command to copy complete file systems.
The cpio command is an archiving program that takes a list of files and copies them into a single, large output file. It inserts headers between the individual files to facilitate recovery. You can use the cpio command to copy complete file systems to another slice, another system, or to a media device such as tape or diskette.
Because the cpio command recognizes end-of-media and prompts you to insert another volume, it is the most effective command (other than ufsdump) to use to create archives that require multiple tapes or diskettes.
With cpio, you frequently use commands like ls and find to list and select the files you want to copy and then pipe the output to the cpio command.
Become superuser.
Change to the appropriate directory.
# cd filesystem1 |
Copy the directory tree from filesystem1 to filesystem2 by using a combination of the find and cpio commands.
# find . -print -depth | cpio -pdm filesystem2 |
. |
Starts in the current working directory. |
|
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.
Verify the copy was successful by displaying the destination directory contents.
# cd filesystem2 # ls |
If appropriate, remove the source directory.
# rm -rf filesystem1 |
# cd /data1 # find . -print -depth | cpio -pdm /data2 19013 blocks # cd /data2 # ls # rm -rf /data1 |
See cpio(1) for more information.
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
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.
Things you should know before copying files to tape with the tar command:
Copying files to a tape using the -c option to tar destroys any files already on the tape at or beyond the current tape position.
You can use filename substitution wildcards (? and *) as part of the file names you specify when copying files. For example, to copy all documents with a .doc suffix, type *.doc as the file name argument.
You cannot use filename substitution wildcards for extracting files from a tar archive.
Change to the directory that contains the files you want to copy.
Insert a write-enabled tape into the tape drive.
Copy the files to tape with the tar command.
$ tar cvf /dev/rmt/n filename ... |
c |
Indicates you want to create an archive. |
v |
Displays the name of each file as it is archived. |
f /dev/rmt/n |
Indicates that the archive should be written to the specified device or file. |
filename ... |
Indicates the files and directories you want to copy. |
The file names you specify are copied to the tape, overwriting any existing files on the tape.
Remove the tape from the drive and write the names of the files on the tape label.
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 |
The following example copies three files to the tape in tape drive 0.
$ cd /export/home/kryten $ ls reports reportA reportB reportC $ tar cvf /dev/rmt/0 reports a reports/ 0 tape blocks a reports/reportA 2 tape blocks a reports/reportB 5 tape blocks a reports/reportC 6 tape blocks $ tar tvf /dev/rmt/n |
Insert a tape into the tape drive.
Display the tape contents with the tar command.
$ tar tvf /dev/rmt/n |
t |
Lists the table of contents for the files on the tape. |
v |
Used with the t option, and provides detailed information about the files on the tape. |
f /dev/rmt/n |
Indicates the tape device. |
filename ... |
Indicates the files and directories you want to retrieve. |
The following example lists the files on the tape in drive 0.
$ tar tvf /dev/rmt/0 drwxr-xr-x 101/10 0 Jun 9 15:40 1998 reports/ -rw-r--r-- 101/10 0 Jun 9 15:40 1998 reports/reportA -rw-r--r-- 101/10 0 Jun 9 15:40 1998 reports/reportB -rw-r--r-- 101/10 0 Jun 9 15:40 1998 reports/reportC |
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Retrieve files from the tape using the tar command.
$ tar xvf /dev/rmt/n [filename ...] |
x |
Indicates that files should be extracted from the specified archive file. All of the files on the tape in the specified drive are copied to the current directory. |
v |
Displays the name of each file as it is archived. |
f /dev/rmt/n |
Indicates the tape device containing the archive. |
filename |
Specifies a file to retrieve. |
Verify the files are copied by listing the contents of the current directory.
$ ls -l |
The following example retrieves all the files from the tape in drive 0.
$ cd /var/tmp $ tar xvf /dev/rmt/0 x reports/, 0 bytes, 0 tape blocks x reports/reportA, 0 bytes, 0 tape blocks x reports/reportB, 0 bytes, 0 tape blocks x reports/reportC, 0 bytes, 0 tape blocks x reports/reportD, 0 bytes, 0 tape blocks $ ls -l |
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.
This section describes how to copy files with the pax command.
Change to the directory that contains the files you want to copy.
Insert a write-enabled tape into the tape drive.
Copy the files to tape with the pax command.
$ pax -w -f /dev/rmt/0 filename ... |
-w |
Enables the write mode. |
-f /dev/rmt/0 |
Identifies the tape drive. |
filename ... |
Indicates the files and directories you want to copy. |
Verify the files are copied to tape.
$ pax -f /dev/rmt/0 |
Remove the tape from the drive and write the names of the files on the tape label.
$ pax -w -f /dev/rmt/0 . $ pax -f /dev/rmt/0 filea fileb filec |
See pax(1) for more information.
Insert a tape that is not write-protected into the tape drive.
Copy files to a tape using the ls and cpio commands.
$ ls | cpio -oc > /dev/rmt/n |
ls |
Provides the cpio command with a list of file names. |
cpio -oc |
Specifies that cpio should operate in copy-out mode (-o) and write header information in ASCII character format (-c). This ensures portability to other vendor's systems. |
> /dev/rmt/n |
Specifies the output file. |
All of the files in the directory are copied to the tape in the drive you specify, overwriting any existing files on the tape. The total number of blocks copied is displayed.
Verify the files are copied to tape by using the following cpio command.
$ cpio -civt < /dev/rmt/0 |
Remove the tape from the drive and write the names of the files on the tape label.
The following example copies all of the files in the directory /export/home/kryten to the tape in tape drive 0.
$ cd /export/home/kryten $ ls | cpio -oc > /dev/rmt/0 8 blocks $ cpio -civt < /dev/rmt/0 drwxr-xr-x 2 kryten users 0 Jun 9 15:56 1998, letters drwxr-xr-x 2 kryten users 0 Jun 9 15:56 1998, memos drwxr-xr-x 2 kryten users 0 Jun 9 15:55 1998, reports 8 blocks $ |
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.
Insert an archive tape into the tape drive.
List the files on the tape using the cpio command.
$ cpio -civt < /dev/rmt/n |
-c |
Specifies that cpio should read files in ASCII character format. |
-i |
Specifies that cpio should operate in copy-in mode (even though its only listing files at this point). |
-v |
Displays the output in a format similar to the output from the ls -l command. |
-t |
Lists the table of contents for the files on the tape in the tape drive you specify. |
< /dev/rmt/n |
Specifies the input file of an existing cpio archive. |
The following example lists the files on the tape in drive 0.
$ cpio -civt < /dev/rmt/0 drwxr-xr-x 2 rimmer users 0 Jun 9 16:07 1998, answers drwxr-xr-x 2 rimmer users 0 Jun 9 16:07 1998, sc.directives drwxr-xr-x 2 rimmer users 0 Jun 9 16:07 1998, tests 8 blocks |
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.
Using absolute path names can be dangerous because you may overwrite existing files on your system.
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Copy all files from the tape to the current directory using the cpio command.
$ cpio -icvd < /dev/rmt/n |
-i |
Reads in the contents of the tape. |
-c |
Specifies that cpio should read files in ASCII character format. |
-v |
Displays the files being retrieved in a format similar to the output from the ls command. |
-d |
Create directories as needed. |
< /dev/rmt/n |
Specifies the output file. |
Verify the files are copied by listing the contents of the current directory.
$ ls -l |
The following example retrieves all files from the tape in drive 0.
$ cd /var/tmp cpio -icvd < /dev/rmt/0 answers sc.directives tests 8 blocks $ ls -l |
Change to the directory where you want to put the files.
Insert the tape into the tape drive.
Retrieve a subset of files from a tape using the cpio command.
$ cpio -icv "*file" < /dev/rmt/n |
-i |
Reads in the contents of the tape. |
-c |
Specifies that cpio should read headers in ASCII character format. |
-v |
Displays the files as they are retrieved in a format similar to the output from the ls command. |
"*file" |
Specifies that all of the files that match the pattern are copied to the current directory. You can specify multiple patterns, but each must be enclosed in double quotation marks. |
< /dev/rmt/n |
Specifies the input file. |
Verify the files are copied by listing the contents of the current directory.
$ ls -l |
The following example retrieves all files with the suffix chapter from the tape in drive 0.
$ cd /home/smith/Book $ cpio -icv "*chapter" < /dev/rmt/0 Boot.chapter Directory.chapter Install.chapter Intro.chapter 31 blocks $ ls -l |
See cpio(1) for more information.
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.
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.
To copy files to a remote tape drive use the tar and dd commands.
$ tar cf - files | rsh remotehost dd of=/dev/rmt/n obs=blocksize |
tar cf |
Creates a tape archive and specifies the tape device. |
- (Hyphen) |
Represents a placeholder for the tape device. |
files |
Identifies files to be copied. |
| rsh remotehost |
Pipe the tar command's output to a remote shell to copy the files. |
dd of=/dev/rmt/n |
Represents the output device. |
obs=blocksize |
Represents the blocking factor. |
Remove the tape from the drive and write the names of the files on the tape label.
# tar cvf - * | rsh mercury dd of=/dev/rmt/0 obs=126b a answers/ 0 tape blocks a answers/test129 1 tape blocks a sc.directives/ 0 tape blocks a sc.directives/sc.190089 1 tape blocks a tests/ 0 tape blocks a tests/test131 1 tape blocks 6+9 records in 0+1 records out |
Change to a temporary directory.
$ cd /var/tmp |
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. |
Verify that the files have been extracted.
$ ls -l /var/tmp |
$ 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 |
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.
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").
Copying files to a formatted diskette using the -c option of tar destroys any files already on the diskette.
A diskette that already contains a tar image is not mountable.
Change to the directory that contains the files you want to copy.
Insert a formatted diskette that is not write-protected into the drive.
Make the diskette available using the volcheck command.
$ volcheck |
Unmount any file system on the diskette and reformat it.
$ fdformat -U /vol/dev/aliases/floppy0 |
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.
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 |
Remove the diskette from the drive.
Write the names of the files on the diskette label.
The following example copies two files to a diskette.
$ cd /home/smith $ ls evaluation* evaluation.doc evaluation.doc.backup $ tar cvf /vol/dev/rdiskette0/unlabeled evaluation* a evaluation.doc 86 blocks a evaluation.doc.backup 84 blocks $ tar tvf /vol/dev/rdiskette0/unlabeled |
Insert a diskette into the drive.
Run volcheck to make the diskette available.
$ volcheck |
Use the tar command to list the files on a diskette.
$ tar tvf /vol/dev/rdiskette0/unlabeled |
The following example lists the files on a diskette.
$ tar tvf /vol/dev/rdiskette0/unlabeled rw-rw-rw-6693/10 44032 Jun 9 15:45 evaluation.doc rw-rw-rw-6693/10 43008 Jun 9 15:55 evaluation.doc.backup $ |
See tar(1) for more information.
If you need a multiple-volume interchange utility, use the cpio command. The tar command is only a single-volume utility.
Change to the directory where you want to put the files.
Insert the diskette into the drive.
Run volcheck to make the diskette available.
$ volcheck |
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.
Verify the files have been retrieved by listing the contents of the current directory.
$ ls -l |
Remove the diskette from the drive.
The following example retrieves all the files from a diskette.
$ /home/smith/Evaluations $ tar xvf /vol/dev/rdiskette0/unlabeled x evaluation.doc, 44032 bytes, 86 tape blocks x evaluation.doc.backup, 43008 bytes, 84 tape blocks $ ls -l |
The following example retrieves an individual file from a diskette.
$ tar xvf /vol/dev/rdiskette0/unlabeled evalutation.doc x evaluation.doc, 44032 bytes, 86 tape blocks $ ls -l |
The file names you specify are extracted from the diskette and placed in the current working directory.
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.
Archives created with the SunOS 5.7 cpio command may not be compatible with older SunOS releases. The cpio command allows you to create archives that can be read with several other formats. You specify these formats using the -H option and one of these arguments:
crc or CRC - ASCII header with checksum
ustar or USTAR - IEEE/P1003 Data Interchange
tar or TAR - tar header and format
odc - ASCII header with small device numbers
bar - bar header and format
The syntax for using the header options is:
cpio -o -H header-option < file-list > output-archive |
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.
$ 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.
To retrieve files from diskettes that were archived using the SunOS 4.0/4.1 bar command, use the -H bar option to cpio.
You can only use the -H bar option with -i to retrieve files. You cannot create files with the bar header option.
Change to the directory where you want to put the files.
Insert the diskette into the drive.
Run volcheck to make the diskette available.
$ volcheck |
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 |
This chapter describes how to manage tape drives.
This is a list of the step-by-step instructions in this chapter.
You typically back up Solaris systems using:
1/2-inch reel tape
1/4-inch streaming cartridge tape
8-mm cartridge tape
4-mm cartridge tape (DAT)
You can perform backups using diskettes, but this is time-consuming and cumbersome.
The media you choose depends on the availability of the equipment that supports it and of the media (usually tape) that you use to store the files. Although you must do the backup from a local system, you can write the files to a remote device.
Table 38-1 shows typical media used for backing up file systems and shows the storage capacity for each.
Table 38-1 Media Storage Capacities
You specify a tape or diskette drive to use for backup by supplying a logical device name. This name points to the subdirectory containing the "raw" device file and includes the logical unit number of the drive. Tape drive naming conventions use a logical, not a physical, device name. Table 38-2 shows this naming scheme.
Table 38-2 Basic Device Names for Backup Devices
Device Type |
Name |
---|---|
Tape |
/dev/rmt/n |
Diskette |
/vol/dev/rdiskette0/unlabeled |
In general, you specify a tape drive device as shown in Figure 38-1.
If you don't specify the density, a tape drive will typically write at its "preferred" density, which usually means the highest density it supports. Most SCSI drives can automatically sense the density or format on the tape and read it accordingly. To determine the different densities that are supported for a drive, look at the /dev/rmt subdirectory, which includes the set of tape device files that support different output densities for each tape.
Also, a SCSI controller can have a maximum of seven SCSI tape drives.
Normally, you specify a tape drive by its logical unit number, which may run from 0 to n. Table 38-3 describes how to specify tape device names using default density settings.
Table 38-3 Specifying Default Densities for a Tape Drive
To Specify The ... |
Use ... |
---|---|
First drive, rewinding |
/dev/rmt/0 |
First drive, nonrewinding |
/dev/rmt/0n |
Second drive, rewinding |
/dev/rmt/1 |
Second drive, nonrewinding |
/dev/rmt/1n |
By default, the drive writes at its "preferred" density, which is usually the highest density it supports. If you do not specify a tape device, the command writes to drive number 0 at the default density the device supports.
To transport a tape to a system whose tape drive supports only a certain density, specify a device name that writes at the desired density. Table 38-4 describes how to specify different densities for a tape drive.
Table 38-4 Specifying Different Densities for a Tape Drive
To Specify The ... |
Use ... |
---|---|
First drive, low density, rewinding |
/dev/rmt/0l |
First drive, low density, nonrewinding |
/dev/rmt/0ln |
Second drive, medium density, rewinding |
/dev/rmt/1m |
Second drive, nonrewinding, medium density |
/dev/rmt/1mn |
The unit and density characters are shown in Figure 38-1.
You can use the status option with the mt command to get status information about tape drives. The mt command reports information about any tape drives described in the /kernel/drv/st.conf file.
Load a tape into the drive you want information about.
Display tape drive status with the mt command.
# mt -f /dev/rmt/n status |
Repeat steps 1-2, substituting tape drive numbers 1, 2, 3, and so on to display information about all available tape drives.
The following example shows status for a QIC-150 tape drive (/dev/rmt/0) and an Exabyte tape drive (/dev/rmt/1).
$ mt -f /dev/rmt/0 status Archive QIC-150 tape drive: sense key(0x0)= No Additional Sense residual= 0 retries= 0 file no= 0 block no= 0 $ mt -f /dev/rmt/1 status Exabyte EXB-8200 8mm tape drive: sense key(0x0)= NO Additional Sense residual= 0 retries= 0 file no= 0 block no= 0 |
The following example shows a quick way to poll a system and locate all of its tape drives.
$ for drive in 0 1 2 3 4 5 6 7 > do > mt -f /dev/rmt/$drive status > done Archive QIC-150 tape drive: sense key(0x0)= No Additional Sense residual= 0 retries= 0 file no= 0 block no= 0 /dev/rmt/1: No such file or directory /dev/rmt/2: No such file or directory /dev/rmt/3: No such file or directory /dev/rmt/4: No such file or directory /dev/rmt/5: No such file or directory /dev/rmt/6: No such file or directory /dev/rmt/7: No such file or directory $ |
If errors occur when reading a tape, retension the tape, clean the tape drive, and then try again.
Retension a magnetic tape cartridge with the mt command.
$ mt -f /dev/rmt/n retension |
The following example retensions the tape in drive /dev/rmt/1.
$ mt -f /dev/rmt/1 retension $ |
Do not retension non-QIC tape drives.
To rewind a magnetic tape cartridge, use the mt command.
$ mt -f /dev/rmt/n rewind |
The following example rewindes the tape in drive /dev/rmt/1.
$ mt -f /dev/rmt/1 rewind |
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:
Copying some files to the tape, reading them back, and then comparing the original with the copy.
Or, you could use the -v option of the ufsdump command to verify the contents of the media with the source file system. The file system must be unmounted or completely idle for the -v option to be effective.
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.