|
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 that are designed to work in pairs with one providing input in a suitable format for the other.
Some utilities create or use binary files that 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 that are machine independent and can be viewed and updated by any text editor. These are produced independently and 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 subset of the database to an unload binary file. This includes the schema and data for selected record types. This can be used by MERGE
to combine with an existing database or RELOAD
to create a new database that is a subset of the original.
UNLOAD
writes a copy of the database to an unload binary file including the schema 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 UPLOAD
ed 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 that check on the contents of the system.
VERIFY
checks on the contents of the structure of the database and gives details of any problems discovered. This utility has a PATCH
option that recovers from many types of corruptions. If some type of problem has occurred, a SIR/XS 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 either the journal file or 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.
The journal can be used to recover in the case of an unexpected interruption in an update run and allows updates to be re-applied quickly and easily if a backup has to be restored. The journal can be used in VisualPQL to produce reports on updates or other audit trails.
If updates were incomplete or unsuccessful in some way, they can be 'undone' with a JOURNAL ROLLBACK
that takes a database back to a previous update level.
When a database is connected, its status is checked to see if it was not closed properly when being updated e.g. the system 'crashed' while the database was open for update. If this is found to be the case, you are asked if you wish to recover automatically. If you choose to try to recover, a journal rollback is done.
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
. This is the recommended format for storing all long term SIR archives. It is machine and operating system independent and subsequent versions of SIR are always compatible with previous EXPORT formats.
WRITE SCHEMA
UPLOAD
and read by DOWNLOAD
EXPORT
utility. This file is a text copy of a database consisting of commands to recreate the database and data to load into it.This can be done in a number of ways:
Database\Recover\Import
menu
IN =
parameter
Procedures - File
menu
There is a command "IMPORT
" that 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 FILENAME = fileid [BOOLEAN = (logical_expr)] [COUNT = total [,increment [,start]]] [LIST = caseid, ...] [RECTYPES = ALL | rectype(logical_expr) ...] [SAMPLE = fraction [,seed]] [DATABASE = new database name] [PASSWORD = new database password] [COMMON] [CSV] [ENCRYPT] [NODATA] [NOINDEX] [NOMAXKEY] [NOPASSWORDS] [NOPROCS] [NOTO] [NOTXS] [VARLIST] [VARSEQ]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
.
Database administrator security is required to use 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.
Optionally separate multiple parameters on the command with slashes.
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.Specify a logical expression to select records. Records that meet the criteria of the logical expression are selected. For example:
RECTYPES = EMPLOYEE (SALARY GT 2000)
SAMPLE
SAMPLE = .25
exports 25% of the cases from the database using a default seed.
COUNT
DATABASE
PASSWORD
COMMON
COMMON
if commands are to be produced for each common variable on every record where it occurs.
CSV
ENCRYPT
NODATA
NOINDEX
NOMAXKEY
NOPASSWORDS
NOPROCS
NOTO
TO
. e.g.MISSING VALUES NAME TO NDEPENDS (BLANK)The
NOTO
keyword suppresses this shorthand and all variables are individually listed within the specification.
NOTXS
STANDARD VARS
and RECORD SCHEMA 0
are not written and slashes are generated as separators.
VARLIST
DATA LIST
. VARLIST
specifies that variable names are written as a VARIABLE LIST
command followed by input definitions as an INPUT FORMAT
command. e.g.VARIABLE LIST ID NAME GENDER MARSTAT ... INPUT FORMAT (I4,T6,A25,I1,I1,...
VARSEQ
VARSEQ
keyword specifies that the output is in variable sequence and that all commands that apply to a single variable are grouped together. e.g.VAR LABEL NAME 'Name' MISSING VALUES NAME (BLANK) VAR LABEL GENDER 'Gender' VAR RANGES GENDER (1 2) MISSING VALUES GENDER (BLANK) VALUE LABELS GENDER (1)'Male' (2)'Female' VAR LABEL MARSTAT 'Marital status' VAR RANGES MARSTAT (1 2) MISSING VALUES MARSTAT (BLANK) VALUE LABELS MARSTAT (1)'Married' (2)'Not married'
Examples:
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= 1000The 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.).
Export writes a summary of the data records exported. This lists the number of cases, each record type exported and the number exported.
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 subset of a database. The subset file is a binary file in identical format to an unload. 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 the copies that are 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
SAMPLE
COUNT
or LIST
.
COUNT
SAMPLE
or LIST
DATABASE
SIR SUBSET FILENAME = 'SUBSET.UNL' DATABASE = TESTDBMS
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.
Use the 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)
At this point, previous unload files and journal files can be renamed or deleted.
The options and keywords are:
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. Journaling then starts on a new file.
NEWDB
NEWPW
UNLOAD FILE FILENAME = 'COMPANY.UNL' NEWDB = TESTDBMS NEWPW = TESTPASS
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 journaled 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
If this is specified, a report is produced showing each update level that is written to the upload file. For example:
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 [FILENAME= fileid]Reports on the contents of a unload and journal files. An unload file may contain multiple unloads taken at different update levels. A journal file typically has journals from multiple update levels. This information is necessary when restoring a database or applying journals.
The options on the command are:
FILENAME
The report produced is similar to the following:
Itemize File 'C:\sir2004\alpha\COMPANY.sr5' is a JOURNAL file for database COMPANY Update level: 1 - 2 Dec 08, 2005/10:46:13 Journal data to Dec 08, 2005/10:47:07 Update level: 2 - 3 Dec 08, 2005/10:48:07 Journal data to Dec 08, 2005/10:49:03 Itemize File 'C:\sir2004\alpha\COMPANY.unl' is an UNLOAD file for database COMPANY Update level: 2 Dec 02, 2005/13:08:17 Unload schema Record: 1 Update level: 2 Dec 02, 2005/13:08:17 Unload data Record: 2 Update level: 3 Dec 08, 2005/10:49:03 Unload schema Record: 3 Update level: 3 Dec 08, 2005/10:49:03 Unload data Record: 4The information reported is the name of the file, the type of file and the database that the file refers to. This is then followed by a list of the records on the file. Each entry has the following information:
LIST STATSProvides a status report about the database similar to the following:
Statistics for COMPANY Database name COMPANY Creation Date/Time Dec 06, 2005 10:46:12 Last update Date/Time Dec 08, 2005 10:49:03 Update level 3 Average Records per Case 1023 Max/Current Number of Cases 1000/20 Max/Current Number of Records 1023000/114 Max/Current Number of Record Types 30/3 Maximum Input Columns/Lines 80/1 Rectype Column 5 Journal For Database ON Case Id Variable ID (A) Number of Index Levels 2 Max Entries Per Index Block 509 Index/Data Block Size 1019/1019 Active/Inactive Data Blocks 2/0 Active/Inactive Index Blocks 2/0 Keysize In Bytes 8 Min/Max Record Size 1/8 Number of Temporary Variables 0 Maximum Number of Data Variables 10 Record Record Number of Maximum Total In Size In Entry Use No. Name Variables Per Case Database Words Count ---- -------------------------------- --------- -------- -------- ------- --------- 0 CIR 1 1 20 5 1 1 EMPLOYEE 10 1 20 8 1 2 OCCUP 4 100 30 1 1 3 REVIEW 5 100 64 2 1 Secondary Indexes Index Name Record Variables -------------------------------- -------------------------------- -------------------------------- NAME EMPLOYEE NAME ASC BIRTHDAY EMPLOYEE BIRTHDAY ASC EDUC EMPLOYEE EDUC ASC GENDER ASC EDUCID EMPLOYEE EDUC ASC GENDER ASC ID ASCThe information includes:
A) Overall Database Information
B) Information about each Record Type
C) Restructure Information (if any)
D) Secondary index information (if any)
JOURNAL RESTORE [FILENAME = fileid] [FROM = n] [THRU = n] | [COUNT = n] [NEXT]Applies journal files to a database to update it to a more current level. Any schema changes are applied as well as updates to the data. The process expects that the database has been recovered from a backup and, by default, looks for journal records that correspond to updates starting at the current update level on the database. It then applies all journals forward from that point to arrive at the most up to date database possible from that journal.
Update level information may be obtained by LIST STATS
and ITEMIZE FILE
. The update level listed for journals is the level the database was at after the update was originally done. So, for example, if the restored database is at level 40, the first journal to be applied would be update level 41.
JOURNAL RESTORE
can restore partial journal records from abrupt interruptions of journaled update sessions. 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. However if a logical set of updates were being done and were interrupted, data may be in an inconsistent state between records. It is recommended that a VERIFY FILE
is done after a journal has been restored.
The options on the command are:
FILENAME
JOURNAL RESTORE FILENAME = 'COMPANY.JNL'
FROM
NEXT
THRU
UPDATE
is a synonym. For example:
JOURNAL RESTORE FILENAME = 'COMPANY.JNL' THRU = 42
COUNT
JOURNAL RESTORE FILENAME = 'COMPANY.JNL' COUNT = 10
JOURNAL ROLLBACK [FILENAME = fileid] [UPDATE = n] [COUNT = n]Applies journal files to a database to undo updates and roll it back to a previous level. Only applies to data updates.
If a database update run is interrupted, this might be used to roll back to a known update level before re-running the update process
JOURNAL ROLLBACK
can restore partial journal records from abrupt interruptions of journaled update sessions. It is recommended that a VERIFY FILE
is done after a journal has been rolled back.
The options on the command are:
FILENAME
JOURNAL ROLLBACK FILENAME = 'COMPANY.JNL'
UPDATE
LIST STATS
and ITEMIZE FILE
.
COUNT
VERIFY FILE [ALL] [CIRKEY] [CIRDATA] [CHECK] [CCF] [RECKEY] [RECDATA] [RCF] [COUNT= total,increment,start] [PATCH] [STATUS= global_name]
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.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 that 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.
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.
STATUS
***ERROR - couldn't read index PRU - unable to read an index block from disk.
***ERROR - Zero index PRU - should have a block number but have zero.
***ERROR - couldn't read data PRU - unable to read a data block from disk.
***ERROR - Zero data PRU - should have a block number but have zero.
***ERROR - index key mismatch - as the various index levels were processed, a mismatch on the key was found.
***ERROR - data key mismatch - at the bottom level the data block pointed to by the index did not match on key
***ERROR - index count mismatch - as the various index levels were processed, a mismatch on the counts was found
***ERROR - data count mismatch - at the bottom level the data block pointed to by the index did not match on counts
If one of these errors occurs, supplementary information is printed including:
LEVEL - The index level being processed
PRU - The block being referenced
ENTRIES - The number of entries
COUNT - The count of entries
CURRENT ENTRY - The entry being processed
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
For example
DOWNLOAD FILENAME = 'JOURNAL.UPL' MESSAGES = ON
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) that 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 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, COMPUTE, RECODE, ACCEPT REC IF
and REJECT REC IF
statements.
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 SIR SAVE FILE
to create a case structured database from a caseless database.)
The options on this command are:
FILENAME
DATABASE
PASSWORD
SECURITY
SIR MERGE FILENAME = 'COMPANY.UNL' DATABASE = COMPANY PASSWORD = COMPANY SECURITY = HIGH
RECTYPES
ALL
source
RENAME
clause is used, specify the new name of
the variable in this clause.
BOOLEAN
TRUE
the case is merged.
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
By default, both new records are added to the database and existing records are replaced.
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 that is a copy of a database.
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
UNLOAD
.
Optionally separate multiple parameters on the command with slashes.
FILENAME
UNLOAD
ed 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
Example:
RELOAD FILE MYDBMS FILENAME = 'COMPANY.UNL' UPDATE = 52