%SYS
Restore Class Reference

Example 1 (Restore everything in selected journal files of current InterSystems IRIS instance): s RestOref=##class(Journal.Restore). More...

Inheritance diagram for Restore:
Collaboration diagram for Restore:

Public Member Functions

_.Library.Status CheckJournalIntegrity (_.Library.Integer Scan)
 To check the selected journal files for problems (missing files, corruptions, etc.)
More...
 
_.Library.Status RedirectDatabase (_.Library.String SourceDatabase, _.Library.String TargetDatabase)
 Set up journal restore to apply updates of SourceDatabase to TargetDatabase. More...
 
_.Library.Status Run ()
 To run journal restore.
 
_.Library.Status SelectUpdates (_.Library.String SourceDatabase, _.Library.String GlobalName)
 To select a database or a global in a database to restore
More...
 
_.Library.Status UseJournalLocation (_.Library.SysPath JournalDirectory)
 Set up <property>JournalLocation</property>
 

Public Attributes

 AbortOnDatabaseError
 Whether to abort journal restore if an update would have to be skipped due to a database-related problem (e.g., a target database cannot be mounted, error applying an update, etc.). More...
 
 AbortOnJournalError
 whether to abort journal restore if an update would have to be skipped due to a More...
 
 DisableJournaling
 Whether to disable journaling of the applied updates (for performance purpose) More...
 
 Dismount
 To dismount databases whose updates were skipped due to errors. More...
 
 Filter
 Specify a filter routine such as "^ZJRNFILT" to apply to every selected updates during journal restore. More...
 
 FirstFile
 The first journal file to process. More...
 
 JournalLocation
 A list of directories where the selected journal files are located
More...
 
 JournalLog
 Path of a journal history log where the selected journal files are listed
More...
 
 LastFile
 The last journal file to process
More...
 
 MarkerTrigger
 Specify a routine (or tag) such as "MARKER^ZJRNFILT" to be invoked on journal markers during journal restore. More...
 
 RollBack
 To roll back incomplete transactions at the end of journal restore. More...
 
 SourceDatabases
 A list of database directories stored in the selected journal files. More...
 
 StartPosition
 The position of the first journal file to begin processing at. More...
 
 SwitchOnCurrentJournal
 If current journal file is among the journal files selected to be processed,. More...
 

Static Public Attributes

 TYPE = None
 This corresponds to the fromrest parameter in journal restore utility. More...
 

Private Attributes

 __DatabaseRedirection
 An array of SourceDatabase -> TargetDatabase for database redirection
More...
 
 __SelectedFiles
 A list of selected journal files in their current location. More...
 
 __SelectedUpdates
 A table of (SourceDatabase,GlobalName) selected to be restored
More...
 
 __StartTime
   More...
 
 __zsvalsav
 Original value of $ZSTORAGE to be restored upon close. More...
 

Detailed Description

Example 1 (Restore everything in selected journal files of current InterSystems IRIS instance):

s RestOref=##class(Journal.Restore).

New() s RestOref.FirstFile="20100107.001" s RestOref.LastFile="20100107.002" s Status=RestOref.Run()

Example 2 (Restore selected globals in selected databases from foreign journal files):

s RestOref=##class(Journal.Restore).New() s RestOref.FirstFile="/another_system/20100107.001" ;copied from another InterSystems IRIS instance s RestOref.LastFile="/another_system/20100107.002" ;copied from another InterSystems IRIS instance s RestOref.JournalLog="/another_system/journal.log" ;copied from another InterSystems IRIS instance d RestOref.UseJournalLocation("/another_system") ;and so on (where to locate journal files) s Status=RestOref.CheckJournalIntegrity(1) ;to populate property 'SourceDatabases' with database paths collected from the journal files to be restored s key="" for { s SourceDatabase=RestOref.SourceDatabases.GetNext(.key) q:key="" w !,SourceDatabase," => " r TargetDatabase s Status=RestOref.RedirectDatabase(SourceDatabase,TargetDatabase) s Status=RestOref.SelectUpdates(SourceDatabase,GlobalName1) s Status=RestOref.SelectUpdates(SourceDatabase,GlobalName2) ;and so on } s Status=RestOref.Run()

Member Function Documentation

◆ CheckJournalIntegrity()

_.Library.Status CheckJournalIntegrity ( _.Library.Integer  Scan)

To check the selected journal files for problems (missing files, corruptions, etc.)

Scan

  • 0: look for missing files and inconsistent journal end offsets;
  • 1: also collect a list of database directories in the selected journal files and store them in <property>SourceDatabases</property>;
  • 2: also perform a more thorough (and more time-consuming) check by going through every record in the selected journal files, which could detect corruptions in the middle of a journal file that would otherwise go unnoticed until the read restore.

◆ RedirectDatabase()

_.Library.Status RedirectDatabase ( _.Library.String  SourceDatabase,
_.Library.String  TargetDatabase 
)

Set up journal restore to apply updates of SourceDatabase to TargetDatabase.

