C$RECOVER

This routine opens the transaction log file defined in the LOG_FILE configuration variable and replays all of the file operations recorded in it on the appropriate data files.

Note that file systems other than Vision may require you to use their own recovery routines, instead of C$RECOVER. Please refer to your file system manufacturer's documentation to learn how the file system handles recovery procedures.

Usage

CALL "C$RECOVER".

Description

This routine allows you to recover from a hardware failure or power outage that may have left your data files in a corrupt state. C$RECOVER is helpful for recovering from error 98s and from any error that leaves your data damaged or possibly destroyed.

In order to use this routine, you need to have been logging transactions with the START TRANSACTION and COMMIT TRANSACTION verbs. These cause file operations to be logged in log files that you designate with the LOG-FILE. Use the LOG_INCLUDE_PATTERN or LOG_EXCLUDE_PATTERN variables to determine which files' operations are recorded in the log file.

You also need a good backup of your data files. This backup should have been created just before you cleared or deleted the log file. You use your backup to restore the damaged files. Then you use C$RECOVER to read the log and recreate all of the file operations in the log, in the same sequence they were logged. These file operations are replayed on the data files. Use the LOG_RECOVER_REPORT variable to write an audit trail of the recovery process to a file.

The result is that your data files are brought up to date. After recovery, all files will be in a consistent state, because only committed (completed) transactions will be replayed from the log.

One way to use this routine is described here. First get everyone off the system. Then restore your clean backup files to their original locations. (It's a good idea to have more than one backup, because you will need a clean backup in order to recover.) Then run a COBOL program that calls the C$RECOVER routine (for example, CALL C$RECOVER). Make sure that the LOG-FILE configuration variable is set correctly. Repeat this procedure for each log file.

If a GIVING phrase is omitted, the special register RETURN-CODE is updated: a zero indicates a successful recovery, and any other value indicates a failure. The failure value corresponds to a transaction error code; see Transaction Error Codes in Appendix E of the ACUCOBOL-GT Reference Manual for a full list of values.

To make sure that your data can be recovered, follow these guidelines:

  1. Commit all transactions before you make your data file backups.
  2. Clear (or delete) your old log files as soon as your backup is complete and you know you have a good backup.
  3. Don't permit any file activity between the time you make your backup and the time you clear or delete the logs.
  4. It is possible to have multiple log files. You may periodically back up the log file and start a new one, if you are careful not to do this while there is any activity on the log or data files. Just be sure to run C$RECOVER on each log file in the same order in which they were written.
  5. Don't permit any activity on the data files during recovery.
  6. If any log file gets corrupted or destroyed, immediately make data file backups and clear or delete the old log.