Format
- exrecover [–s]
[name_file …]
- exrecover [–v]
Description
The exrecover daemon
recovers text files from working files created by vi and ex.
(These working files are in one or more temporary directories.) It
is normally invoked from a system startup file before these working
files are purged.
Options
- –s
- Suppresses error messages.
- –v
- Displays the version number of exrecover.
Environment variables
exrecover uses
the following environment variables:
- TMP_VI
- Contains
a directory path name that can be specified by an administrator as
a location for vi temporary files. This
is useful if the current default directory for these files (usually /tmp)
is implemented as a TFS. In this case, all vi temporary
files that the exrecover daemon uses for
recovery would be gone after a system crash.
IBM® recommends that this environment variable
be set by a system administrator as opposed to a user setting it for
their environment. If the latter occurs and the user sets the TMP_VI
directory to something different than what exrecover recognizes
as TMP_VI, the user will need to run the exrecover daemon
manually to allow the temporary files to be converted to the recoverable
files used by vi (located in /etc/recover/$LOGNAME).
Restrictions: The
system administrator should not do the following:
- Set TMP_VI to /etc/recover/$LOGNAME.
- Set TMP_VI to any directory where a path name component is an
environment variable with a user's value different than the initialization
process's value (for example, $HOME). vi temporary
files are converted into a form recoverable by vi when exrecover is
run during IPL. Because exrecover is issued
during IPL, it is owned by the initialization process and will therefore
contain different values for certain environment variables, if those
environment variables are set. Throughout the file system, there may
exist some temporary files that can only be converted by exrecover.
This conversion can be done manually by a system administrator (to
recover files owned by all users) or by a single user (to recover
only their own files).
- TMPDIR
- The
default directory. When this environment variable is set, exrecover looks
in this directory for the ex and vi working
files.
- TMP
- If
TMPDIR is not set, TMP specifies the directory to be searched when
looking for the ex and vi working
files.
If both TMPDIR and TMP are not set, exrecover uses
the directory that the XL C/C++ runtime library function tempnam()
would use.
Localization
exrecover uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_MESSAGES
- NLSPATH
See Localization for more
information.
Files
exrecover uses
the following files:
- /tmp/VIl*
- Line table
files.
- /tmp/VIn*
- Name files.
- /tmp/VIt*
- Paged text files.
- /etc/recover
- The directory containing
subdirectories of user names whose files have been recovered. Only
users with the appropriate privileges, such as the system administrator,
can create the /etc/recover directory.
- /etc/recover/$LOGNAME/VIn*
- Contains the
name of the file that was being edited.
- /etc/recover/$LOGNAME/VIt*
- Contains the recovered
text of the file that corresponds to the VIn* file
Rule: Using a TFS for vi temporary
files will make it impossible to recover vi files
after a system crash. vi writes temporary
files to TMP_VI or TMPDIR (or /tmp by default),
and if the system crashes, those files can be recovered by the exrecover command,
which automatically runs from /etc/rc. If the files
are written to a TFS, then they will be wiped out when the system
is IPLed. See the TMP_VI description under Environment Variables section
of this command.
Usage notes
- To recover all the files in the temporary directory, this command
must be run with appropriate permissions (for example, superuser privileges)
so the recovered files can be stored in the /etc/recover directory
with the appropriate ownerships and permissions.
For example,
the following is a shell script to recover the files from TMPDIR,
where TMPDIR is the default directory:
export TMPDIR=/tmp
exrecover
- If it is invoked by a nonprivileged user (for example, a user
who is not a root user), then only those files owned by that user
are recovered. Because vi and ex create
their working files in directories specified by the TMPDIR or TMP
environment variables, one of these environment variables must be
set before exrecover can be issued.
For
example, the following is a shell script that recovers files from
$HOME/tmp:
export TMPDIR=$HOME/tmp
exrecover
- exrecover is also invoked by vi or ex when
you issue the ex preserve command
or when exrecover receives a SIGHUP signal.
The working files created by vi and ex are
found in a default temporary directory (such as /tmp)
or in the directory specified by the TMPDIR or in the directory specified
by the TMP_VI,, TMPDIR, or TMP environment variable. Three working
files are created:
- name_file
- Contains the actual name of the vi file.
The names of all name_files begin with VIn.
- line_table_file
- Contains a dummy page followed by data that gives, in line number
order, the offset for each line of text in the corresponding paged_text_file.
The page size is typically 1K, but may vary on some systems. The names
of all line table files begin with VIl.
- paged_text_file
- Contains lines of text that are at most LINE_MAX bytes in length.
Lines shorter than LINE_MAX byte are ended by a newline. The names
of all paged text files begin with VIt.
- You can also run the program by specifying name_file on
the command line. For example:
exrecover /tmp/VInaaaa.111 /tmp/VInbbbb.222 …
exrecover searches
for a name_file and tries to open the associated
line table and paged text files. If all these files are found, exrecover builds,
from the line table and paged text files, a text file and stores it
in the directory /etc/recover/$LOGNAME.
It
also stores a corresponding
name_file to
identify the file that was recovered and sends mail, using the
mailx utility,
to the owner of the file indicating the date, time, and name of the
file recovered. You can retrieve recovered files in one of the following
ways:
vi –r file [issued from a shell command line]
ex –r file [issued from a shell command line]
:recover file [issued from within a vi session]
Each command loads the most recent occurrence of the file recovered
from a system failure or the ex preserve command.
If vi successfully loads the file, it removes
the preserved file.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Memory allocation error
- No working files were found
- No /etc/recover directory errors that affect
the overall operation of the exrecover command
- An incomplete set of working files were found
- 2
- Usage error
- 3
- An error occurred while recovering a specific file. Some, but
not all, files were recovered.
Related information
ex, vi