Tags:
create new tag
view all tags

File Analysis and Recovery

Verifying and Analyzing a File

You can verify a file's integrity from the Data File Management menu ('Verify Files') or from the command line. To verify files from the command line:

In Windows: %APPXPATH%\..\appx.exe -v={filename}
In Unix: $APPXPATH/../appx -v={filename}
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.

The Verify step is a pass/fail test. To get more information about the file you can analyze it via:

In Windows: %APPXPATH%\..\appx.exe -an={filename}
In Unix: $APPXPATH/../appx -an={filename}
This will give 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.

FREELIST damage (APPX 4.0.a & earlier)

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

Recovering a Damaged File:

These techniques require thought knowledge of the Appx directory/file structure as well as the associated application files and processing. If you have any questions after reading these procedures, please call Appx Technical Support (1-800-879-2779) before proceeding.

There are several techniques that may recover damaged file(s). We recommend that you back up your files before attempting one these techniques. Select the appropriate method after careful analysis of your particular situation.

Important Note

The Export and Import utilities should not be used for recovering a damaged file. In all likelihood this method will result in lost data.

Rebuilding the key file

This is the easiest & simplest type of recovery. Either delete or rename the existing .key file, then run 'Create Files' on the Data File Management menu. This will rebuild the key file, and when it is complete run the 'Verify' step again to check the record counts and confirm the file is good. Even if the file passes verification, you might have lost data. If possible, check the file to see if any valid data was lost.

Restoring files from Backup

Note that all work performed since the backup was made will be lost.

When restoring design files, the entire application should be restored from backup, not just a single file. The best course of action is to restore all of the applications for the version to ensure that design integrity is maintained across applications.

When restoring data files, it may be necessary to restore the entire database. For example, it makes no sense to restore an Order file without also restoring its line item file. Consider other files which may have been updated during the course of processing. Those files may also need to be restored.

APPX Recover Utility

If the above techniques aren't successful, then you can run the Appx Recover Utility. This is the safest method for recovering your damaged or corrupt file(s).

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 consecutive file, either fixed length or variable length depending on the attribute of the original 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.

By recovering the *.dat file, you invalidate the original *.key file.

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.

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: r8 - 2016-10-11 - JeffPrentice
 
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