Skip to content

How Do You Rebuild a Corrupt Elliott File?


Release Date: 05/02/2023
Version: 7. 0 & Up

If a Btrieve data file is corrupt, you can use Butil to rebuild the file. The basic process is to make a copy of the file without any records and then copy all of the records out of the old file into the new copy. Butil will be able to read and extract the records out of the bad file until it encounters a corrupt record, at which point it will stop. There are two methods to copy the records out of the bad file. One method uses the index and the other reads sequentially through the file. Since the two methods use different paths through the file, one method may yield more records than the other. If you are unable to recover all of the records, it may be beneficial to try both methods. If only the index is corrupt, Butil -Recover may be able to get all of the records.

The utility of Butil.exe can be found in “C:\Program Files (x86)\Actian\PSQL\bin” and this is added to your Command Prompt path when Pervasive is installed.  Butil can be run directly on the server or at a workstation from the command prompt, but we suggest running the rebuild directly on the server for speed and to eliminate the network traffic.

The three methods to rebuild a file are: (1) use the Save command, (2) use the Recover command, and (3) use the Copy command, which is really a subset of method 2.

1) Butil -Save creates a sequential ASCII file from a Btrieve file based on the index. The steps are:

Butil -Clone creates a new, empty file with the same file specifications as the existing file.
Butil -Save reads data along a key path and writes the results to a sequential file.
Butil -Load loads the contents of an unformatted file (from Save) into a data file (Clone file).


2) Butil -Recover creates a sequential ASCII file from a Btrieve file, but uses the physical path to read the records from the file. It reads the Btrieve file from top to bottom. The steps are:

Butil -Clone creates a new, empty file with the same file specifications as the existing file.
Butil -Recover reads data sequentially from a data file and writes the results to an unformatted file.
Butil -Load loads the contents of an unformatted file (from Recover) into a data file (Clone file).


3) Butil -Copy performs in a single step the same functions as the Recover command followed by the Load command. So alternately you could do these steps:

Butil -Clone creates a new, empty file with the same file specifications as the existing file.
Butil -Copy copies the contents of one data file to another.

If you have any problems with the Copy command, we suggest using Recover or Save and then the Load command.

The syntax for these commands are:

Butil -Save {input Btrieve file (the bad file)} {output file}
Butil -Recover {input Btrieve file (the bad file)} {output file}
Butil -Copy {input Btrieve file (the bad file)} {output Btrievefile}
Butil -Clone {output file} {source file (the bad file)}
Butil -Load {input file (the file from save or recover)} {output Btrieve file (your cloned file)}

Type Butil without any options to see a list of options and switches.

PSQL 7.0 introduced to Butil the /I switch, which specifies reading forward through the file, which is the default, and the /J switch, which specifies reading backward through the file. If you use both switches, Butil will read forward through the file from the beginning until it encounters a bad record and then read backwards through the file from the end until it encounters a bad record. If the methods above do not recover all the records, try adding both of the /I and /J switches. See the Pervasive.SQL User's Guide for more information.

NOTE: Butil has a -Salvage option. This is not suggested as it can damage files.

MAD

Feedback and Knowledge Base