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:

- Restoring Regular Files and Directories With samfsdump(1M) Output

- Restoring Files and Directories Without samfsdump(1M) Output

- Restoring a Regular File Using Archiver Log or sls Information

- Determining the File Type

- Restoring a Regular File Without Information From an Archiver Log

- Restoring a Segmented File Using Information From an Archiver Log

- Restoring a Volume Overflow File Using Information From an Archiver Log

- Restoring Files Archived to Disk

- Retrieving Unarchived Files From File Systems

Note - If the `mv`(1) command has been used to move an archived file to a different directory, the file is not rearchived. If you use the `star`(1M) command to recover a moved file, the `star`(1M) header on the archive media retains the original path name. When you use the `star`(1M) command to reload the file, the file is restored to its original location. You can see the path by issuing the `star`(1M) command with its `tvbf` arguments. Then, you can extract the file to its original location by issuing the `star`(1M) command again. Finally, issue the `mv`(1) command to move the file to its new directory.

##

Restoring Regular Files and Directories With `samfsdump`(1M) Output

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.

Note - If a dump file has been created using the `-H` option with the `samfsdump` command, it cannot be indexed and cannot be restored with File System Manager. For more information see the `samfsdump`(1M) man page.

5. Perform either of the following in the Metadata Snapshot Summary table:

- Click a metadata snapshot file to browse its contents.

- Select the radio button next to a metadata snapshot file and click Show Contents.

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.

10. Click Restore.

### 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.

`#` `mkdir restore`

2. Use the `archive`(1) command with the `-r` and `-n` options to prevent the archiver from archiving from this temporary directory location.

    # archive -r -n restore

3. Use the `cd`(1) command to change to the temporary restoration directory.

    # cd restore

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.

    # samfsrestore -t -f /dump_sam1/041126
    samfsrestore -t -f /dump_sam1/041126
    ./lost+found
    ./neptune
    ./mary
    ./fileA
    ./fileB
    ./fileC
    ./fileD
    ./fileE
    ./mary/mary1
    ./mary/mary2
    ./neptune/vmcore.0
    ./neptune/unix.0
    ./neptune/bounds

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`.

    # samfsrestore -T -f /dump_sam1/041126 ./mary/mary1

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`.

    # sls -D ./mary/mary1
    mary/mary1:
      mode: -rw-rw----  links:   1  owner: mary     group: sam
      length:        53  inode:          43
      offline;  archdone;
      copy 1: ---- Nov 17 12:35          8ae.1 xt 000000
      copy 2: ---- Nov 17 15:51       cd3.7f57 xt 000000
      access:      Nov 17 12:33  modification: Nov 17 12:33
      changed:     Nov 17 12:33  attributes:   Nov 17 15:49
      creation:    Nov 17 12:33  residence:    Nov 17 15:52

8. Use the `mv`(1) command to move the file to the desired location.

    # cd mary
    # mv mary1 /sam1/mary/

##

Restoring Files and Directories Without `samfsdump`(1M) Output

TABLE 5-1 lists the procedures used to restore various types of files when no `samfsdump`(1M) output is available.

TABLE 5-1 Restoring Files When No `sampfdump` (1M) Output Is Available
Type of File | Condition | Where Described
--- | --- | ---
Regular file archived to removable media cartridges | 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.
Regular file archived to removable media cartridges | No archiver log file exists. | Restoring a Regular File Without Information From an Archiver Log.
Regular file archived to disk | 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 Files Archived to Disk
Segmented file | An archiver log file exists with entries for the file. | Restoring a Segmented File Using Information From an Archiver Log.
Volume overflow file | An archiver log file exists with entries for the file. | 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:

- Restoring a Regular File Using Archiver Log or sls Information

- Determining the File Type

Note - If you restore any type of file (regular file, segmented file, and so on) without `samfsdump`(1M) output, you re-create the `.inodes` file, and you lose the content of the original `.inodes` file, as well as any file attributes modified with the `chmod`(1), `chown`(1), or other command. The files are restored with their default attributes.

