File Analysis and Recovery

Verifying and Analyzing a File

In Windows: %APPXPATH%\..\appx.exe -v={filename}
In Unix: $APPXPATH/../appx -v={filename}
... will manually verify an APPX datafile. This does the same thing as interactive "Verify Files Menu", "Verify Integrity" from the Database, Design File, and System Administration File Management menus, but from a command line.

If the invocation of this command results in no output, then the file passes verification. Any output from this command means that the file fails verification.

To analyze a damaged file ...

In Windows: %APPXPATH%\..\appx.exe -an={filename}
In Unix: $APPXPATH/../appx -an={filename}
... gives you a"BRF>" prompt for {filename}. The most useful command at this prompt is ...

VERIFY KEY #ALL

which performs counts the number of records in the .dat portion of the file verifying the .dat as it goes, and verifies all Keys in the .key portion of the file. Other useful commands are:

HELP          - list all available commands.

DUMP HEADER   - will give you info about the file, including the
                number of keys.

COUNT REC     - will give a count of the number of records that
                {FILENAME.dat} believes it contains.

VERIFY KEY #0 - verifies the primary index, and gives # of records.

VERIFY KEY #1 - verifies the alt index #1, and gives # of records.

VERIFY KEY #2 - verifies the alt index #2, etcetera ...

QUIT          - exit the "-an=" utility.

If the file doesn't pass #ALL verification, but does pass COUNT REC verification, then it means that the *.dat portion of the file is probably OK, but the *.key indices are probably damaged. In this case, rename or delete the *.key file, then run 'Create Files' on the Data File or Design File Management menu. This will recreate your indices from scratch.

If the file doesn't pass COUNT REC analysis, you have a seriously damaged *.dat file. Your best bet at this point is to use the recover procedure below, or if necessary restore from backup.

FREELIST damage

A type of file damage that VERIFY KEY #ALL does not tell you about is freelist damage. The freelist is the list of pointers in AppxIO files that point to deleted records. This list can get damaged. It could for example point to a live record, indicating erroneously that it is deleted.

Up through APPX version 4.0.a the menu driven Verify Integrity utilities, the 'appx -v={filename}, and the 'appx -an={filename}', VERIFY KEY #ALL option don't detect such damaged freelist conditions.

To find a damaged freelist condition, you must use the APPX engine (the engine is all that's necessary) release 4.0.a or higher, then go into the BRF> command line from 'appx -an={filename}', then execute the command:

VERIFY FREELIST

If the freelist is damaged, this command will give you an error condition to that effect. To repair the damage, execute:

VERIFY KEY #ALL

If the file passes this verification, you may safely export and re-import the file, in order to initialize its freelist.

If the file doesn't pass #ALL verification, but does pass COUNT REC verification, then it means that the *.dat portion of the file is probably OK, but the *.key indices are probably damaged. In this case, rename or delete the *.key file, then run "Create Files" on the Data File or Design File Management menu. This will recreate your indices from scratch. It will then be safe to export and re-import the file.

If the file doesn't pass COUNT REC analysis, you have a seriously damaged *.dat file. Your best bet at this point is to use the recover procedure below, or if necessary restore from backup.

Recovering a Damaged File:

The following steps can be used to recover data from a damaged file. You can also use this technique to recover accidentally deleted records, if you can perform this procedure in time. Since APPX re-uses deleted records, if new data is added after the deleted records, the deleted record may already be overwritten.

Usage:

In Windows: %APPXPATH%\..\appx.exe -r old.file new.file [deleted.record.file]
In Unix: $APPXPATH/../appx -r old.file new.file [deleted.record.file]
This utility will read an APPX indexed data file (.dat) and copy the good/active records to the output file. Any corrupt data is hex-dumped to the screen. If you redirect standard output (>bad.data ), you can collect any corrupted data into a file, for later examination.

Deleted Records are discarded, unless a third filename is given on the command line. In this case, the deleted records are copied to the given file. This file is a fixed-length consecutive file. To access it from within APPX, you must design transfer your data dictionary, remove the indices, and change the file type to consecutive. This is needed since the deleted records could contain duplicate key values.

Overhead blocks are also removed. These blocks are used to track deleted record space within the file for reuse. Since the new file has no deleted record space, it no longer needs these blocks.

This utility does not deal with duplicate primary or unique alternate indices.

After the command is complete, new.file contains the salvaged data. To access it, rename or delete the original file, then rename the new file to the original file name. Then you must create a new *.key file. This is done by renaming or deleting the existing *.key file, then running "Create Files" on the Data or Design File Management menu. The *.key file contains pointers to all of the data records in the *.dat file. By recovering the *.dat file, you invalidate the original *.key file.

Example:

The following command (in Windows) ...

appx.exe -r C:\APPX\DATA\DDD\PAT\Data\BB.dat C:\APPX\DATA\DDD\PAT\Data\BB.new

... will generate the following output and files ...

APPX Recover Utility:
             Input Filename = C:\32\DATA\ttt\PAT\Data\bb.dat
            Output Filename = C:\32\DATA\ttt\PAT\Data\bx.dat
File Header Information:
          File Organization = 3 ( Fixed Length Records )
              Record Length = 19
             UnixIO Version = 2
  Freelist Starting Address = 0
        End of File Address = 617
Recover Completion Information:
     Active Records Copied = 3
    Deleted Records Removed = 0
   Overhead Records Removed = 0
          File Errors Found = 0
      New Eof Seek Location = 617
 Space Allocation Reduction = 0 bytes

* You MUST create a new '.key' file that matches your new '.dat' file!

Comments:

Read what other users have said about this page or add your own comments.



Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r5 - 2016-01-20 - JeanNeron
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback