Previous Page
Next Page

Apply Your Knowledge

Exercises

These exercises utilize a tape drive connected as /dev/rmt/0. If your system does not have a tape drive attached to it, you should substitute the device /dev/rmt/0n for a filename such as /tmp/foo.

7.1. Using tar

In this exercise, you use the tar command to copy files from disk to tape.

Estimated time: 15 minutes (depending on the size of /export/home)

1.
Log in as root and insert a tape in the tape drive. The tape will be erased, so you should use a blank tape and make sure the tape is not write protected.

2.
Create a tape archive of everything in the /export/home directory on tape device /dev/rmt/0:

tar cvf /dev/rmt/0 /export/home

3.
List the contents of the archive:

tar tvf /dev/rmt/0

4.
Add another tape archive to the same tape. This is referred to as a stacked tape. To do this, you first need to advance the tape past the first archive by using the mt command:

mt  -f /dev/rmt/0n fsf 1

The mt utility sends commands to a magnetic tape drive. It can be used to rewind, retension, and fast forward a tape as well as many other operations. In the example, the fsf option will move the tape forward 1 record.

Notice the use of the "no rewind" device (that is, 0n rather than 0).

5.
Add the next archive of the /var/adm directory:

tar cvf /dev/rmt/0n /var/adm

6.
Rewind the tape:

mt -f /dev/rmt/0 rew

7.
List the first archive on the tape:

tar tvf /dev/rmt/0n

8.
List the contents of the second tape archive on the stacked tape:

tar tvf /dev/rmt/0

Note that it's important to make a notation on the tape label that this is a stacked tape and also to record the order of each archive on the tape.

7.2. Using cpio and pax

This exercise demonstrates how to copy user files that have been modified in the past 30 days to a tape drive with the device name /dev/rmt/0. You should specify a larger-than-default blocking factor to increase the transfer speed.

Estimated time: 15 minutes (depending on the size of /export/home)

1.
Log in as root and insert a tape in the tape drive. The tape will be erased, so you should use a blank tape and make sure the tape is not write protected.

cd /export/home

2.
Locate all files by using the find command and transfer them to tape by using cpio:

find . -mtime -30 -print | cpio -oB > /dev/rmt/0

3.
List all the files that were backed up in step 2:

cpio -ict < /dev/rmt/0

4.
Use the pax utility to list the contents of the tape that was created by using cpio:

pax -v -f /dev/rmt/0

7.3. Using ufsdump and ufsrestore

In this exercise, you use the ufsdump command to back up an entire file system. You then use the ufsrestore command to restore a file.

Caution

This Exercise Destroys Data This exercise removes and overwrites files in the /var file system. Therefore, you should not do this exercise on a production system.


Estimated time: 20 minutes

1.
Log in as root and insert a tape in the tape drive. The tape will be erased, so you should use a blank tape and make sure the tape is not write protected.

2.
Back up the entire /var file system to tape:

ufsdump 0ucf /dev/rmt/0 /var

3.
Remove the /var/adm/messages file:

rm /var/adm/messages

4.
Restore the /var/sadm/README file by using ufsrestore:

cd /var
ufsrestore -ivf /dev/rmt/0

5.
At the ufsrestore> prompt, verify that the messages file is on the tape:

ls sadm/README

6.
Mark the file for extraction, and then extract the file:

add sadm/README
extract

When the system asks you to specify the next volume, type 1.

When the system says, set owner/mode for '.'?[yn], enter y.

Enter q to exit the ufsrestore utility.

7.
Verify that the file has been restored to its proper location by using the ls -l command.

Exam Questions

1.

What does the following command sequence do?

#cd /home/myjunk
#tar cvf /dev/rmt/0 .

  1. Take all the files in /home/myjunk, package them into a single tar archive on /dev/rmt/0, and print out a commentary of the process.

  1. Extract the contents of the tape at /dev/rmt/0 to /home/myjunk.

  1. tar all the files in /dev/rmt/0 to /home/myjunk, create a table of contents, and ignore checksum errors.

  1. tar all the files in the current directory into two separate archivesone for the contents of myjunk and one for the rest of /home.


2.

Say you have the following backup schedule:

  • First Monday of the monthlevel 0 (tape 1)

  • All other Mondayslevel 1 (tape 2)

  • Wednesdayslevel 2 (tape 3)

  • Fridayslevel 4 (tape 4)

Which tapes would be needed to fully restore the system if it goes down the second Saturday of the month?

  1. All four of them

  1. Tapes 24

  1. Tapes 1, 2, and 4

  1. Tapes 1, 3, and 4


3.

Which of the following commands can be used in conjunction with the cpio command to perform incremental archives?

  1. sort

  1. find

  1. grep

  1. diff


4.

Which of the following utilities has a built-in function to perform incremental backups?

  1. tar

  1. cpio

  1. ufsdump

  1. dd


5.

Which of the following commands lists the contents of a tar file without actually extracting the file?

  1. tar -cvf

  1. tar -xvf

  1. tar -tvf

  1. tar -txf


6.