##

Determining the File Type

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.

### Regular File

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 96/01/05 10:55:56 mo v1 set_1.1 d2e.1 samfs2 770.11 2673 test/file3 f 0 0

### Segmented 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.

CODE EXAMPLE 5-1 Archiver Log Entry for a Segmented File
    A 2000/06/15 17:07:28 ib E00000 all.1 1276a.1 samfs4 14.5 10485760 seg/aaa/1 S 0 51
    A 2000/06/15 17:07:29 ib E00000 all.1 1276a.5002 samfs4 15.5 10485760 seg/aaa/2 S 0 51
    A 2000/06/15 17:07:29 ib E00000 all.1 1276a.a003 samfs4 16.5 184 seg/aaa/3 S 0 51

### Volume Overflow File

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.

CODE EXAMPLE 5-2 Archiver Log Entry for a Volume Overflow File
    A 2001/10/31 09:47:29 lt CFX600 arset1.1 3668e.1 samfs9 71950.15 2011823616 testdir1/big2d f 0 43
    A 2001/10/31 09:47:29 lt CFX603 arset1.1 3844a.0 samfs9 71950.15 1209402048 testdir1/big2d f 1 41

##

Restoring a Regular File Using Archiver Log or sls Information

TABLE 5-2 shows the information you need from the archiver log or `sls -D` command output in order to restore a regular file.

TABLE 5-2 Information Needed for Restoring a Regular File
Definition | Field in Archiver Log Output | Field in Archive Copy Line in `sls -D` Output
--- | --- | ---
Media type | 4 | 5
Volume serial name (VSN) | 5 | 6
Position[1] | 7 | 4

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`.

    # sls -D /sam1/tape_test/file4
    /sam1/tape_test/file4:
     mode: -rw-rw----  links:   1  owner: root      group: other
     length:    130543
     offline;
     copy 1:   Jun  4 10:55       286.1324f lt DLT001
     access:   May 24 16:55  modification: May 24 16:38
     changed:  May 24 16:38  attributes:   Jun  4 10:55
     creation: May 24 16:38  residence:    Jun  4 10:55

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:

    # request -p 0x286 -m lt -v DLT001 /sam1/xxxx

The following example creates a request file with the contents of the example file from step 2a that is on optical disk:

    # request -p 0xd2e -m mo -v v1 /sam2/xxxx

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
    #

Note - You can ignore the 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.

`#` `sls -D /sam2/test/file3` `/sam2/test/file3:` `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` `changed: May 1 15:40 attributes: May 1 15:44` `creation: May 1 15:40 residence: May 1 16:50`

##

Restoring a Regular File Without Information From an Archiver Log

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:

- If you are using an automated library, the automated library daemon is active on the system.

- If you are using a manually mounted, standalone drive, `/kernel/drv/st.conf` is correctly configured for the tape drive that you are using. For more information about performing this task, see how to add tape support to the `st.conf` file in the Sun StorEdge SAM-FS Installation and Upgrade Guide.

### 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. .

    # samcmd unavail 51

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.

    # samload 50:03 51

3. Use the `mt`(1M) command to rewind the tape.

