The EDRC simplify the development of recovery scripts and helps to
recover your environment in an efficient and reliable way.
The WA2L/edrc package has to be an integral part of a whole disaster
recovery plan and process. This process is documented step by step
in an "Emergency Handbook".
- !<number>
-
execute the command with the number
<number>
listed in the
edrc
history. To list the history use the
history
command.
- !!
-
execute the command you invoked the last. This command is evaluated
from the
edrc
history. To list the history use the
history
command.
- @
-
execute the menupoint you invoked the last. This command re-invokes
the menupoint which is displayed after the ":" in the EDRC
prompt.
- b, back, up
-
go one menu back. Respectively exit a submenu and go back to the
overlying menu.
- banner
-
display the program startup banner with the copyright and version
information.
- busy
-
print a rotating slash. This command does nothing productive. It might
be useful to keep a line open when for instance a firewall cuts the
connection if a TCP timeout is reached. To end the rotating press
Ctrl+C.
- clear
-
clear screen.
- date
-
print the current system date and time.
- debug
-
toggle the script debug variable
$DEBUG
between
False
and
True.
All recovery shellscripts should have the following line included
to be able to react to the
debug
command:
test "$DEBUG" = True && set -x
After startup the
$DEBUG
variable is set to
False.
- distribute
-
distribute recovery scripts to other hosts. This command allows you to
keep all recovery scripts on all your hosts synchronized. It is
recommended that you set up your recovery menu tree that way that
you can have an identical set of scripts on all your hosts.
This has the advantage of a "single point of administration".
See
edrc.cfg(4)
for information about the configuration and the configuration file
names.
The
distribute
command will guide you to a couple of steps needed to transfer the
scripts to a set of hosts. It is also possible to enter hostgroups (
@HOSTGROUP
), as known from the
hostlist
command.
You will have the opportunity to cancel at several points.
-
- Distribution types:
-
To speed up distribution and to allow some parallel editing on different hosts
you can choose between a
differential
and a
full
distribution. A
full
distribution contains all files in a recovery script tree, a
differential
distribution contains only the files that are newer then the last
full
distribution.
The following guideline helps to decide which distribution type to
use in what situation: If things are removed or renamed, use a
full
distribution, in all other cases use a
differential
distribution.
- The following steps are performed by the distribute command:
-
-
- 1.)
-
create a new distribution file. This file contains scripts in
SCRIPTS_BASEDIR.
If you decide to create a
full
distribution, all files will be packed. If you decide to create a
differential
distribution, only the files will be packed which are newer then
the last distribution file created by a
full
distribution.
- 2.)
-
specify a list of hosts to distribute the distribution file to.
- 3.)
-
distribute (copy) the distribution file to each target host in the
list.
- 4.)
-
on the target host backup the current scripts. If it is a
full
distribution all scripts are backed up. If it is a
differential
distribution only the files which will be overwritten are backed up.
- 5.)
-
if it is a full distribution remove all scripts in
SCRIPTS_BASEDIR
on the target host.
- 6.)
-
extract the distribution file to the
SCRIPTS_BASEDIR
on the target host.
- Hint:
-
The host where you invoke the
distribute
command is excluded from distribution. Therefore you can keep the
local host in the
DIST_HOSTLIST
and the configuration file
edrc.cfg
can be kept identical on all your hosts.
To view the contents of a compressed backup file (without
decompressing it) you can use the
lscomp,
llcomp
and
catcomp
commands in the shell.
- edrcdebug
-
this will toggle debugging on the
edrc
command between
False
and
True.
Normally only the author of
edrc
will use this command for debugging of the EDRC itself. To
debug your recovery scripts use the
debug
command.
- edrcperm
-
list the complete permission set and all functionality that is
defined to be denied. The denial of the startup of certain functions
can be specified in the
edrc.cfg
file with the
DENY_LIST
setting.
For a disaster recovery configuration, you should *never* deny any
functionality from startup, due to the fact that in a disaster
recovery maximal flexibility has to be provided under all circumstances.
Therefore the feature to deny certain functions from execution should
only be used for system administration configurations, and even
there - use it moderately! The user gets the message:
"edrc-WARNING: execution of functionality '<option>' not permitted."
if a certain command/functionality is not permitted to be executed.
See also
edrc.cfg(4)
for more information.
- env
-
create, edit, view, remove the environment file. The environment
file (
_env
) is used to do common settings for a certain menu (=directory).
So you can set passwords, ORACLE_SID's etc. in this file and
you don't have to edit all your recovery scripts in this menu if you
change the password (for instance). You could also do some
user prompting in this environment file if you have to.
To keep the process and the dependencies simple the environment
settings are not inherited to sub-menus.
If you like to share a whole recovery script tree later with other
system administrators you can strip out all passwords from
_env
files with the
envpasswdstrip
shell command. This command triggers for patterns
like 'export*password=my_secret' and 'export*passwd=my_secret'
and substitutes the password with the string 'PASSWORD_STRIPED_OUT'.
-
- How a recovery script is started:
-
-
- 1.)
-
If an environment file (
_env
) exists for the current menu
(=directory), the
_env
file is sourced and the variables defined in it are set. Your
code has to be ksh conform and the variables have to be exported.
- 2.)
-
If the recovery script is executable, invoke it directly. It is
also validated, if the command defined in the recovery scripts
magic key exists. If the shell in the magic key does not exist
a fallback mechanism tries to resolve an alternate shell to
be used to start the recovery script.
- 3.)
-
If the recovery script is not executable, start it in using
the shell as defined in the magic key. Here the fallback
mechanism as described above applies as well.
- Hint:
-
To be sure that your settings will reach the recovery
script you should always export your variables.
When you create a new environment file a template is provided.
The environment file has the filepermissions 600.
- Example _env file:
-
#
# _env - Environment settings for commands in ....
#
# [00] 29.01.2003 CWa Initial Version
#
#
test "$DEBUG" = True && set -x
export system_password=coo1runnings
export sys_password=he11oworld
export scott_passwd=tiger
export app_user=psoft
export oracle_sid=FS75PROD
export oracle_owner=oracle
- erase
-
set the erase terminal character. Normally the system can determine
the erase character by itself. However, in some circumstances it is
still wrong. The
erase
command allows you to choose an erase character from a list or to
specify the correct character by yourself.
- header
-
create, edit, view, remove a menu header. The menu header is intended
to display additional information below the menu title, if the menu
title information is not sufficient.
- help, h, usage, ?
-
print a short help of all internal and contributed
(contrib.edrc(1m))
commands.
- history, hist
-
print the history of
edrc.
The history contains all invoked commands. Commands which are
entered repetitive are listed only once.
- hostname
-
print the hostname of the system you started
edrc
on.
- loadrec
-
load a previous saved recovery point in time from disk.
This will set the
$EDRC_RECOVERYTIME
environment variable which is exported to all recovery
scripts.
To display a recovery point in time, use the
printrec
command, to set a recovery point in time, use the
setrec
command.
- log
-
view the last logfile. Every output of a recovery script is saved to a
logfile. Therefore your recovery scripts don't have to care about
logging information.
- man
-
display manual pages.
- menu, m, ls
-
print the menu. In the menu title the name of the current
session (if set with the
name
command) is displayed. All menupoints are enclosed by square
brackets: [ 28 ]. Submenus are marked with a "
>
" sign. The current location in the script tree is part of the
edrc
prompt. The prompt consists of three parts which might not be
present at all times:
edrc@host/Oracle/PSYS:157>
In this example you are in the sub-sub menu "PSYS" and the last
menupoint you selected was "157". If you execute a
edrc
command after you selected a menupoint this will not influence the
prompt. So it is very easy to see what your last action during the
recovery was.
It will make sense that the menupoints correspond to the reference
numbers in the "Emergency Handbook" of your environment.
- name
-
give the current session a name. This is useful to avoid confusion
and to find the right session if you started parallel multiple
sessions.
The logfiles contain the session name in square brackets: [example ].
If you do not set a session name the current process id or a random
value is used as an (ad hoc) session name.
The current session name is printed in the menu head (SESSION: )
when the menu is listed using the
menu
command.
During a "Disaster Case" or "Disaster Case Simulation" it is highly
recommended to set the session name as advised by the "Emergency Handbook".
If possible a session name is transferred to a remote host when a trunk is
established. However, if on the remote system a session with the
same name is already running, a new (ad hoc) session name will be set
automatically.
- newmenu, newdir
-
create a new menu in the recovery script menu tree.
edrc
will guide you thru the naming of the menu. Finally a menu is a
directory with the name:
<menu_point>:<name>
menu_point
*and*
name
has to be unique in the current menu.
If the menu title contains a
semicolon (
;
) the menu entry will be broken into two lines at the position
of the semicolon when using the
menu
command.
- newscript
-
create a new recovery script.
edrc
will guide you thru the naming of the script and will provide a
template script which contains some key elements. The name of the
script will be:
<menu_point>:<name>
menu_point
*and*
name
has to be unique in the current menu.
If the script header contains a
semicolon (
;
) the menu entry will be broken into two lines at the position
of the semicolon when using the
menu
command.
- PID
-
print the UNIX process id of the
edrc
session.
- printrec
-
display the currently set recovery point in time.
To set a recovery point in time, use the
setrec
command, to load a saved recovery point in time, use the
loadrec
command.
- quit
-
quit
edrc
at any point.
- removemenu
-
remove an existing submenu. Prior to the removal
the menu is backuped.
- removescript
-
remove an existing recovery script. Prior to the removal
the file is backuped.
- renamemenu
-
rename an existing submenu.
- renamescript
-
rename an existing recovery script. Prior to the rename
the file is backuped.
- setrec
-
set recovery point in time.
This will set the
$EDRC_RECOVERYTIME
environment variable which is exported to all recovery
scripts.
The date format has to be compliant to the
NLS_DATE_FORMAT
configured in
edrc.cfg.
You can save your recovery point in time to have it
available after a newstart of
edrc.
To save the recovery point in time would be a good idea
in most cases. If you have to change the recovery point in time
only temporarily for a certain recovery action you probably
won't save it.
To display a recovery point in time, use the
printrec
command, to load a saved recovery point in time, use the
loadrec
command.
- shell
-
start a shell in
edrc.
You should use this command to exit to the operating system
rather than to do an other telnet or rlogin to the system.
When you use the
shell
command the current working directory is the location in the
menu you are currently in. Furthermore the shell settings are
tuned and customized to the WA2L/edrc environment and all
$EDRC_
environment variables are exported to the shell.
On UNIX the Korn-Shell (ksh), on Linux the Bourne-Again-Shell (bash)
will be started. To see all additional commands and aliases
you have available in the shell type
usage
within the started shell.
See
shell(1)
for a description of the additional commands available.
- term
-
set the terminal emulation (the
$TERM
environment variable) for the current session. See also:
edrc.cfg(4).
- title
-
edit, view, remove a menu title created while creating a new
submenu. Or create a menutitle for a menu which was not labeled
so far.
- top
-
browse directly back to the root menu. If it is a trunk, browse
to the trunk root.
- trunk
-
create, edit, view, remove, activate, deactivate the trunk
definition (
_trunk
) for a menu. A trunk is basically the invocation of a menu on
a remote system. Therefore, ahead of defining a trunk, a normal
menu has to be created. A trunk definition enhances a menu
with the behavior to be started on a remote system transparently
without the need to first manually log on to the remote system,
start
edrc
and then change to the desired submenu.
To establish a trunk to a remote system it must be possible to
connect with
OpenSSH
mode (
-m OpenSSH
) to the remote system using the
remote_shell
command and the recovery scripts have to be distributed. See also
remote_shell(3)
and
edrc.cfg(4)
for more information.
When a new trunk is defined using the
trunk
command, a specification template consisting of the following
elements is provided:
-
-
target::=
[
comment
:
]
hostname
-
- The
target
listed in the specifications below can consist of a
comment
(optional) and a
hostname
(not optional) where to connect to. The
comment,
if specified, is displayed at the trunk dialog instead of the
hostname.
The
comment
and the
hostname
has to be separated by a colon (
:
). Furthermore spaces and tabs are not allowed in a
comment
text and between the
comment,
the
:
and the
hostname.
If spaces in the
comment
output are needed, they have to be replaced by a
%
character in the definition.
-
ACTIVE=
True
|
False
-
- If
ACTIVE
is set to
True
the trunk specification is active and a remote menu
invocation will be established based on the remaining
trunk settings. If it is set to
False
the trunk specification exists but is not active. In this case
the menu behaves as a normal submenu. When the
trunk
command is invoked, it is possible to toggle this setting
using the
(a)ctivate
and
(d)eactivate
options prompted when invoking the
trunk
command.
-
TYPE=
direct
|
prompt
|
prompt:nolocal
-
- If
TYPE
is set to
direct
the trunk is established immediately without prompting the
user. When it is set to
prompt
or
prompt:nolocal
a dialog is displayed and the user is prompted for a selection of a
target to establish the trunk to. The dialog for a
prompt
trunk always includes one menu point to stay on the local system
and not to establish a trunk to a remote system. A
prompt:nolocal
trunk does not provide the local selection.
-
DEFAULT=
target
-
- The target definition here takes into effect if the
TYPE
setting is set to
direct
and no
target
is entered in the
TAGETS
definition. If
TYPE
is set to
prompt
the setting made here is printed in the "Default:" section of
the user dialog.
This setting is interpreted by a shell, therefore it is also possible
to do some dynamic stuff here.
-
TARGETS=
target
[{
target
}]
-
- White space separated list of targets to be listed in the "Targets:"
section of the user dialog when
TYPE
is set to
prompt.
If
TYPE
is set to
direct
and no
DEFAULT
target is defined, all elements of this list are probed and the first
one that is up is used to establish the trunk to.
This setting is interpreted by a shell, therefore it is also possible
to do some dynamic stuff here.
-
TARGET_MENUPATH=
menupath
-
- This is an optional setting that is only used for advanced exceptional trunk
specifications. When specifying the
menupath
it is possible to choose a different entry menu at the trunk target.
-
TARGET_CONFIG=
configfile
-
- This is an optional setting that is only used for advanced exceptional trunk
specifications. When specifying the
configfile
it is possible to establish a trunk to a target using a target configuration
that differs from the local configuration.
-
- 1) Example of a simple trunk specification:
-
#
# _trunk - Trunk specification for menu /HP_11/services
#
# [00] 22.03.2007 CWa Initial Version
#
#
ACTIVE=True
TYPE=prompt
DEFAULT="host-001"
TARGETS="host-001 host-002 host-003 host-004"
- 2) Example of a more enhanced trunk specification:
-
#
# _trunk - Trunk specification for menu /HP_11/services
#
# [00] 22.03.2007 CWa Initial Version
#
#
ACTIVE=True
TYPE=prompt
DEFAULT="`server_environment`:localhost"
TARGETS="
MAINTENANCE:host-001
TEST:host-002
PREPRODUCTION:host-003
PRODUCTION:host-004
"
- 3) Example defining a dynamic target list
-
The target list consists of all hosts defined to be member of the group
@ALL
as defined in the
HOSTGRPS
setting in the
edrc/etc/hostlist.cfg
file. Therefore, if a host is added to the
@ALL
group, the trunk
target list will be automatically enhanced.
#
# _trunk - Trunk specification for menu /HP_11/services
#
# [00] 22.03.2007 CWa Initial Version
#
#
ACTIVE=True
TYPE=prompt
DEFAULT=""
TARGETS="`hostlist -g @ALL`"
- 4) Example of exceptional advanced trunk specification
-
Suppose
~edrc/bin/sat
is started (
~edrc/sbin/edrc -c edrc.sat.cfg
), you are in the menu
/HP_11
and the submenu
services
is a trunk. This example definition will establish a trunk using the
configuration
~edrc/etc/edrc.psup.cfg
on the trunk target. The entry menu on the remote system is
/user_mgmt
instead of
/HP_11/services.
It is not imperative to use both advanced trunk specification
options in an advanced trunk definition.
Hint: The advanced trunk definition options (
TARGET_MENUPATH
and
TARGET_CONFIG
) should be used *very* moderately and with a good reason, due to the fact
that the chance is high that advanced trunks cannot be established later
on (error message:
edrc-FATAL: menu does not exist, aborting
), because the target menu structure could be changed without realizing
that a certain (sub)menu is a trunk target. On normal trunks, where the
menu and the configuration is identical and the menu tree is distributed,
this cannot happen.
#
# _trunk - Trunk specification for menu /HP_11/services
#
# [00] 22.03.2007 CWa Initial Version
#
#
ACTIVE=True
TYPE=prompt
DEFAULT="host-001"
TARGETS="host-002 host-003 host-004"
TARGET_MENUPATH="/user_mgmt"
TARGET_CONFIG="edrc.psup.cfg"
- trunkbypass
-
toggle bypassing of active trunks between
True
and
False.
When toggle trunk bypassing to
True
all active trunks are bypassed in the current session and are not followed.
It might be helpful to bypass trunks to efficiently edit many menu points in
submenus which are defined as trunks. Doing so you do not have to first
deactivate and after editing activate the trunk for each menu separately.
- tty
-
print the TTY you are logged on and the
edrc
program is started in.
- tz
-
set the time zone (the
$TZ
environment variable) for the current session. See also:
edrc.cfg(4)
and
timezone(3).
- $EDRC_NLS_DATE_FORMAT
-
national language support date format. The recovery point in time
has to comply with this format.
- $NLS_DATE_FORMAT
-
same as
$EDRC_NLS_DATE_FORMAT.
- $EDRC_NLS_LANG
-
national language support language name.
- $NLS_LANG
-
same as
$EDRC_NLS_LANG .
- $DEBUG
-
used to debug recovery scripts or contributed commands. This variable
is set to
False
(no debugging)
or
True
(debugging). Your script should contain the following line to allow
debugging:
test "$DEBUG" = True && set -x
- $EDRC_ENTRY_DIR
-
current directory where your recovery script is located or where
you enter the filesystem tree when you invoke the
shell
command.
- $EDRC_TMP_DIR
-
this variable points to a secure temporary directory that
exists during the execution of a recovery script, contributed command
or the shell command and is afterwards removed.
This variable is therefore exported to recovery scripts, contributed
commands and the shell command only.
This variable should be used to securely
save temporary data during the execution of a recovery script
or a contributed command.
- $EDRC_TMP_DIR_SESSION
-
this variable points to a secure temporary directory that
exists during the execution of an
edrc
session and is afterwards removed.
This variable is exported to recovery scripts, contributed
commands and the shell command only.
This variable should be used to securely
save temporary data from recovery scripts
or contributed commands that must be accessed
multiple times throughout the
edrc
session.
You should add the name of the
recovery script or contributed command as prefix
to ensure a unique filename.
Example:
date > $EDRC_TMP_DIR_SESSION/$EDRC_SCRIPTNAME.begin
If you need to save temporary data during the execution
of a recovery script or a contributed command the
$EDRC_TMP_DIR
variable shall be used.
- $EDRC_OSID
-
the systems operating system id evaluated by
osid.
See
osid(3)
for more information.
- $EDRC_SCRIPTS_BASEDIR
-
name of the recovery scripts basedir. This environment variable
is set to the value you specified with the
SCRIPTS_BASEDIR
option in the
edrc.cfg
configuration file. See
edrc.cfg(4)
for more information.
- $EDRC_ENV
-
name of the environment file. See description in section
COMMANDS,
at the
env
command. Therefore do *not* hard-code _env in your scripts, use this
variable.
- $EDRC_CONFIGFILE
-
name of the configuration file loaded in the current
edrc
session.
- $EDRC_LOGFILE
-
logfile of the current script. Normally you will not have to write to
this file by your own,
edrc
will redirect all output of your recovery script to this file.
- $EDRC_RECOVERYTIME
-
point in time to recover to. See description in section
COMMANDS,
at the
setrec
command.
- $EDRC_SCRIPTNAME
-
name of the recovery script (without the "<menu_point>:" part). If you
use the
msg
command for message output this name will appear in front of
the "-" sign.
- $EDRC_MENUPOINT
-
menu point of the recovery script (without the ":<scriptname>:" part).
- $EDRC_SESSION
-
name of the
edrc
session. If you use the
log
command (what will normally not be the case in recovery scripts) the
session name is written between the square brackets into the logfile (
$EDRC_LOGFILE
).
- $EDRC_CONTRIB_VARDIR
-
var directory for contributed commands. This environment variable is
only exported to contributed commands. If you have to save persistent
information store it to this location.
You should add the name of the
contributed command as prefix to ensure a unique filename.
Example:
date > $EDRC_CONTRIB_VARDIR/$EDRC_SCRIPTNAME.begin
- $EDRC_SEED
-
session persistent random seed number.
- $EDRC_SHELLHIST
-
history file for the shell started with the
shell
EDRC command. This environment variable is only exported to the shell
started within
edrc.
- $EDRC_DIST_USER
-
this variable equals to the
DIST_USER
setting in the
etc/edrc.cfg
file.
- $EDRC_DEBUG
-
switch all commands in
edrc/bin
and
edrc/lib
into debugging mode. This allows to debug also commands
that don't have the debugging option
-x
implemented.
Do not mix up this environment variable with the
$DEBUG
environment variable. When debugging recovery scripts only the
$DEBUG
variable is of significance.
- $EDRC_DEBUG_COMMAND
-
switch a
command
in
edrc/bin
or
edrc/lib
into debugging mode. This allows to debug also commands
that don't have the debugging option
-x
implemented.
Do not mix up this environment variable with the
$DEBUG
environment variable. When debugging recovery scripts only the
$DEBUG
variable is of significance.
- $TODAY
-
current date in the form YYYYMMDDD (example: 20061021).