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:
| 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:
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. | | 7. | List the first archive on the tape:
| 8. | List the contents of the second tape archive on the stacked tape:
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.
| 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:
| 4. | Use the pax utility to list the contents of the tape that was created by using cpio:
|
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:
| 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:
| 6. | Mark the file for extraction, and then extract the file:
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 .
| 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.
| | Extract the contents of the tape at /dev/rmt/0 to /home/myjunk.
| | tar all the files in /dev/rmt/0 to /home/myjunk, create a table of contents, and ignore checksum errors.
| | 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?
| 3. | Which of the following commands can be used in conjunction with the cpio command to perform incremental archives?
| 4. | Which of the following utilities has a built-in function to perform incremental backups?
| 5. | Which of the following commands lists the contents of a tar file without actually extracting the file?
| 6. | Which of the following is false regarding dd?
| It quickly converts and copies files with different data formats.
| | It is a good backup tool.
| | It is used to transfer a complete file system or partition from a hard disk to a tape.
| | It is used to copy all data from one disk to another.
|
| 7. | Which of the following is true regarding the cpio command?
| It is used to copy data from one place to another.
| | It is not a good tool for backups.
| | It can back up and restore individual files, not just entire file systems.
| | Backups made by cpio are smaller than those created with tar.
|
| 8. | Which of the following statements regarding the pax utility is false?
| It supports a wide variety of archive formats, including tar and cpio.
| | It is a POSIX-conformant archive utility.
| | It does not have a built-in function to perform incremental backups.
| | 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?
| fssnap, then use ufsdump on the snapshot
| | fnssnap, then use ufsdump on the snapshot
| | flarcreate, then use ufsdump on the snapshot
| | ufsdump alone can be used to back up an active file system
| | 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?
| ufsdump -S0uf /dev/rmt/0 /
| | ufsdump 0uf /dev/rmt/0 'fssnap -o bs=/opt,raw'
| | ufsdump 0uf /dev/rmt/0 'fssnap -o bs=/export,raw /'
| | ufsdump 0uf /dev/rmt/0 'snapfs -o bs=/var/tmp,raw /'
|
| 11. | Which statement about the restoresymtable file is true?
| The restoresymtable file manages the restoration of symbolic links to ensure that unnecessary copies of data are not restored.
| | 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.
| | 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.
| | 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.
| | 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."
|
|