C H A P T E R 5 |
Restoring Files and Directories |
This chapter describes how to restore individual files and directories. It covers the following topics:
TABLE 5-1 lists the tasks for restoring files and directories with cross references to where the procedures are located.
You can use one of the following procedures to restore files and directories by using the dump file created by samfsdump(1M).
Note - samfsdump and samfsrestore work on SAM-QFS file systems but not Sun StorEdge QFS stand-alone file systems. If needed, see the Sun StorEdge QFS Configuration and Administration Guide. |
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 displayed as a link in the Metadata Snapshot Summary table, skip to the next step. Otherwise, make the snapshot available by selecting the radio button next to the snapshot that is unavailable and click Make Available for Browsing.
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 complete instructions on finding the files you want to restore, 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. From the Online Status After Restoring drop-down menu, choose how you want the file restored.
Note - The File System Manager software can only restore files from snapshots created by the File System Manager software. |
To Restore Using a samfsdump(1M) File |
The example in this procedure uses the samfsrestore(1M) command to restore a lost file from a dump file created by the samfsdump command. It restores a file (pathname: /sam1/mary/mary1) from a samfsdump metadata dump file called /dump_sam1/041126. The example creates a temporary restoration directory called restore in the /sam1 file system.
1. Use the mkdir(1) command to create a directory in which to restore the files within a SAM-QFS file system.
2. Use the archive(1) command with the -r option and -n option 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 CODE EXAMPLE 5-1.
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 command with the -T and -f options to restore the file's inode information to the current directory.
The filename must match exactly the pathname as it was listed in the previous output from Step 4. The following screen example shows using 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.
CODE EXAMPLE 5-2 shows inode information for file ./mary/mary1.
8. Use the mv(1) command to move the file to the desired location.
TABLE 5-2 lists the tasks for restoring various types of files when no samfsdump(1M) output is available.
When you have an archiver log with an entry or 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:
Note that if you restore files without samfsdump(1M) output, you recreate the .inodes file. In addition, you lose the content of the original .inodes file. If you had used chmod(1), chown(1), or any other commands to modify file attributes, those attributes are lost. The files are restored with their default attributes. This applies to all types of files (regular files, segmented files, and so on).
TABLE 5-3 shows the information needed for restoring a regular file.
Position[3] |
If you can get the needed information about a regular file either from its archiver log entry or from output about the file 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, the request command is first used to create a file whose contents represent the contents of one or more pieces of removable media (which is sometimes referred to as a request file). The star command is then used to extract the file, as shown in To Restore a Regular File Using Information From an Archiver Log or sls Command Output.
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 entry for a regular file in an archiver log:
A segmented file is a file that has the segment attribute set and a segment_size specified using the segment(1) command. When a file has the segment attribute set, it is archived and staged in segment-sized chunks. The length of the segment (segment_size) is shown in field 10 of the archiver log file in kilobytes.
For each segmented file, an archiver log has multiple entries. CODE EXAMPLE 5-3 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 one that is written on multiple volumes. For a volume overflow file, an archiver log has multiple entries, one for each section of the file. CODE EXAMPLE 5-4 shows two entries for the two sections of file big2d.
The big2d file is identified as a volume overflow file because it has two entries, the f in field 12 indicates that the entry is for a regular file, and the 0 and the 1 in field 13 are section numbers. Field 5 shows that the file starts on VSN CFX600 and overflows to VSN CFX603.
TABLE 5-4 summarizes the defining characteristics of regular, segmented, and volume overflow files.
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 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.
CODE EXAMPLE 5-5 shows the sample entry for a file that is archived on a tape followed by a sample entry for a file archived on an optical disk.
If needed, see TABLE 5-3 for definitions of the fields in the archiver log file.
b. If you have output from the sls command with the -D option about the missing file, search that output.
CODE EXAMPLE 5-6 shows output from the sls(1) command with the -D option 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 using the position from the archiver log to position to the beginning of the tar(1) header for the file.
Use hexadecimal notation, prefacing the position number after the -p option with 0x.
The following example creates a request file with the contents of the archive containing the example file that is on tape:
The following example creates a request file with the contents of the example file that is on optical disk:
Note - VSNs specified using request(1M) command must reside on a local automated library. |
4. Use the star(1M) command to extract the file as shown in CODE EXAMPLE 5-7.
Note - 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 (type CTRL-i for detail lines), or the output of the dump_cat(1M) command.
5. Use the sls(1) command to verify that you have extracted the lost file.
CODE EXAMPLE 5-8 shows the sls -D output for the file on the optical disk.
If you do not have an archive log available with an entry for the file, you can use the procedure 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, you can still restore the file by starting this procedure with Step 3. |
You can perform the procedure To Restore a Regular File Without Information From an Archiver Log using either an automated library or a manually mounted, standalone drive, under the following conditions:
To determine which cartridge contains the missing file, you need to examine only those volumes that are assigned to the archive set for the file in question. You can use the -t option to tar or star repeatedly on each volume as described in the procedure To Restore a Regular File Without Information From an Archiver Log to find out which volume contains the archive copy. When you have found the archive copy of the file, you then use the -x option to tar or star to extract the file.
To Restore a Regular File Without Information From an Archiver Log |
1. (Optional) 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 either the samu(1M) command with the :unavail eq option, the samcmd(1M) command with the unavail eq option, the devicetool(1M) 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 screen example shows the use of the samcmd command with the unavail subcommand when the equipment ordinal is 51.
2. (Optional) 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 screen 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 how to do this using the mt(1M) command. If your tape drive is not /dev/rmt/2, substitute the correct name in the following examples.
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.
The five characters that appear after H D R 2 on the line that starts with 0000240 are the five bottom digits of the block size, in decimal. In the previous screen example, the characters are 1 6 3 8 4.
6. Use the five bottom digits of the block size to determine the block size used on the media.
Locate the bottom five digits of the block size in the left column of TABLE 5-5. For the dd(1M) command, the block size is found in the second column. For both the star(1M) and tar(1) commands, the block size is specified in units of 512-byte blocks, which are shown in column 3.
Note - In the following screen examples, all files are archived twice, so each file is inspected twice. |
7. If the star(1M) command is available, enter it with the number of 512-byte blocks obtained in the previous two steps to find the file in the archive.
You can download the star command from a Sun StorEdge SAM-FS system onto any Solaris system. If you do not have access to the star command, you can use the dd(1M) command with the tar(1) command, as shown in Step 8.
CODE EXAMPLE 5-9 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-10 shows the same command examining 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-11 shows two copies of another file being examined.
CODE EXAMPLE 5-12 shows the end of the tape has been reached.
8. If the star(1M) command is not available, use the dd(1M) and tar(1) commands to examine the archives.
CODE EXAMPLE 5-13 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 the third column of the table in Step 6 that corresponds to the number 16384 in the ANSI label in Step 4.
CODE EXAMPLE 5-14 shows the same command examining the next tar(1) file.
CODE EXAMPLE 5-15 shows the examination of two copies of another file.
CODE EXAMPLE 5-16 shows that the end of the tape has been reached.
9. When you find the missing file in an archive, use the -x option with either the star command alone or the dd command with the tar command to extract the files from that archive.
CODE EXAMPLE 5-17 shows these commands.
Note - You can ignore the dd: read error in the first line of output. |
When a segmented file is archived or staged, it is archived and staged in chunks. For each segmented file, an archiver log has multiple entries.
If an archiver log file exists, you can search the archiver log for the multiple entries for the missing segmented file. (See To Set Up Archiver Logging, if needed.)
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 using the request(1M) and star(1M) commands. The procedure is described in To Restore a Segmented File Using Information From Archiver Log Entries.
If needed, see TABLE 5-3 for definitions of the fields in the archiver log file.
The segmented file named aaa is used in the examples in this section and in the procedure. CODE EXAMPLE 5-18 shows three entries for segmented file aaa in the archiver log file.
Note - CODE EXAMPLE 5-18 assumes that all segments are in the same tape tar(1) file and that no segment is overflowed. If there are segments on more than one tar(1) file, 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. |
TABLE 5-6 provides a place to record the information used when restoring a segmented file.
To Restore a Segmented File Using Information From Archiver Log Entries |
Note - Free space must be available 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-19 shows entries for segmented file file2 in the archiver.log file.
CODE EXAMPLE 5-19 shows the archiver log file for file segments in file system qfs1. Each segment has its own entry and file name: seg/aaa/1, seg/aaa/2, seg/aaa/3, and so on.
If needed, see TABLE 5-3 for definitions of the fields in the archiver log file.
2. Note the contents of several fields in the archiver log.
Information from the archiver log needs to be used as input to the request(1M) command in Step 3 and to the segment(1) command in Step 9. The information needed is contained in the following fields:
The first line in the previous screen example provides the following information:
3. Enter the request(1M) command to create a removable media file that points to the segments.
Supply the following information as arguments to the request(1M) command:
The following command uses the values from the example lines in Step 1:
The preceding command retrieves the first two segments.
Note - VSNs specified using request(1M) command must reside on a local automated library. |
4. Enter the star(1M) command, as shown in CODE EXAMPLE 5-20.
Use the name of the file created in the previous step to read the segments from tape onto the disk.
# star xvbf 512 /sam3/rmfile seg/aaa/1 seg/aaa/2 |
5. Repeat Step 2, Step 3, and Step 4 for each segment or group of segments that is located at a unique position (even if they are on the same VSN).
There might be more than one segment at a position. You might need to issue this step, Step 3, and Step 4 as a sequence more than once.
If there are segments on different VSNs, make sure you specify the correct media type and VSN for each.
The following commands complete the command sequence that is needed to retrieve the three file segments described in CODE EXAMPLE 5-19:
# request -m ib -p 0x1933a -v E00000 /sam3/rmfile # star xvbf 512 /sam3/rmfile |
The commands in CODE EXAMPLE 5-21 are needed because the third segment is at a different position from the first two segments. If there are file segments at more than one location, you must enter request(1M) and star(M) commands to retrieve all the segments. You can dispense with other files that might be retrieved in the same tarball.
6. Use the cd(1) command to change into the directory where the segmented files reside.
CODE EXAMPLE 5-22 shows segmented files 1, 2, and 3 in the seg/aaa directory.
7. 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.
8. 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.
CODE EXAMPLE 5-23 shows this.
9. Enter the touch(1M) command to create an empty file.
10. Use the segment(1) command to set the segment attribute on the file created in Step 9.
Enter the segment command with the -l option following by the segment length in megabytes followed by m followed by the filename of the empty file created in the previous step.
Convert the segment length (from field 10 of the archiver log file entry) to megabytes by dividing 1048576. For example, the segment length in the archiver log entry example in Step 2 is 10485760. Dividing the segment length by 1048576 gives 10 megabytes, which is entered as -l 10m in the following screen example.
11. Copy the temporary file created in Step 7 into the empty file created in Step 9, and then remove the temporary file.
CODE EXAMPLE 5-24 shows this procedure.
12. Enter the sls(1) command with the -2K option to list the segments of the segmented file in two lines of output.
CODE EXAMPLE 5-25 shows this procedure.
A volume overflow file is a file that is written on multiple volumes. If an archiver log file exists, you can search the archiver log for entries for the missing file. (See To Set Up Archiver Logging, if needed.) 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 using the request(1M), star(1M), dd(1M), and cat(1) commands. The procedure is described in To Restore a Volume Overflow File Using Information From an Archiver Log.
If needed, see TABLE 5-3 for definitions of the fields in the archiver log file.
The volume overflow file named file3 is used in this section and in the procedure. CODE EXAMPLE 5-26 shows two entries for the two sections of file file3 in the archiver.log 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.
The following procedure assumes that free space is available in the file system equal to two times the recovered file.
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.
The archiver log file for file3 was shown previously in CODE EXAMPLE 5-26.
2. Use the request(1M) command to create a removable media file that points to each section.
CODE EXAMPLE 5-27 shows the request(1M) options to use.
# request -p 0x12d55 -m sg -v 700036 /samfs1/tp1 # request -p 0x15f9e -m sg -v 700032 /samfs1/tp2 |
3. Use the cd(1M) and dd(1M) commands to recover the sections.
CODE EXAMPLE 5-28 shows that a block size of 256 kilobytes is assumed for both tapes.
Repeat the dd(1M) command for each remaining section.
4. Use the ls(1M) command to examine the output and ensure that all pieces of the file are on the disk.
CODE EXAMPLE 5-29 shows an example of this.
# 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 files.
CODE EXAMPLE 5-30 uses the cat(1) and star(1) commands to reassemble the files.
The following sections describe how to restore files archived to disk. The sections are as follows:
The examples in these procedures uses six archived files. Three of these files use long path names (filex, filey, filez), which result in extended tar(1) file headers. These are included just for completeness. No extra steps are required on behalf of the user for disaster recovery purposes of files with long path names.
Each of the sample files has four archive copies, as follows:
To Gather Information for a Disk Archive Restoration |
The following information is needed 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. The examples in this step show both.
You can use this method if you have sls(1) output for the files you want to restore.
CODE EXAMPLE 5-31 shows output from the sls(1) command. Examine the lines that correspond to the disk archive copies. These lines show 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 output for CODE EXAMPLE 5-31, both the commands you type in and the information you are looking for are in bold text.
Use this method if you have an archiver log file that includes the files you want to restore.
CODE EXAMPLE 5-32 shows archiver log example output. Examine the lines corresponding to the disk archive copies. These lines show 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 it shows the path to the disk archive tar(1) file. These are joined by a slash (/) character.
In the output for CODE EXAMPLE 5-32, 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).
CODE EXAMPLE 5-33 shows the following three disk volumes defined for receiving disk archive copies:
To Restore a Single File From a Disk Archive tar(1) File |
Use this procedure to restore a single file from a disk archive tar(1) file.
1. Use the procedure in To Gather Information for a Disk Archive Restoration to gather the information needed for this restoration.
2. Use the mkdir(1) command to create a directory in which to restore the files within a SAM-QFS file system.
3. Use the cd(1) command to change to the restoration directory.
4. Use the star(1M) command with its -tv options to list the content of the disk archive tar(1) file.
CODE EXAMPLE 5-34 shows the content of the disk archive tar(1) file associated with archive copy 1. The star(1M) command shown derives its input file name from two sources:
5. Verify that the file you wish to restore is listed in the output from Step 4.
If you find the file you are looking for, copy down the exact path name shown in the output for use in Step 6.
CODE EXAMPLE 5-34 shows lost file fileb residing in directory testdir4. Copy down testdir4/fileb for use in Step 6.
6. Use the star(1M) command with its -xv options to restore the file to the current directory.
The file name must match exactly the path name as it was listed in the output from Step 4 (CODE EXAMPLE 5-34).
CODE EXAMPLE 5-35 shows the star(1M) command retrieving file testdir4/fileb from disk archive tar(1) file /ufs2/disk_archive/01/d8/d19/f102.
# star -xv -f /ufs2/disk_archive/01/d8/d19/f102 testdir4/fileb testdir4/fileb |
7. Use the sls(1) command with its -DR options to verify that you have extracted the proper file.
CODE EXAMPLE 5-36 shows sls(1) output.
To Restore Multiple Files From a Disk Archive tar(1) File |
Use this procedure to restore multiple files from a disk archive tar(1) file.
1. Use the procedure in To Gather Information for a Disk Archive Restoration to gather the information needed for this restoration.
2. Use the mkdir(1) command to create a directory in which to restore the files within a SAM-QFS file system.
3. Use the cd(1) command to change to the restoration directory.
4. Use the star(1M) command with its -tv options to list the content of the disk archive tar(1) file.
CODE EXAMPLE 5-37 shows the content of the disk archive tar(1) file associated with archive copy 1. The star(1M) command shown derives its input file name from two sources:
5. Verify that the files you wish to restore are listed in the output from Step 4.
6. Use the star(1M) command with its -xv options to restore the entire content of the disk archive tar(1) file to the current directory.
CODE EXAMPLE 5-38 shows the star(1M) command retrieving all files from disk archive tar(1) file /ufs2/disk_archive/01/d8/d19/f102.
# star -xv -f /ufs2/disk_archive/01/d8/d19/f102 testdir4/filea testdir4/filec testdir4/fileb |
7. Use the sls(1) command with its -DR options to verify that you have extracted the proper files.
CODE EXAMPLE 5-39 shows sls(1) output.
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 © 2005, Sun Microsystems, Inc. All Rights Reserved.