![]() | ||
| Database | ![]() ![]() ![]() ![]() | Backup |
Note: If transferring export or other text (machine independent) files between machines using ftp, you must use ftp in ACSII mode (not BINARY)
There are various procedures and the utilities to assist in protecting a database and recovering it in the case of problems.The key to a successful recovery operation is being prepared. Do not assume that the computer, disk drives or power supply are always 100% trouble free. Be prepared for unexpected problems by taking regular backups, saving journals and, in general, take reasonable precautions against losing much time or work.
The procedure for restructuring a database is the same as for backing up and recovery.
There are utilities which are designed to work in pairs with one providing input in a suitable format for the other.
Some utilities create or use binary files which are operating system internal formats and are specific to an operating system. These files are created in "append" mode; that is they are added to the end of any existing unload or subset file with the same name. However, if you run these through the menu system, you are given the choice of deleting the old file first.
Other utilities create text files which are machine independent and can be viewed and updated by any text editor. These are produced independently and will overwrite existing files.
EXPORT
creates a file containing a text copy of the database, including the data dictionary, procedures and data. This can be used by IMPORT to create a new database on a different machine.
WRITE SCHEMA writes just the database definition in a similar format to export.
SUBSET writes a binary copy of a subset of the database to a file. This includes schema and data. This can be used by MERGE to combine with an existing database or RELOAD to create a new database which is a subset of the original.
UNLOAD
writes a binary copy of the database to a file including
the data dictionary and the procedures.
UPLOAD
creates a text copy from the journal of all updates
that have been done. This can be used by
DOWNLOAD to apply
those changes to a second copy of the database. An example of this might
be a central database with subsets on various PCs in remote locations. Updates
might be done on the PCs and UPLOADed to the center, or
updates might be done in the center and UPLOAD to the PCs to
avoid re-transmitting the whole of the database.There are two utilities which check on the contents of the system.
VERIFY checks on the
contents of the actual database.
This gives details of any problems discovered. This
utility may be run with a PATCH option which recovers from
many types of corruptions. If some type of problem has occurred, a SIR2002 process may
warn that a corruption has occurred. If this happens, use the VERIFY
FILE utility to find out more about the problem, and attempt to
correct it.
ITEMIZE
reports on the contents of binary files including
the journal file and files produced by UNLOAD or
SUBSET.
LIST STATS
reports on the current status of the database giving the number of
records, data size and update level.
If a database has to be recovered from backups, restore the database from the backup and then use JOURNAL RESTORE to bring that version of the database up to the level of the journal file.
.
UNLOAD FILE and read by
RELOAD FILE
SIR SUBSET and read by
MERGE
JOURNAL and read by
JOURNAL RESTORE
ITEMIZE.
EXPORT and read
by IMPORT
WRITE SCHEMA
UPLOAD and read by
DOWNLOAD
This can be done in a number of ways:
There is a command "
Database administrator security is required to use
Separate multiple parameters on the command with slashes.
Specify a logical expression to select those records which meet the
criteria of the logical expression. For example:
eg (assuming the datemap for birthday is
eg (assuming the datemap for birthday is
In these cases it is best to convert the string to a number for the comparison:
Examples:
Export also writes a summary of the data records exported. This lists the number
of cases, each record type exported and the number exported.
eg (assuming the datemap for birthday is
eg (assuming the datemap for birthday is
In these cases it is best to convert the string to a number for the comparison:
Use the
At this point, previous unload files and journal files can be renamed or deleted.
The options and keywords are:
If this is specified, a report is produced showing each update level
that is written to the upload file. For example:
The options on the command are:
The report produced is similar to the following:
A) Overall Database Information
B) Information about each Record Type
C) Restructure Information (if any)
D) Secondary index information (if any)
If a premature End-of-Record condition is encountered, the database is restored
to a useable (non-corrupt) state, with as much data intact as possible. It is
recommended that a
The options on the command are:
For example:
The corruption flag is set when any errors are detected in the database. It is cleared when the database is verified and found to contain no errors.
The keywords control the amount of checking and the amount of output generated when verifying each data record. The error message number is followed by a character which signals the type of error message: I for Informative, N for Non-correctable, C for Correctable, F for Fatal. The loading factors are printed with 2 decimal digits. Errors are listed by type with informative messages as appropriate.
For example
If the record type is already defined in the target database schema, the source
and target record type definitions must match exactly. If a new record type is
being merged, the schema for the new record type is created containing
everything from the source database schema definition except the
If the target database is caseless, the case id and CIR's on the
source database are ignored. A caseless source cannot be merged into a case
structured target. (Use
The options on this command are:
eg (assuming the datemap for birthday is
eg (assuming the datemap for birthday is
In these cases it is best to convert the string to a number for the comparison:
By default, both new records are added to the database and existing
records are replaced.
The reload database name and password must be the name and password of the
database on the unload file. To change database names and passwords, specify the
new name and password on the
Separate multiple parameters on the command with slashes.
Example:
IMPORT
To import and recreate a complete database, simply tell SIR2002 to read the export file generated by a previous EXPORT utility. This file is a text copy of a database consisting of commands to
recreate the database and data to load into it.Database\Recover\Import menu
IN = parameter
Procedures - File
menuIMPORT" which indicates that data,
in a suitable format for importing, follows the command. eg:
IMPORT
0/1/1/2/4/1/12/John D Jones1/1/11/772-21-1321129754/1/M1/5/2150/145851/2/4/
145120/1500/1/2/5/145733/2000/1/3/4/145241/5/1650/2/3/4/145180/4/1600/2/3/5/
145851/5/2150/2/3/5/145794/4/2100/2/0/2/1/1/3/1/25/James A Arblaster 1/1/
...
EXPORT
EXPORT FILENAME = fileid
[/BOOLEAN = (log_expr)]
[/LIST = caseid, ...]
[/RECTYPES = ALL | rectype(log_expr) ...]
[/SAMPLE = fraction [,seed]]
[/COUNT = total [,increment [,start]]]
[/DATABASE = new database name]
[/PASSWORD = new database password]
[/NODATA]
[/NOINDEX]
[/NOMAXKEY]
[/NOPASSWORDS]
[/NOPROCS]
[/SIROLD]
Creates a file of text records containing the data dictionary,
procedures and data from the database. Exports all non-compiled procedures, i.e
members with a :T, :M or :P suffix (text, menu and picture (template) members).
Compiled procedures (:E, :O and :V) are not machine independent and cannot be
exported. Compiled procedures must be re-compiled after an
IMPORT.EXPORT.
If the export does not run because record types in the database are locked
(due to schema modifications) then
restructure
the database before rerunning the export.FILENAME
BOOLEAN
TRUE. Only use
common variables in the expression and only use for databases with a case
structure. The test is applied after any SAMPLE, COUNT or
LIST. If the case id is a categorical, date or time variable,
specify either a string or numeric test and the equivalent variable value is
used. VisualPQL functions can be used. For example:
BOOLEAN = (ID GT 5)
LIST
THRU to select a range. For example:
LIST = 12 THRU 29, 33, 37
RECTYPES
RECTYPES clause. If this clause is omitted,
data for all record types in the database are exported.RECTYPES = EMPLOYEE (SALARY GT 2000)
Caution
When comparing dates, times or catvars with strings remember that the variable
is converted to a string using its default format then compared with the string.DDIMMIYYYY):
RECTYPES = EMPLOYEE (BIRTHDAY lt '01 01 1960')/
is a
comparision of strings and the string '02 12 1920' is greater than the
string '01 01 1960'.YYYYIMMIDD):
RECTYPES = EMPLOYEE (BIRTHDAY lt '01 01 1960')/
will compare
strings like '1960 12 31' with '1960/01/31'. The former is less than the later
because the character ' '(blank) has a lower ascii value to the slash.
RECTYPES = EMPLOYEE (BIRTHDAY lt CDATE('1960/01/31','YYYYIMMIDD'))/
SAMPLE
SAMPLE = .25 exports 25% of
the cases from the database using a default seed.COUNT
DATABASE
PASSWORD
NODATA
NOINDEX
NOMAXKEY
NOPASSWORDS
NOPROCS
SIROLD
To export the entire database:
EXPORT FILENAME = 'COMPANY.EXP'
To export record types 5, 6, and 8 of the first 1000 cases:
EXPORT FILENAME= 'SUBSET.EXP' /
RECTYPES= 5 6 8 /
COUNT= 1000 /
The export procedure writes out a number of messages. These note the beginning
and end of various stages of the export (Begin export of schema/Export of schema
complete, Begin export of procedures/etc.).
SIR SUBSET
SIR SUBSET FILENAME = filename
[/ BOOLEAN = (logical expression)]
[/ LIST = caseid list]
[/ RECTYPES = rectype [(logical expression)] ...]
[/ SAMPLE = fraction [,seed]]
[/ COUNT = total [,increment [,start]]]
[/ DATABASE = newdbname]
Creates a sequential (machine specific) copy of a subset of an existing
database. The schema and procedures are written in their entirety. Only the data
that meets the criteria is subset. Database administrator security is required
to use this utility.FILENAME
ITEMIZE FILE utility to determine
which copies are on there.BOOLEAN
BOOLEAN is applied after SAMPLE and
COUNT. For example:
SIR SUBSET FILENAME = 'SUBSET.UNL' /
BOOLEAN = (ID GT 5)
LIST
SAMPLE or
COUNT. For example:
SIR SUBSET FILENAME = 'SUBSET.UNL' /
LIST= 1,3,5 thru 10
RECTYPES
SIR SUBSET FILENAME = 'SUBSET.UNL' /
RECTYPES = 1 (SALARY GT 2000),3
Caution
When comparing dates, times or catvars with strings remember that the variable
is converted to a string using its default format then compared with the string.DDIMMIYYYY):
RECTYPES = EMPLOYEE (BIRTHDAY lt '01 01 1960')/
is a
comparision of strings and the string '02 12 1920' is greater than the
string '01 01 1960'.YYYYIMMIDD):
RECTYPES = EMPLOYEE (BIRTHDAY lt '01 01 1960')/
will compare
strings like '1960 12 31' with '1960/01/31'. The former is less than the later
because the character ' '(blank) has a lower ascii value to the slash.
RECTYPES = EMPLOYEE (BIRTHDAY lt CDATE('1960/01/31','YYYYIMMIDD'))/
SAMPLE
COUNT or LISTCOUNT
SAMPLE or LISTDATABASE
SIR SUBSET FILENAME = 'SUBSET.UNL' /
DATABASE = TESTDBMS
UNLOAD FILE
UNLOAD FILE FILENAME = filename
[/JOURNAL = KEEP | PURGE]
[/NEWDB = newname]
[/NEWPW = newpassword]
Creates a machine dependent copy of the database. UNLOAD is
used for backup and restructuring. Database administrator security is required
to use this utility.UNLOAD FILE utility to back up the database. The old
journal file can be deleted once an unload file is produced. A database may be
recovered from an unload file plus any journals from the point the unload was
done. Make sure that there is either a journal file that covers the entire
history of the database, or an unload file and a journal file that covers
modifications made to the database since the unload.
The suggested procedure is:ON for the database.
UNLOAD FILE on a regular
basis.
VERIFY FILE
before doing an unload)
FILENAME
ITEMIZE FILE to see what
is on the output file. If multiple copies of a database are on one physical
file, specify the file number or update level to restore the correct copy of the
database. For example:
UNLOAD FILE FILENAME = 'COMPANY.UNL'
JOURNAL
KEEP is the default and specifies that the current
journal file is retained.
PURGE specifies that the current
journal file is deleted when the unload run is completed. Journalling then
starts on a new file.NEWDB
NEWPW
UNLOAD FILE FILENAME = 'COMPANY.UNL' /
NEWDB = TESTDBMS /
NEWPW = TESTPASS
[NODATA]
and [DATAFILE = fileid] are obsolete. These do not
cause a compile error but now have no effect.
UPLOAD
UPLOAD FILENAME= filename
[/JOURNAL = filename]
[/UPDATE = update level [THRU update_level]]
[/RECTYPES = ALL | rectype (variable_list), ...]
[/TITLE = 'upload_file_title']
Reads a journal file and outputs all the journalled changes to a file. This file
is a text file so that it can be transferred to another machine. The
DOWNLOAD utility reads the file produced by UPLOAD
and applies the changes to the new database. Database administrator
security is required to use this utility.FILENAME
JOURNAL
UPDATE
UPLOAD FILENAME = 'JOURNAL.UPL' /
UPDATE= 10 THRU 30
RECTYPES
CIR selects the common information record variables.
ALL selects all record types, including CIR and is the
default. For example:
UPLOAD FILENAME = 'JOURNAL.UPL' /
RECTYPES= 1,3
TITLE
DOWNLOAD
prints this title in the summary report. This title may be up to 45 characters
and is enclosed in quotes. For example:
UPLOAD FILENAME = 'JOURNAL.UPL' /
TITLE= 'Department 3 Changes'
ITEMIZE FILE
ITEMIZE FILE [FILENAME= fileid/]
Reports on the contents of a
binary file.
A single binary file can contain multiple outputs. For example, one
physical journal file may have the journals from several update levels.
This information is necessary when restoring a database or
applying journals.FILENAME
FILE ORDINAL 1
TYPE OF RECORD: SEQUENTIAL DATA FILE
DATABASE NAME: CLIENT
'FROM' UPDATE LEVEL: 349
DATE: 03/20/97
TIME: 14:28:41
The information reported is:FILE ORDINAL
TYPE OF RECORDDATABASE NAME
'FROM' UPDATE LEVEL
'TO' UPDATE LEVELDATE
TIME
LIST STATS
LIST STATS
Provides a status report about the database similar to the following:
Statistics for COMPANY
Database name COMPANY
Creation Date/Time 02/04/02 09:31:36
Last update Date/Time 02/07/02 11:57:16
Update level 266
Average Records per Case 1023
Max/Current Number of Cases 1000/21
Max/Current Number of Records 1023000/1166
Max/Current Number of Record Types 60/4
Maximum Input Columns/Lines 80/1
Rectype Column 5
Sequence Column None
Journal For Database OFF
Case Id Variable ID (A)
Number of Index Levels 2
Max Entries Per Index Block 126
Index/Data Block Size 253/254
Active/Inactive Data Blocks 33/3
Active/Inactive Index Blocks 2/0
Keysize In Bytes 8
Min/Max Record Size 0/51
Number of Temporary Variables 0
Maximum Number of Data Variables 11
Record Type Number of Maximum Total In Size In Entry Use
No. Name Variables Per Case Database Words Count
-------------- --------- -------- -------- ------- ---------
0 CIR 1 1 21 9 1
1 EMPLOYEE 11 1 21 8 1
2 OCCUP 4 100 31 1 1
3 REVIEW 5 100 64 2 1
4 REC_4 2 100 1050 51 4
Restructured Records
Record Type Previous Changed Update Level
No. Name Variables Variables From - To
-------------- --------- --------- ------------
4 REC_4 1 0 0 - 265
Secondary Indexes
Index Name Record Variables
---------- ------ ---------
NAME EMPLOYEE NAME ASC
The information includes:
JOURNAL RESTORE
JOURNAL RESTORE [FILENAME = fileid /] [UPDATE = n /]
Applies journal files to a database to update it to a more current level. Any
schema changes are restored as well as updates to the data.JOURNAL RESTORE can restore partial journal records from
abrupt interruptions of journalled update sessions.VERIFY FILE is done after a journal has
been restored.JOURNAL RESTORE keeps a copy of the CIR in memory and updates
the Record Count Field (RCF) in that CIR. If the CIR is not on the input
journal (for any reason), the "computed" CIR is written to the database,
leaving the database physically correct. However if a logical set of updates
were being done and were interrupted, data may be in an inconsistent state
between records.FILENAME
JOURNAL RESTORE FILENAME = 'COMPANY.JNL'
UPDATE
LIST STATS and
ITEMIZE FILE.JOURNAL RESTORE FILENAME = 'COMPANY.JNL' /
UPDATE = 42
VERIFY FILE
VERIFY FILE [ALL]
[/CIRKEY]
[/CIRDATA]
[/CHECK]
[/CCF]
[/RECKEY]
[/RECDATA]
[/RCF]
[/COUNT= total,increment,start]
[/PATCH]
VERIFY FILE examines the database files for damage and corrects errors where possible. DBA-level security clearance is needed if any keywords are specified, since potentially secure data might be revealed.ALL
CIRKEY
CIRDATA
CHECK
CCF
RECKEY
RECDATA
RCF
COUNT
Total
Increment
Start
PATCH
VERIFY FILE
again to verify the patched database to clear the corruption flag if no errors
are detected.VERIFY FILE Error Codes
The following error messages show the types of problems detected. Most of these
errors are "major", and if any of them occur (except for error 17), the data
file is probably unsaveable. (For an explanation of the structure of the
database, what is a PRU, etc., please see
Tuning and Efficiency.)
2 index pru that is out
of range
3 index pru in error
2 index entry found
3 index pru in error
2 index count
calculated
3 index count in upper level
4 index pru in error
2 db pru in error
2 db entry in header
3 db
pru in error
2 db used in
header
3 db pru in error
2 rectype
3 mismatch (- more records than count (records will have been listed indiviually as error 09), + if count is more than records)
2 rectype
3 count field in error
4 legal max record count for
rectype
2 record ordinal
3 rectype
2 record
ordinal
3 rectype
2 incirn detected
3 incirn
4 db pru in error
2 record ordinal
3 recdrn detected
4 recdrn
5 db pru in
error
2 record ordinal
3 rectype detected
4 db pru in error
2 reccnt
detected
3 reccnt
2 dinrec
2 dincas
2 master
index overflow
3 data file is full
2 number should be
2 index block level
3 case
data file ord:case ord (last case)
4 record ordinal
2 case data file ord:case ord
(last case)
3 record ordinal
2 index
block level
3 case data file ord:case ord (last case)
4 record ordinal
2 case data
file ord:case ord (last case)
3 record ordinal
DOWNLOAD
DOWNLOAD FILENAME= filename
[/MESSAGES= ON | OFF]
Reads the text file produced by
UPLOAD
from a journal and applies these changes to the database. Database
administrator security is required to run this utility.FILENAME
DOWNLOAD FILENAME = 'JOURNAL.UPL'
MESSAGES
DOWNLOAD FILENAME = 'JOURNAL.UPL' / MESSAGES = ON
SIR MERGE
SIR MERGE FILENAME = input_file
/ DATABASE = database [PASSWORD = password]
[SECURITY = read password]
/ RECTYPES = ALL | source [:targetno,name] [(expression)]
[/ BOOLEAN = (log_expr)]
[/ NODATA]
[/ RENAME = [source](source_list = target_list)]
[/ UPDATE = ADD | REPLACE]
Merges record types from a copy of one database (source) into an
existing database (target) which is the database currently being used.
The source is a
binary file.
The FILENAME, DATABASE, and
PASSWORD, SECURITY clauses if required on
this database, must appear before any other clauses.
DBA write security for the target database is required
to use this command. This utility is not available through the menu system.IF,
COMPUTE, RECODE, ACCEPT REC IF and REJECT REC IF
statements.SIR SAVE FILE
to create a case structured database from a caseless database.)FILENAME
DATABASE
PASSWORD
SECURITY
SIR MERGE FILENAME = 'COMPANY.EXP' /
DATABASE = COMPANY /
PASSWORD = COMPANY /
SECURITY = HIGH
RECTYPES
If the ALL
source
RENAME clause is used, specify the new name of
the variable in this clause.BOOLEAN
TRUE the case is merged.Caution
When comparing dates, times or catvars with strings remember that the variable
is converted to a string using its default format then compared with the string.DDIMMIYYYY):
RECTYPES = EMPLOYEE (BIRTHDAY lt '01 01 1960')/
is a
comparision of strings and the string '02 12 1920' is greater than the
string '01 01 1960'.YYYYIMMIDD):
RECTYPES = EMPLOYEE (BIRTHDAY lt '01 01 1960')/
will compare
strings like '1960 12 31' with '1960/01/31'. The former is less than the later
because the character ' '(blank) has a lower ascii value to the slash.
RECTYPES = EMPLOYEE (BIRTHDAY lt CDATE('1960/01/31','YYYYIMMIDD'))/
NODATA
RENAME
RENAME does not change variable names
on existing target records. Specify the RENAME= rectype
(source variable list = target variable list) form when more than one record
type is being merged. The rectype is the source rectype:
SIR MERGE /.../ RENAME = 1 (EMPNAME = NAME)
UPDATE
ADD
REPLACE
RELOAD FILE
RELOAD FILE dbname
FILENAME = fileid
[/PASSWORD = password]
[/SECURITY = rsec,wsec]
[/UPDATE = n | FILE= n]
[/LOADING = n]
[/NOFCASES = n]
[/AVGREC = n]
[/RESTART]
Recreates a database. The input is a
binary file which is a
copy of a database.UNLOAD.FILENAME
UNLOADed to the same file more than once), specify
UPDATE= n or FILE= n to reload a copy other
than the first.PASSWORD
SECURITY
UPDATE
ITEMIZE FILE
reports the update levels of multiple database copies on a file.FILE
LOADING
AVGREC
RECS PER CASE
in the Case Schema definition for a case-structured database.
The specified value is the average number of records per case.NOFCASES
N OF CASES
in the Case Schema definition for a case-structured database.
The specified value is an upper limit on the number of cases in the
reloaded database.
RESTART
RELOAD FILE MYDBMS /
FILENAME = 'COMPANY.UNL' /
UPDATE = 52