Which of the following is false regarding dd?

  1. It quickly converts and copies files with different data formats.

  1. It is a good backup tool.

  1. It is used to transfer a complete file system or partition from a hard disk to a tape.

  1. It is used to copy all data from one disk to another.


7.

Which of the following is true regarding the cpio command?

  1. It is used to copy data from one place to another.

  1. It is not a good tool for backups.

  1. It can back up and restore individual files, not just entire file systems.

  1. Backups made by cpio are smaller than those created with tar.


8.

Which of the following statements regarding the pax utility is false?

  1. It supports a wide variety of archive formats, including tar and cpio.

  1. It is a POSIX-conformant archive utility.

  1. It does not have a built-in function to perform incremental backups.

  1. It is old and not a recommended backup utility.


9.

You need to perform a backup of the root file system without bringing the system to single-user mode or unmounting the root file system. Which is the best method of backing up an active, mounted file system?

  1. fssnap, then use ufsdump on the snapshot

  1. fnssnap, then use ufsdump on the snapshot

  1. flarcreate, then use ufsdump on the snapshot

  1. ufsdump alone can be used to back up an active file system

  1. fssnapshot, then use ufsdump on the snapshot


10.

On an active file system, which command successfully backs up the root file system to the /dev/rmt/0 tape device?

  1. ufsdump -S0uf /dev/rmt/0 /

  1. ufsdump 0uf /dev/rmt/0 'fssnap -o bs=/opt,raw'

  1. ufsdump 0uf /dev/rmt/0 'fssnap -o bs=/export,raw /'

  1. ufsdump 0uf /dev/rmt/0 'snapfs -o bs=/var/tmp,raw /'


11.

Which statement about the restoresymtable file is true?

  1. The restoresymtable file manages the restoration of symbolic links to ensure that unnecessary copies of data are not restored.

  1. The restoresymtable file is used to coordinate the restoration of incremental dumps on top of a full dump. It can be deleted after the last incremental restoration.

  1. The restoresymtable file contains detailed information about the restored files. It's simply a log file that can be removed after the restoration of a full backup.

  1. The restoresymtable file is used for future full dumps of a file system that has been restored by using ufsrestore. It needs to be saved for when ufsrestore may be used to restore files to this file system later.

  1. You must not delete this binary file; it is needed by ufsrestore and ufsdump. You should put a backup copy of this file in another location.


Answers to Exam Questions

1.

A. The first command changes your working directory, and the second creates the tar file. The commands shown in the example take all the files in the /home/myjunk directory, package them into a single tar archive on /dev/rmt/0, and print out a commentary of the process. For more information, see the section "The tar Utility."

2.

A. To restore the data from backups, you first load the level 0 tape created the first Monday of the month, followed by the level 2 tape, followed by the level 3 tape, and finally the level 4 tape. For more information, see the section "The ufsdump Utility."

3.

B. You use the find command with cpio to perform incremental archives. For more information, see the section "The cpio Utility."

4.

C. ufsdump has built-in options for creating incremental backups that back up only those files that were changed since a previous backup. This saves tape space and time. For more information, see the section "The ufsdump Utility."

5.

C. The -t option with the tar command lists the contents of a tar file. For more information, see the section "The tar Utility."

6.

B. The main advantage of the dd command is that it can quickly convert and copy files with different data formats, such as differences in block size or record length. The most common use of this command is to transfer a complete file system or partition from your hard disk to a tape. You can also use it to copy files from one hard disk to another. dd does not make a good backup tool. For more information, see the section "The dd Utility."

7.

A, C, D. cpio is used to copy data, back up and restore files and file systems, in a more compressed format than tar. For more information, see the section "The cpio Utility."

8.

D. pax is a backup utility that has recently been added to Solaris. It works well as a backup utility. For more information, see the section "The pax Utility."

9.

A. Unlike ufsdump, fssnap enables you to keep the file system mounted and the system in multi-user mode during backups. The snapshot is stored to disk, and then you can use Solaris backup commands such as ufsdump, tar, and cpio to back up the UFS snapshot. The result is a more reliable backup. For more information, see the section "The fssnap Utility."

10.

C. The following example backs up the root (/) file system without requiring you to unmount the file system:

# ufsdump 0uf /dev/rmt/0 'fssnap -o bs=/export,raw /'

Because ufsdump requires the path to a raw device, the raw option is used. The command fssnap -o bs=/export,raw / is enclosed in backticks so that the file system snapshot is created in the /export file system and then backed up by ufsdump. After you use ufsdump, you need to ensure that you remove the snapshot to free up space on the backing store by using fssnap -d and by removing the temporary file created in /export. For more information, see the section "The fssnap Utility."

11.

B. The restoresymtable file is created by the ufsrestore command when restoring an entire file system. This is a temporary file that is created whenever you restore an entire file system from tape. The restoresymtable file is used only by ufsrestore for "checkpointing," which involves information passed between incremental restorations. For example, if you perform an incremental restoration of data from backup tapes, the system uses information from the restoresymtable file to restore incremental backups on top of the latest full backup. The restoresymtable file is not required after the file system has been successfully restored, and it can be deleted by using the rm command. It is not removed automatically. For more information, see the section "The ufsrestore Utility."


Previous Page
Next Page