instead of SourceDatabase itself.
Note that for database redirection to take effect, you must also call SelectUpdates() for each database to be restored, even if you intend to have all databases restored.
This method can be called before or after the SelectUpdates() calls.
See <method>SelectUpdates</method> on how to ensure the SourceDatabase argument is in a proper form.

◆ SelectUpdates()

_.Library.Status SelectUpdates ( _.Library.String  SourceDatabase,
_.Library.String  GlobalName 
)

To select a database or a global in a database to restore

If GlobalName is not specified, all globals in SourceDatabase will be restored, unless you also call SelectUpdates(SourceDatabase,GlobalName) (before or after the call without GlobalName), in which case only the specified global(s) are restored.
GlobalName must begin with an alpha, "%", "*" or "?", followed by alphanumerics and "*?."s ("." for dot syntax).
You must make sure the 'SourceDatabase' argument is in the canonical form acceptable to journal restore. One way to ensure that is illustrated in Example 2 at the beginning of the class document, that is, by calling <method>CheckJournalIntegrity</method> with 1 to have <property>SourceDatabases</property> populated with database paths collected from the journal files to be restored.

Member Data Documentation

◆ TYPE

TYPE = None
static

This corresponds to the fromrest parameter in journal restore utility.


fromrest is set by the caller of journal restore utility to indicate the type of journal restore (or the type of the caller). For example, ^JCONVERT sets fromrest=8 to instructs journal restore to write out the updates to a file instead of applying them to databases. Some types of restore have their own parameters (e.g., the path of an output file for fromrest=8), so a subclass for each type seems logical.
^JRNRESTO sets fromrest=0, which is the default here.

◆ AbortOnDatabaseError

AbortOnDatabaseError

Whether to abort journal restore if an update would have to be skipped due to a database-related problem (e.g., a target database cannot be mounted, error applying an update, etc.).


If journal restore is aborted, databases will be left in a self-consistent state as of the record that caused the restore to be aborted. Parallel dejournaling will be disabled with this setting; otherwise, affected database(s) may not be self-consistent and will need to be recovered separately.

 

◆ AbortOnJournalError

AbortOnJournalError

whether to abort journal restore if an update would have to be skipped due to a

journal-related problem (e.g., journal corruption, missing journal files, etc.)  

◆ __DatabaseRedirection

__DatabaseRedirection
private

An array of SourceDatabase -> TargetDatabase for database redirection

If none specified, apply updates to the original databases

s JrnRestOref=##class(Journal.Restore).New() s Status=JrnRestOref.RedirectDatabase(SourceDatabase,TargetDatabase)

 

◆ DisableJournaling

DisableJournaling

Whether to disable journaling of the applied updates (for performance purpose)

 

◆ Dismount

Dismount

To dismount databases whose updates were skipped due to errors.

 

◆ Filter

Filter

Specify a filter routine such as "^ZJRNFILT" to apply to every selected updates during journal restore.

 

◆ FirstFile

FirstFile

The first journal file to process.

 

◆ JournalLocation

JournalLocation

A list of directories where the selected journal files are located

Required if <property>JournalLog</property> has a non-default value.  

◆ JournalLog

JournalLog

Path of a journal history log where the selected journal files are listed

Default: the journal history log of local InterSystems IRIS instance.
Set JournalLog=-1 to override the default without specifying a journal log.  

◆ LastFile

LastFile

The last journal file to process

Default: the last journal file listed in the journal history log given by <property>JournalLog</property>  

◆ MarkerTrigger

MarkerTrigger

Specify a routine (or tag) such as "MARKER^ZJRNFILT" to be invoked on journal markers during journal restore.

 

◆ RollBack

RollBack

To roll back incomplete transactions at the end of journal restore.

 

◆ __SelectedFiles

__SelectedFiles
private

A list of selected journal files in their current location.

 

◆ __SelectedUpdates

__SelectedUpdates
private

A table of (SourceDatabase,GlobalName) selected to be restored

If none specified, restore everything from the selected journal files

s JrnRestOref=##class(Journal.Restore).New() s Status=JrnRestOref.SelectUpdates(SourceDatabase,GlobalName)

 

◆ SourceDatabases

SourceDatabases

A list of database directories stored in the selected journal files.

for verifying the source database directories given in the <property>DatabaseRedirection</property> property if specified  

◆ StartPosition

StartPosition

The position of the first journal file to begin processing at.

 

◆ __StartTime

__StartTime
private

 

 

◆ SwitchOnCurrentJournal

SwitchOnCurrentJournal

If current journal file is among the journal files selected to be processed,.

the user has an option to switch journal file or stop journaling system wide.
This is necessary if <property>DisableJournaling</property> is NO, as otherwise the applied updates will be journaled in the file that will be dejournaled, resulting in data integrity issues.
Even if <property>DisableJournaling</property> is YES, it is still a good practice to switch journal file so that new updates will go into the new file.  

◆ __zsvalsav

__zsvalsav
private

Original value of $ZSTORAGE to be restored upon close.