C H A P T E R 5 |
Restoring Files and Directories |
This chapter describes how to restore individual files and directories. It contains the following sections:
You can use either of the following procedures to restore Sun StorEdge SAM-FS or SAM-QFS files and directories that were archived to tape or magneto-optical cartridges. These procedures use the dump file created by samfsdump(1M).
Beginning with File System Manager version 2.1, compressed metadata snapshots created by File System Manager can be indexed without being uncompressed. In order to take advantage of this feature, you should select the gzip compression method for any scheduled metadata snapshots.
If you have existing compressed snapshots that are not in the gzip format, you can use the gznew command to convert them to gzip format.
In addition, indexing for metadata snapshots was also improved in version 2.1 of File System Manager. Additional information was added to the index, including information about damaged or online files. To take advantage of this improvement, you should delete any existing indexes and recreate them.
To Restore Files Using File System Manager |
1. From the Servers page, click the name of the server on which the file system that you want is located.
The File Systems Summary page is displayed.
2. Select the radio button next to the file system for which you want to restore files.
3. From the Operations drop-down menu, choose Restore.
The Restore File System page is displayed.
4. If the metadata snapshot file is not already displayed as a link in the Metadata Snapshot Summary table. Otherwise, make the snapshot available by selecting the radio button next to the snapshot and clicking Create Index.
5. Perform either of the following in the Metadata Snapshot Summary table:
The Restore File System page is refreshed, and the top-level items in the selected metadata snapshot are displayed in the Metadata Snapshot Entries table.
6. Find the files that you want to restore.
For detailed instructions on finding the files, see the File System Manager online help file.
7. In the Metadata Snapshot Entries table, select the radio button next to the file or directory that you want to restore.
The file or directory that you select is displayed in the File to Restore field.
8. Specify the location to which you want to restore the file or directory.
By default, the location is the path of the original file or directory, relative to the mount point of the file system. You can specify a different path relative to the mount point, or you can specify an absolute path on any archiving file system.
9. From the Online Status After Restoring drop-down menu, choose the actions that you want the file system to take after completing the restore process.
To Restore Files Using a samfsdump(1M) File |
The example in this procedure uses the samfsrestore(1M) command to restore the lost file /sam1/mary/mary1 from a samfsdump metadata dump file called /dump_sam1/041126. In the example, a temporary restoration directory called restore is created in the /sam1 file system.
1. Use the mkdir(1) command to create the directory to which you want to restore the files within a SAM-QFS file system.
2. Use the archive(1) command with the -r and -n options to prevent the archiver from archiving from this temporary directory location.
3. Use the cd(1) command to change to the temporary restoration directory.
4. Use the samfsrestore(1M) command with the -t and -f options to list the contents of the dump file.
After the -f option specify the dump file's path name, as shown in the following example.
5. Search the listing from the previous step to verify that the lost file is in the dump file.
If you find the file you are looking for, copy down the exact path name shown in the output to use in the following step.
In the previous screen example, the lost file, called mary1, is shown as residing in the ./mary directory.
6. Use the samfsrestore (1m) command with the -T and -f options to restore the file's inode information to the current directory.
The file name you specify must match exactly the path name as it was listed in the previous output. The following example shows the use of samfsrestore to retrieve the file ./mary/mary1 from the dump file /dump_sam1/041126.
7. Use the sls(1) command with the -D option to list detailed information about the file, and verify that the inode information for the correct file has been retrieved.
The following example shows inode information for file ./mary/mary1.
8. Use the mv(1) command to move the file to the desired location.
TABLE 5-1 lists the procedures used to restore various types of files when no samfsdump(1M) output is available.
An archiver log file exists with an entry for the file, or you have output from the sls command with the -D option that lists the file. |
To Restore a Regular File Using Information From an Archiver Log or sls Command Output. |
|
Restoring a Regular File Without Information From an Archiver Log. |
||
An archiver log file exists with an entry for the file, or you have output from the sls command with the -D option that lists the file. |
||
Restoring a Segmented File Using Information From an Archiver Log. |
||
Restoring a Volume Overflow File Using Information From an Archiver Log. |
When you have an archiver log with one or more entries for a missing file, see the following sections for how to interpret the information in the archiver log file and how to determine which of the above procedures to use:
This section shows how to determine from a missing file's archiver log file entries whether the file is a regular file, a segmented file, or a volume overflow file. You need this information to decide which of the restoration procedures to follow from Restoring Files and Directories Without samfsdump(1M) Output.
Each regular file has a single entry in an archiver log. In field 12 of the archiver log entry, a regular file is identified with an f. The following example shows a typical archiver log entry for a regular file:
A segmented file is a file that has the segment attribute set and a segment size specified through the segment(1) command. When a file has the segment attribute set, it is archived and staged in segment-sized chunks. The segment size is shown in field 10 of the archiver log file in kilobytes.
Each segmented file has multiple entries in an archiver log. CODE EXAMPLE 5-1 shows three entries for segmented file seg/aaa. Field 12 has a S indicating that the file type is file segment.
A volume overflow file is a file that is written on multiple volumes. A volume overflow file has multiple entries in an archiver log, one for each section of the file. CODE EXAMPLE 5-2 shows two entries for the two sections of the regular file big2d. Field 5 shows that the file starts on VSN CFX600 and overflows to VSN CFX603, and field 13 shows the section numbers, 0 and 1.
TABLE 5-2 shows the information you need from the archiver log or sls -D command output in order to restore a regular file.
Position[1] |
If you can obtain the needed information about a regular file either from its archiver log entry or from output from the sls(1) command with the -D option, you can restore the file with the request(1M) and star(1M) commands. As shown in the examples that follow, you use the request command first to create a file whose contents represent the contents of one or more pieces of removable media. This new file is sometimes referred to as a request file. You then use the star command to extract the file.
To Restore a Regular File Using Information From an Archiver Log or sls Command Output |
Note - For the procedure to work, the SAM-QFS file system must be mounted. |
1. Log in as, or switch user to, root.
2. Find and record the media type, the file's position, and the VSN.
a. If you have an archiver log, use cat(1M) or another command to search the archiver log file for an entry for the missing file.
The following example shows a sample entry for a file archived on a tape followed by a sample entry for a file archived on an optical disk.
# cat ... A 96/06/04 10:55:56 lt DLT001 arset0.1 286.1324f samfs1 770.11 130543 tape_test/file4 0 0 0 A 96/01/05 10:55:56 mo v1 set_1.1 d2e.1 samfs2 770.11 2673 test/file3 0 0 0 |
For definitions of the relevant fields in the archiver log file, see TABLE 5-2.
b. If you have output from the sls command with the -D option about the missing file, search that output.
The following example shows output from this command for file tape_test/file4.
c. Record the media type, the file's position, and the VSN to use as input to the request(1M) command in the next step.
3. Use the request(1M) command with the -p option, followed by the hexadecimal 0x and the position number from the archiver log to position to the beginning of the tar(1) header for the file.
Note - VSNs specified with the request(1M) command must reside on a local automated library. |
The following example creates a request file with the contents of the archive containing the example file from step 2a that is on tape:
The following example creates a request file with the contents of the example file from step 2a that is on optical disk:
4. Use the star(1M) command to extract the files.
The star(1M) command restores all the files from the archive file that you are pointing to with the request file.
If you labeled the tape with a block size other than the default (16 kilobytes), you would use the block size in bytes divided by 512 (in place of the value 32) for the star command's -b option. You can see the tape block size by mounting the tape and observing either the samu(1M) utility's t display, the samu utility's v display (press CTRL-i for detail lines), or the output of the dump_cat(1M) command.
# cd /sam1 # star -xv -b 32 -f /sam1/xxxx ... tape_test/file4 ... tar: directory checksum error # cd /sam2 # star -xv -b 32 -f /sam2/xxxx ... test/file3 ... tar: directory checksum error # |
5. Use the sls(1) command to verify that you have extracted the lost file.
The following example shows the command output for the file on the optical disk.
mode: -rw-rw---- links: 1 owner: root group: other length: 2673 admin id: 7 inode: 161.2 copy 1:---- May 1 15:41 286.1324f mo v1 access: May 1 16:50 modification: May 1 15:41 |
If you do not have an archive log available with an entry for a regular file, you can still restore the file using either an automated library or a manually mounted, standalone drive, under the following conditions:
To Restore a Regular File Without Information From an Archiver Log |
Note - If the only resources available consist of a cartridge containing archive copies and a Solaris system without Sun StorEdge SAM-FS software installed, start this procedure with Step 3. |
1. If you are using an automated library, prevent the Sun StorEdge SAM-FS software from using the tape drive.
Note - If you are using a manually mounted, standalone drive, skip this step. |
You can use the samu(1M) command with the :unavail eq option, the samcmd(1M) command with the unavail eq option, the devicetool(1M) commands, or the libmgr(1M) command. For the samu and samcmd commands, specify the equipment ordinal of the drive as eq. The equipment ordinal for each device is specified in the mcf(4) file.
The following example shows the use of the samcmd command. .
2. If you are using an automated library, use the samload(1M) command to load the desired volume into the drive.
Note - If you are using a manually mounted, standalone drive, skip this step. |
For the command-line options to use, see the samload(1) man page. The following example shows the use of the samload command to load the cartridge that is in slot 3 of library 50 into the drive with equipment ordinal 51.
3. Use the mt(1M) command to rewind the tape.
The following example shows this command applied to tape drive /dev/rmt/2.
Note - Because the device name used in these examples ends with the n (no rewind) option, each of the commands in the following steps examines the next file on the tape. |
4. Use od(1M) or another command to examine the ANSI label on the cartridge, and find the line that starts with 0000240.
The first file on the cartridge is the ANSI label. In the following example, the information you are looking for appears on the line that starts with 0000240.
5. Note the five characters that appear after H D R 2 on the line that starts 0000240.
These five characters are the bottom five digits of the block size, in decimal. In the previous screen example, the characters are 1 6 3 8 4.
6. Use the bottom five digits to determine the block size used on the media.
TABLE 5-3 shows the block sizes corresponding to these digits for the dd(1M) and tar(1) commands.
7. Issue one of the following commands:
Issue it with the number of 512-byte blocks obtained in the previous two steps.
You can download the star command from a Sun StorEdge SAM-FS system onto any Solaris system.
CODE EXAMPLE 5-3 shows the star command being used to examine the first tar file. The block size for both the star(1M) and tar(1) commands is specified in units of 512-byte blocks. The number 32 used after -b in the example is the number of 512-byte blocks that corresponds to the number 16384 in the ANSI label in Step 4, from the table in Step 6.
# star -tv -b 32 -f /dev/rmt/2cbn -rw-rw---- 0/1 102564 Sep 6 13:02 1996 test 6+1 records in 11+1 records out |
CODE EXAMPLE 5-4 shows the same command used to examine the next tar(1) file.
# star -tv -b 32 -f /dev/rmt/2cbn -rw-rw---- 0/1 102564 Sep 6 13:02 1996 test 6+1 records in 11+1 records out |
CODE EXAMPLE 5-5 shows two copies of another file being examined.
CODE EXAMPLE 5-6 shows that the end of the tape has been reached.
CODE EXAMPLE 5-7 shows the dd command being used to examine the first tar file. The value 16k used for the input block size (ibs=) is the number in TABLE 5-3 that corresponds to the number 16384 in the ANSI label.
CODE EXAMPLE 5-8 shows the same command examining the next tar(1) file.
CODE EXAMPLE 5-9 shows the examination of two copies of another file.
CODE EXAMPLE 5-10 shows that the end of the tape has been reached.
8. When you find the missing file in an archive, extract the file by using either the -x option with the star command or the dd command with the tar command.
CODE EXAMPLE 5-11 shows these commands.
Note - You can ignore the dd: read error in the first line of dd commands output. |
When a segmented file is archived or staged, it is archived and staged in chunks. Each segmented file has multiple entries in an archiver log.
If you can find entries for a missing segmented file in an archiver log, you can use the file's position, segment size, VSN, and media type to restore the file with the request(1M) and star(1M) commands.
Note - In the following procedures, all segments are in the same tape tar(1) file, and no segment is overflowed. If your file has segments on more than one tar(1) file, you must use a separate request(1M) command for each tar(1) file position. If any segments are volume overflow files, use the procedure described in Restoring a Volume Overflow File Using Information From an Archiver Log for those segments. |
To Restore a Segmented File Using Information From Archiver Log Entries |
Note - You must have free space in the file system equal to two times the size of the file to be recovered. |
1. Find the archiver log entries for the segmented file by the file system name (from field 8) and file name (from field 11).
CODE EXAMPLE 5-12 shows entries for segmented file file2 in the archiver.log file.
CODE EXAMPLE 5-12 shows the archiver log file for file segments in file system samfs4. Each segment has its own entry and file name: seg/aaa/1, seg/aaa/2, and seg/aaa/3.
2. Do the following for each segment or group of segments that is located at a unique position, even if they are on the same VSN.
If there are segments on different VSNs, make sure that you specify the correct media type and VSN for each.
a. Note the contents of fields in the archiver log.
You will use information from the archiver log as input to the request(1M) command in Step 3 and to the segment(1) command in Step 9. The information you need is contained in the following fields:
The first line in the previous screen example provides the following information:
b. Issue the request(1M) command to create a removable media file that points to the segments.
# request -m media-type -p 0x position-number -v VSN filename
Note - VSNs specified in the request(1M) command must reside on a local automated library. |
For example, the following command uses the values from the example lines in Step 1:
The preceding command retrieves the first two segments.
c. Issue the star(1M) command.
Use the name of the file created in the previous step to read the segments from tape onto the disk, as shown in the following example.
3. stet(1) command to change into the directory where the segmented files reside.
The following example shows segmented files 1, 2, and 3 in the seg/aaa directory.
4. Use the ls(1) and sort(1) commands to list and sort the numbered files in numerical order, and use the cat(1M) command to join the files.
The temporary file created in this step is not segmented.
5. Use the cd(1) command to change to the directory above where the numbered files reside, and then use the rm(1) command to remove the numbered files.
6. Use the touch(1M) command to create an empty file.
7. Use the segment(1) command to set the segment attribute on the file that you just created.
To obtain the segment length, take the segment size from field 10 of the archiver log file entry and divide it by dividing 1048576. For example, the segment size in the archiver log entry example in Step a is 10485760. Dividing the segment size by 1048576 yields 10 megabytes, which is entered as 10m in the following example.
8. Copy the temporary file created in Step 4 into the empty file created in Step 9, and then remove the temporary file, as shown in the following example.
9. Issue the sls(1) command with the -2K option to list the segments of the segmented file in two lines of output.
A volume overflow file is a file that is written on multiple volumes. If you can find entries for a missing volume overflow file in an archiver log, you can use the file's position, segment size, VSN, and media type to restore and reassemble the file with the request(1M), star(1M), dd(1M), and cat(1) commands.
To Restore a Volume Overflow File Using Information From an Archiver Log |
Note - Free space must be available in the file system equal to two times the size of the file to be recovered. |
1. Use vi(1M) or another command to examine the archiver log file that contains an entry for the file you are trying to recover.
CODE EXAMPLE 5-13 shows the archiver log file for file3, a sample volume overflow file.
The file is identified as a volume overflow file with two sections because the f in the third-to-last field indicates that the entry is for a regular file, and the 0 and the 1 in the second-to-last fields are section numbers. The fifth field shows that the file starts on VSN 700036 and overflows to information about 700034.
2. Use the request(1M) command to create a removable media file that points to each section of the volume overflow file, as shown in the following example.
3. Use the cd(1M) and dd(1M) commands to recover the sections.
Repeat the dd(1M) command for each remaining section.
In the following example, a block size of 256 kilobytes is assumed for both tapes.
# cd /qfs2 # dd if=/samfs1/tp1 of=file3.0 ibs=256k 340+0 records in 174080+0 records out # dd if=/samfs1/tp2 of=file3.1 ibs=256k 2004+0 records in 1026048+0 records out |
4. Use the ls(1M) command to examine the output and ensure that all pieces of the file are on the disk.
# ls -l file3.* -rw-r--r-- 1 root other 89128960 Aug 31 12:07 file3.0 -rw-r--r-- 1 root other 525336576 Aug 31 12:14 file3.1 |
5. Use the cat(1M) and star(1M) commands to reassemble the file.
The following sections tell you how to gather necessary information and then restore files archived to disk:
To Gather Information for a Disk Archive Restoration |
You must have the following information before you can restore any files that have been archived to disk:
You must have either the saved sls(1) output or the archiver log files that include the files you want to restore.
1. Find the disk volume name and the path to the disk archive tar(1) file that contains the archived file.
You can use either the sls(1) command with the -D option or the archiver log file entry.
Examine the lines that correspond to the disk archive copies, indicated by a media type of dk in the fifth field. The second-to-the-last field in these lines shows the disk volume name as defined in diskvols.conf(4). The last field shows the path to the disk archive tar(1) file.
In the following example, both the commands you type in and the information you are looking for are in bold text.
Examine the lines corresponding to the disk archive copies, indicated by a media type of dk in the fourth field. The fifth field in these lines shows the disk volume name as defined in diskvols.conf(4), and a slash (/) character, and then the path to the disk archive tar(1) file.
In the following example, the information you are looking for is in bold text.
2. Use cat(1) or another command to examine the diskvols.conf(4) file and to find the path name defined for the disk volume name in diskvols.conf(4).
In the following example, two of the three disk volumes defined for receiving disk archive copies are mounted locally, and one is mounted remotely, on server mars.
# cat /etc/opt/SUNWsamfs/diskvols.conf DISK_01 /ufs2/disk_archive/01 DISK_02 /ufs2/disk_archive/02 DISK_03 mars:/qfs1/disk_archive/03 |
To Restore Files From a Disk Archive tar(1) File |
Before you start this procedure, collect the information described in To Gather Information for a Disk Archive Restoration.
1. Use the mkdir(1) command to create the directory in which you will restore the files.
2. Use the cd(1) command to change to the restoration directory.
3. Use the star(1M) command with its -tv option to list the content of the disk archive tar(1) file.
The following example shows the content of the disk archive tar(1) file associated with archive copy 1.
4. Verify that the files that you want to restore are listed in the output from Step 3.
If you are restoring a single file, not its exact path name. You will use this information in the next step.
5. Use the star(1M) command with its -xv option to restore the files.
6. Use the sls(1) command with its -DR option to verify that you have extracted the proper files.
The following example shows multiple retrieved files.
Unarchived files that resided within a SAM-QFS file system might not be recoverable after a system outage. The following list contains information that might help you to retrieve unarchived files:
Copyright © 2006, Sun Microsystems, Inc. All Rights Reserved.