The following example shows this command applied to tape drive `/dev/rmt/2`.

    # mt -f /dev/rmt/2cbn rewind

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`.

    # od -c /dev/rmt/2cbn
    0000000   V   O   L   1   X   X   X
    0000020                                   S   A   M   -   F   S       1
    0000040   .   0
    0000060
    0000100                                                               4
    0000120   H   D   R   1
    0000140                                               0   0   0   1   0
    0000160   0   0   1   0   0   0   1   0   0       2   4   9   0   9
    0000200                                                   S   A   M   -
    0000220   F   S       1   .   0
    0000240   H   D   R   2       1   6   3   8   4                   1
    0000260                                                   2   0   g 031
    0000300
    *
    0000360

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.

TABLE 5-3 Block Sizes Corresponding to the Bottom Five Digits of Block Size in the ANSI Label
Bottom Five Digits of Block Size | Block Size for `dd`(1) | 512-byte Blocks for `tar`(1) and `star`(1M)
--- | --- | ---
16384 | 16 kilobytes | 32 blocks
32768 | 32 kilobytes | 64 blocks
65536 | 64 kilobytes | 128 blocks
31072 | 128 kilobytes | 256 blocks
62144 | 256 kilobytes | 512 blocks
24288 | 512 kilobytes | 1024 blocks
48576 | 1024 kilobytes | 2048 blocks
97152 | 2048 kilobytes | 4096 blocks

7. Issue one of the following commands:

- If the `star`(1M) command is available, use it to find the file in the archive.

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.

Note - `star` files have an extended maximum file size of 1 Tbytes-1. `tar` and `star` files have compatible formats only at file sizes less than or equal to 8 Gbytes-1. At file sizes larger than 8 Gbytes, the formats of `star` and `tar` files are not compatible. Therefore, you must use the `star` command to read archives larger than 8 Gbytes-1.

CODE EXAMPLE 5-3 shows the s`tar` 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.

CODE EXAMPLE 5-3 `star` (1M) Command for Examining the First `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-4 shows the same command used to examine the next `tar`(1) file.

CODE EXAMPLE 5-4 `star` (1M) Command for Examining the Second `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-5 `star` (1M) Command for Examining Additional `tar` (1) Files
    # star -tv -b 32 -f /dev/rmt/2cbn
    -rw-rw----  0/1   102564 Sep  6 13:02 1996 test2
    6+1 records in
    11+1 records out
    # star -tv -b 32 -f /dev/rmt/2cbn
    -rw-rw----  0/1   102564 Sep  6 13:02 1996 test2
    6+1 records in
    11+1 records out

CODE EXAMPLE 5-6 shows that the end of the tape has been reached.

CODE EXAMPLE 5-6 `star` (1M) and `mt` (1M) Output Showing the End of the Tape
    # star -tv -b 32 -f /dev/rmt/2cbn
    0+0 records in
    0+0 records out
    tar: blocksize = 0
    # mt -f /dev/rmt/2cbn status
    Other tape drive:
     sense key(0x13)= EOT   residual= 0   retries= 0
     file no= 5   block no= 0

- If the `star`(1M) command is not available, use the `dd`(1M) and `tar`(1) commands to examine the archives.

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-7 `dd` (1M) Command for Examining the First `tar` (1) File
    # dd if=/dev/rmt/2cbn ibs=16k obs=10k conv=sync | tar tvf -
    -rw-rw----  0/1   102564 Sep  6 13:02 1996 test
    6+1 records in
    11+1 records out

CODE EXAMPLE 5-8 shows the same command examining the next `tar`(1) file.

CODE EXAMPLE 5-8 `dd` (1M) Command for Examining the Next `tar` (1) File
    # dd if=/dev/rmt/2cbn ibs=16k obs=10k conv=sync | tar tvf -
    -rw-rw----  0/1   102564 Sep  6 13:02 1996 test
    6+1 records in
    11+1 records out

CODE EXAMPLE 5-9 shows the examination of two copies of another file.

CODE EXAMPLE 5-9 `dd` (1M) Command for Examining Additional `tar` (1) Files
    # dd if=/dev/rmt/2cbn ibs=16k obs=10k conv=sync | tar tvf -
    -rw-rw----  0/1   102564 Sep  6 13:02 1996 test2
    6+1 records in
    11+1 records out
    # dd if=/dev/rmt/2cbn ibs=16k obs=10k conv=sync | tar tvf -
    -rw-rw----  0/1   102564 Sep  6 13:02 1996 test2
    6+1 records in
    11+1 records out

CODE EXAMPLE 5-10 shows that the end of the tape has been reached.

CODE EXAMPLE 5-10 `dd` (1M) and `mt` (1M) Output Showing the End of the Tape
    # dd if=/dev/rmt/2cbn ibs=16k obs=10k conv=sync | tar tvf -
    0+0 records in
    0+0 records out
    tar: blocksize = 0
    # mt -f /dev/rmt/2cbn status
    Other tape drive:
     sense key(0x13)= EOT   residual= 0   retries= 0
     file no= 5   block no= 0

Note - You might receive errors during this process. The following error indicates that the block size you selected does not match that of the tape: `read: not enough space` If you receive this error, correct the block size and try again.

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.

CODE EXAMPLE 5-11 Using the `star` (1M) command or the `dd` (1M) and `tar` (1) Commands
    # dd if=/dev/samst/c0t1u0 bs=1k iseek=3374 of=/tmp/junk count=10
    dd: read error: I/O error
    8+0 records in
    8+0 records out
    # tar xvf /tmp/junk
    # star -xv -f /tmp/junk
    tar: blocksize = 1
    -rw-rw---- 0/1 2673 May 1 15:41 1996 dir3/dir2/file0
    -rw-rw---- 0/1 946 May  1 15:41 1996 dir3/dir1/file1
    -rw-rw---- 0/1 468 May  1 15:41 1996 dir1/dir3/file0

##

Restoring a Segmented File Using Information From an Archiver Log

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 Example Archiver Log File
    A 2002/11/19 14:01:47 ib E00000 all.1 1276a.1 samfs4 14.5 10485760 seg/aaa/1 S 0 51
    A 2002/11/19 14:04:11 ib E00000 all.1 1276a.5002 samfs4 15.5 10485760 seg/aaa/2 S 0 51
    A 2002/11/19 14:06:24 ib E00000 all.1 1933a.1 samfs4 16.5 184 seg/aaa/3 S 0 51

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:

- Field 4. Media type on which the file is stored. For the supported media types, see the `mcf`(4) man page.

- Field 5. VSN.

- Field 7. File position. From the position indicator portion to the left of the period (`.`) in the field.

- Field 10. Segment size. This is the length field.

The first line in the previous screen example provides the following information:

- The media type is `ib`.

- The VSN is `E00000`.

- The file's position is `1276a`.

- The segment size is 10485760.

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:

    # request -m ib -p 0x1276a -v E00000 /sam3/rmfile

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.

    # star xvbf 512 /sam3/rmfile
    seg/aaa/1
    seg/aaa/2

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.

    # cd seg
    # pwd
    /sam3/seg
    # ls -l
    total 8
    drwxrwx---   2 root     other       4096 Jun 15 17:10 aaa/
    # ls -l aaa
    total 40968
    -rw-rw----   1 root     other    10485760 Jun 15 17:06 1
    -rw-rw----   1 root     other    10485760 Jun 15 17:06 2
    -rw-rw----   1 root     other        184 Jun 15 17:07 3
    # pwd
    /sam3/seg
    # cd aaa
    # pwd
    /sam3/seg/aaa

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.

    # ls | sort -n | xargs cat > ../bbb

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.

    # cd ..
    # pwd
    /sam3/seg
    # ls -l
    total 41000
    drwxrwx---   2 root     other       4096 Jun 15 17:10 aaa/
    -rw-rw----   1 root     other    20971704 Jun 15 17:11 bbb
    # ls -l aaa
    total 40968
    -rw-rw----   1 root     other    10485760 Jun 15 17:06 1
    -rw-rw----   1 root     other    10485760 Jun 15 17:06 2
    -rw-rw----   1 root     other        184 Jun 15 17:07 3
    # rm -rf aaa

6. Use the `touch`(1M) command to create an empty file.

    # touch aaa

7. Use the `segment`(1) command to set the segment attribute on the file that you just created.

    # segment -l segment-length m filename

where:

- segment-length is the length of the segment in megabytes.

- filename is the name of 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.

    # segment -l 10m aaa

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.

    # cp bbb aaa
    # rm bbb

9. Issue the `sls`(1) command with the `-2K` option to list the segments of the segmented file in two lines of output.

    # sls -2K aaa
    -rw-rw----   1 root     other     20971704 Jun 15 17:12 aaa
    ---------- ----- sI {3,0,0,0}
    -rw-rw----   1 root     other     10485760 Jun 15 17:12 aaa/1
    ---------- ----- sS
    -rw-rw----   1 root     other     10485760 Jun 15 17:12 aaa/2
    ---------- ----- sS
    -rw-rw----   1 root     other          184 Jun 15 17:12 aaa/3
    ---------- ----- sS

##

Restoring a Volume Overflow File Using Information From an Archiver Log

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.

CODE EXAMPLE 5-13 Archiver Log File Entries
    A 2004/08/23 10:28:51 sg 700036 ReleasePercent.1 12d55.1 qfs2 11731.1 89128448 ReleasePercent/huge2/dir24/file3 f 0 210
    A 2004/08/23 10:28:51 sg 700034 ReleasePercent.1 15f9e.0 qfs2 11731.1 525271552 ReleasePercent/huge2/dir24/file3 f 1 220

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.

    # 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.

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.

    # cat file3.0 file3.1 > file3.2
    # 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
    -rw-r--r--   1 root     other    614465536 Aug 31 12:21 file3.2
    # star xvbf 256 file3.2
    ReleasePercent/huge2/dir24/file3
    # sls -D ReleasePercent/huge2/dir24/file3
    ReleasePercent/huge2/dir24/file3:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length: 614400000  admin id:      0  inode:    12481.1
      access:      Aug 31 12:40  modification: Aug 20 14:28
      changed:     Aug 31 12:43  attributes:   Aug 31 12:40
      creation:    Aug 31 12:40  residence:    Aug 31 12:40

##

Restoring Files Archived to Disk

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

- To Restore Files From a Disk Archive tar(1) File

### 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:

- The disk volume name.

- The path to the disk archive `tar`(1) file.

- The path name defined for the disk volume name in `diskvols.conf`(4).

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.

- You can use the `sls` method if you have `sls`(1) output for the files you want to restore.

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.

    # sls -D filea fileb filec
    filea:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length:     65732  admin id:      0  inode:   120235.783
      archdone;
      copy 1: ---- Nov  3 14:46     81366.1    dk DISK_01 d8/d19/f102
      copy 2: ---- Nov  3 14:54     2ec7e.209  dk DISK_02 d2/d236/f126
      copy 3: ---- Nov  3 14:58        bf.209  dk DISK_03 f191
      copy 4: ---- Nov  3 15:05      ea7a.209  lt 000064
      access:      Nov  3 14:35  modification: Nov  3 14:35
      changed:     Nov  3 14:35  attributes:   Nov  3 14:35
      creation:    Nov  3 14:35  residence:    Nov  3 14:35
    fileb:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length:     65732  admin id:      0  inode:   120300.783
      archdone;
      copy 1: ---- Nov  3 14:46     81366.105  dk DISK_01 d8/d19/f102
      copy 2: ---- Nov  3 14:54     2ec7e.411  dk DISK_02 d2/d236/f126
      copy 3: ---- Nov  3 14:58        bf.411  dk DISK_03 f191
      copy 4: ---- Nov  3 15:05      ea7a.411  lt 000064
      access:      Nov  3 14:35  modification: Nov  3 14:35
      changed:     Nov  3 14:35  attributes:   Nov  3 14:35
      creation:    Nov  3 14:35  residence:    Nov  3 14:35
    .
    .
    .

- You can use the archiver log method if you have an archiver log file that includes the files you want to restore.

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.

    A 2003/11/03 14:46:35 dk DISK_01/d8/d19/f102 arset4.1 81366.1 shareqfs2 120235.783 65732 testdir4/filea f 0 0
    A 2003/11/03 14:46:35 dk DISK_01/d8/d19/f102 arset4.1 81366.83 shareqfs2 120243.783 65732 testdir4/filec f 0 0
    A 2003/11/03 14:46:35 dk DISK_01/d8/d19/f102 arset4.1 81366.105 shareqfs2 120300.783 65732 testdir4/fileb f 0 0
    A 2003/11/03 14:50:35 dk DISK_01/d8/d19/f103 arset4.1 81367.3 shareqfs2 120228.783 131420
    A 2003/11/03 14:54:35 dk DISK_02/d2/d236/f126 arset4.2 2ec7e.38f shareqfs2 120243.783 65732 testdir4/filec f 0 0
    A 2003/11/03 14:54:35 dk DISK_02/d2/d236/f126 arset4.2 2ec7e.411 shareqfs2 120300.783 65732 testdir4/fileb f 0 0
    A 2003/11/03 14:58:35 dk DISK_03/f191 arset4.3 bf.3 shareqfs2 120228.783 131420
    .
    .
    .

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.

    # star -tv -f /ufs2/disk_archive/01/d8/d19/f102
    -rw-r--r-- root/other    65732 2003-11-03 14:35 testdir4/filea
    -rw-r--r-- root/other    65732 2003-11-03 14:35 testdir4/filec
    -rw-r--r-- root/other    65732 2003-11-03 14:35 testdir4/fileb

Note - If the tar file is on a remote server, accessing it requires proper configuration of the remote authentication database. For information on configuring the `/.rhosts` file, see the `hosts.equiv`(4) man page.

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.

- In the following example, shows the `star`(1M) command is used to retrieve the single 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

- In the following example, the `star`(1M) command is used to retrieve 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

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.

    # sls -DR
    testdir4:
      mode: drwxr-xr-x  links:   2  owner: root      group: other
      length:      4096  admin id:      0  inode:   120274.789
      access:      Nov  4 14:11  modification: Nov  4 14:11
      changed:     Nov  4 14:11  attributes:   Nov  4 14:11
      creation:    Nov  4 14:11  residence:    Nov  4 14:11
    testdir4:
    testdir4/filea:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length:     65732  admin id:      0  inode:   120293.787
      access:      Nov  4 14:11  modification: Nov  3 14:35
      changed:     Nov  4 14:11  attributes:   Nov  4 14:11
      creation:    Nov  4 14:11  residence:    Nov  4 14:11
    testdir4/fileb:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length:     65732  admin id:      0  inode:   120281.783
      access:      Nov  4 14:11  modification: Nov  3 14:35
      changed:     Nov  4 14:11  attributes:   Nov  4 14:11
      creation:    Nov  4 14:11  residence:    Nov  4 14:11
    testdir4/filec:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length:     65732  admin id:      0  inode:   120280.783
      access:      Nov  4 14:11  modification: Nov  3 14:35
      changed:     Nov  4 14:11  attributes:   Nov  4 14:11
      creation:    Nov  4 14:11  residence:    Nov  4 14:11

##

Retrieving Unarchived Files From File Systems

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:

- You can use the `sfind`(1M) command line to identify all files in a file system that are not archived. The following command finds all unarchived files associated with the `/sam1` mount point:

    # sfind /sam1 ! -archived

- If the `samfsdump`(1M) method was used to dump and back up metadata, the `samfsrestore`(1M) command identifies files without archive copies and flags them as damaged.

- Sun StorEdge SAM-FS log files cannot help you determine which files were not archived and were therefore lost between the last archiver run and the system outage. However, you can determine the files that might not have been archived by analyzing the `archiver.cmd` file for archiving directives and intervals. If all files are eligible for archiving, you can find the age of the oldest unarchived (lost) files in the `archiver.cmd` file's contents.

- You can use the `-l` and `-v` options with the `archiver`(1M) command to determine whether volumes were available to archive each archive set's data before the outage. Lack of sufficient volumes can prevent archiving of data in one or more archive sets. For information about the `archiver`(1M) command, see the `sam-archiverd`(1M) man page.

- If you are recovering files directly from a backup tape in `tar`(1) format, the files are restored to their locations according to the information on the tape. The path name is relative to the mount point of the file system. If any files have been moved within the system since the archive copies were created, they are restored to their original locations, not to their new locations.

1 (TableFootnote) The position is the value on the left of the field with the format position.offset.

Copyright © 2006, Sun Microsystems, Inc. All Rights Reserved.