Caché Data Integrity Guide
Backup and Restore
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

This chapter outlines the factors to consider when developing a solid plan for backing up your Caché system. It discusses techniques for ensuring the integrity and recoverability of your backups, as well as suggested backup strategies. In addition, the chapter contains details about the procedures used to perform these tasks using Caché utilities or other third-party utilities. It discusses the following topics:

Backup strategies can differ depending upon your operating system, preferred backup utilities, disk configurations, and backup devices. If you require more information to help you to develop a backup strategy tailored for your environment, or to review your current backup practices, contact the InterSystems Worldwide Response Center (WRC).
Backup Integrity and Recoverability
Regardless of the backup strategies you use, it is critical to restore backups on a regular basis to validate your procedures. The best practice — to restore every backup of the production environment to an alternate server and then validate the integrity of the restored databases (see Verify Database Integrity in the “Managing Caché” chapter of the Caché System Administration Guide for more information) — provides the following advantages:
The backup strategies described in this document preserve the physical structure of the database; therefore, a clean integrity check of the restored copy implies that the integrity of the production database was sound at the time of the backup. The converse, however, is not true: an integrity error detected on the restored copy of a database does not necessarily imply that there are integrity problems on the production database; there could, for example, be errors in the backup media. If you discover an integrity error in the restored database, immediately run an integrity check on the production database to verify the integrity of the production system.
To further validate that the application is working correctly on the restored database, you can also perform application-level checks. To perform these checks, you may need to restore journal files to restore transactional integrity. See the Importance of Journals section for more information.
Once you restore the backup and establish that it is a viable source of recovery, it is best to preserve that restored copy until you establish the next good backup. Therefore, the server on which you are validating the backup should ideally have twice the storage space required by production—space to store the last-known good backup as well as the backup you are currently validating. (Depending on your needs, you may have less stringent performance requirements of the storage device used for restoring backups, allowing for a less expensive storage solution.) In this way, the last-known good backup is always available for use in a disaster even if validation of the current backup fails. To protect enterprise databases from a disaster that could destroy the data center, regularly ship backup media to a secure off-site location.
Importance of Journals
The backup of a Caché database alone is not enough to provide a viable restore of production data. In the event of a failure that requires restoring from backup, you must also apply journal files to the restored copy of the database. Applying journal files restores all journaled updates from the time of the backup to the time of the failure. Also, applying journals is necessary to restore the transactional integrity of your database by rolling back uncommitted transactions.
Be sure to see Journaling Best Practices in the “Journaling” chapter of this guide for important information about ensuring journal availability for recovery. In particular, as explained in that section, in the interests of performance and recoverability, InterSystems recommends placing the primary and alternate journal directories on storage devices that are separate from the devices used by databases and the write image journal (WIJ), as well as separate from each other.
Important:
It is critical to periodically test your entire disaster recovery procedure from start to finish. This includes backup restore, journal restore, and running simulated user activity on the restored environment.
Backup Strategies
The best strategies for backing up Caché data are external backup and Caché online backup. This section describes these and other special-purpose strategies:
External Backup
External backup is currently the recommended best practice for backing up Caché. It integrates easily with your existing system backup procedures and typically allows for a zero downtime backup. It is used primarily in conjunction with technology that provides the ability to quickly create a functional “snapshot” of a logical disk volume. Such technologies exist at various levels, from storage arrays, to operating systems, to simple disk mirroring. There are special considerations, discussed in this section, for systems on which snapshot technology is not available.
To ensure the integrity of the snapshot, Caché provides methods to freeze writes to databases while the snapshot is created. Only physical writes to the database files are frozen during the creation of the snapshot, allowing user processes to continue performing updates in memory uninterrupted. The snapshot is typically a snapshot of all file systems in use by the system. At a minimum, this includes all directories used by Caché in any way, such as the installation directory, database directories, journal and alternate journal directories, WIJ directory, and any directory containing external files used by Caché. After writes are thawed, the snapshot may be backed up to tape and then either rejoined to production or left online as a warm backup (depending on the specific technology used).
Note:
To avoid the problem of false reporting of errors when running integrity checks on databases while they are in use, you can integrate the integrity checks into procedures like those described in this section, so that databases are checked immediately after the file system snapshot is taken. (See Verify Database Integrity in the Managing Caché chapter of the Caché System Administration Guide for information about checking database integrity.)
There are two exceptions where users could experience an interruption of service:
The following table lists the advantages and disadvantages of the external backup strategy:
Advantages Disadvantages
Allows zero downtime backups with no user interruption for most systems.
Users are interrupted on Caché OpenVMS clusters.
Integrates easily with existing backup procedures.
 
The class methods that perform the database freeze and thaw operations are Backup.General.ExternalFreeze() and Backup.General.ExternalThaw(), respectively. In addition to pausing writes, the freeze method also handles switching journal files and writing a backup marker to the journal. The journal file continues to be written normally while physical database writes are frozen. If the system were to crash while the physical database writes are frozen, data would be recovered from the journal as normal during startup.
To summarize, the external backup involves the following steps:
  1. Freeze writes to the database using the Backup.General.ExternalFreeze() method. Examples of the use of this method on various platforms are included in the class documentation.
    Note:
    When the security configuration requires that the backup script supply Caché credentials, you can do this by redirecting input from a file containing the needed credentials. Alternatively, you can enable OS-level authentication and create a Caché account for the OS user running the script.
  2. Create a snapshot of the file system using an external snapshot utility.
  3. Resume Caché writes using the Backup.General.ExternalThaw() method. Here is a sample thaw.bat:
    rem Unfreeze the system
    CD C:\InterSystems\E20131\mgr\
    ..\bin\cache -s. -B -V -U%SYS ##Class(Backup.General).ExternalThaw()
    
  4. Copy the snapshot to the backup media.
See the Backup.General class documentation in the InterSystems Class Reference for platform-specific examples of these methods.
For systems where snapshot technology is not available, a slower filesystem copy may be used in the external backup approach, described above, by replacing the creation of the snapshot with a filesystem copy. This can be done in one of the following ways or, depending on your needs, Caché Online Backup may be an alternative:
Important:
When the instance being backed up is the primary failover member in a mirror (see the chapter Mirroring in the Caché High Availability Guide), an external freeze must not suspend updates for longer than the specified ExternalFreezeTimeOut parameter of Backup.General.ExternalFreeze(). If this happens, the mirror may fail over to the backup failover member, thereby terminating the backup operation in progress.
Caché Online Backup
Caché implements a proprietary backup mechanism designed to cause very minimal or no downtime to users of the production system. Caché online backup, which only backs up data in CACHE.DAT files, captures all blocks in the databases that are allocated for data. The output goes to a sequential file. This must be coordinated with a system backup to copy the Caché online backup output file to the backup media along with other files. Typically the system backup should include all filesystems in use by the system, excluding CACHE.DAT files. At a minimum it must include the installation directory, journal and alternate journal directories, CSP files, and any directory containing external files used by Caché; exclude CACHE.DAT files.
The Caché online backup procedure uses multiple passes to copy data, where each consecutive pass copies an incrementally reduced list of data blocks that changed during the previous pass. Generally, three passes are sufficient to complete a backup. During the entire final pass and for a brief moment during each prior pass, the process pauses writes to the database. The backup pauses physical writes to the database while allowing user processes to continue performing updates in memory. If the backup is running in an OpenVMS clustered Caché environment, it also pauses user processes for these multiple brief periods.
The following table lists the advantages and disadvantages of the online backup strategy:
Advantages Disadvantages
Allows zero downtime backups for most systems. With old-format databases or in OpenVMS cluster configurations, there is minimal user interruption.
Backs up only databases; it does not back up external files.
Supports cumulative and incremental backups on a regular basis.
Restoring a single database requires processing the entire backup file.
Does not require enterprise-class storage.
Requires a running instance of Caché to perform a restore.
 
Restores can be cumbersome with extremely large amounts of data.
 
Backups of encrypted databases are unencrypted.
There are different types of online backup, which you can combine to manage the trade-offs between the size of the backup output and the time needed to recover from the backup:
When using online backup, you must first run a full backup, after which you can run cumulative and/or incremental backups.
Online backup writes all database blocks to a single file (or set of tapes) in an interleaved fashion. When you back up an extremely large amount of data using the online backup, restores can become somewhat cumbersome; consider this when planning your backup strategy.
The restore validation process helps resolve any limitations by providing an online, restored copy of the databases. Use the same backup validation strategy when running incremental or cumulative backups. After you perform each incremental or cumulative backup, you can immediately restore to the alternate server. For example, a strategy of weekly full backups and daily incremental backups can work well because each daily backup contains only the blocks modified that day. Using this strategy, you should restore the incremental backup to the alternate server each day, and check the integrity of the restored databases.
Avoid overwriting the warm copy of the last known good backup when restoring the backup you are currently validating. The same concept applies when restoring an incremental to the existing restored database. After you establish that the backup is the last known good backup and before applying the next day’s incremental or cumulative backup to it, save a copy so that the last known good backup is always online and ready for use in case the subsequent incremental restore fails. If a restored backup fails an integrity check, you must discard it; you cannot use it as a target of a subsequent incremental restore.
When restoring a system from an online backup, first restore the most recent full backup, followed by the most recent cumulative backup, and then all incremental backups taken since the cumulative backup.
For information about configuring Caché online backup, see Configuring Caché Online Backup Settings in this chapter; for information about managing Caché online backup, see Managing Caché Online Backups in this chapter.
Cold Backup
Cold backup refers to an external backup of the system taken when Caché has been shut down normally. The backup is typically a backup of all filesystems in use by the system. At a minimum, all directories used by Caché in any way, including the installation directory, database directories, journal and alternate journal directories, WIJ directory, and any directory containing external files used by Caché. This strategy may be appropriate for systems where Caché is typically shut down at night.
The following table lists the advantages and disadvantages of the cold backup strategy:
Advantages Disadvantages
Simple procedure (stop Caché and copy entire instance).
Caché is not available.
Occasionally, it is useful to back up the system while Caché is shut down.
 
Legacy Concurrent External Backup
The Legacy Concurrent External Backup strategy is also known as “dirty backup.” It was designed before Caché had the capability of performing a zero downtime backup that is available in both External Backup and Caché Online Backup; the design allowed for an external backup to be taken with only a minimum amount of downtime. Today, this backup strategy is practical only in very special cases, typically only if all of the following conditions exist:
The Legacy Concurrent External Backup strategy works by allowing an external system backup to run while normal databases writes are taking place. The copy of the databases captured in this manner are expected to be corrupt (“dirty”). This copy is then followed by an Incremental Caché Online Backup, which captures any database blocks that were modified while the dirty copy took place. When restoring the backup, first the copy of the databases are restored, then the incremental backup is restored. The steps in detail are as follows:
  1. Clear the list of database blocks modified since the last backup:
     Do CLRINC^DBACK("QUIET")
    For information, see CLRINC^DBACK in this chapter.
  2. Copy the CACHE.DAT database files, using your chosen operating system or third-party backup utility.
  3. Call $$BACKUP^DBACK with the E parameter to indicate you used an external backup utility; for example:
     Set x=$$BACKUP^DBACK("","E","Dirty external backup - incrementals must be applied.","","","")
    For information, see BACKUP^DBACK in this chapter.
  4. Perform a Caché incremental backup, which copies any blocks that changed while the CACHE.DAT files were being copied; this may cause a very brief suspension of user processes in some configurations:
     Set x=$$BACKUP^DBACK("","I","Nightly","test.bck","N","bck.log","QUIET","N","Y")
    
    For information, see BACKUP^DBACK in this chapter.
The following table lists the advantages and disadvantages of the legacy concurrent external backup strategy:
Advantages Disadvantages
Provides a backup strategy with little or no interruption for sites that are not able to use one of the other recommended approaches.
Multiple files need to be restored (CACHE.DAT database files and incremental backup files), which causes the restore process to take longer.
 
The procedure is complex.
 
Requires a running instance of Caché to perform a restore.
OpenVMS Legacy Concurrent External Backup Example
InterSystems supplies a command procedure, CBACKUP.COM, on OpenVMS platforms, which provides a model of how to use entry points in the Caché backup routines to perform a backup while Caché is running. This command procedure gives you examples of various combinations of OpenVMS and Caché backups. CBACKUP.COM carries out the following actions:
  1. Performs the OpenVMS backup.
  2. Records the date, time, and a brief description of the OpenVMS full backup in the Caché backup history global and uses this information later when you request a restore.
  3. Runs a Caché incremental backup.
InterSystems recommends that you examine this procedure in detail, modify it as necessary, and use it if you wish to use OpenVMS BACKUP or any entry points and functions of the Caché backup procedures.
Note:
InterSystems recommends that you always use the /REPAIR parameter when restoring a saveset file with OpenVMS BACKUP. This ensures that record attributes are always set correctly, regardless of the condition of the saveset file.
Restoring from a Backup
It is critical to restore backups on a regular basis to test your procedures. As described in the Backup Integrity and Recoverability section in this chapter, InterSystems recommends restoring every backup onto an alternate server for validation and to serve as a warm copy of the restore.
Backup restores can be complex and time consuming, and the practice of regular restores helps mitigate the risks involved. Backup restore should be considered as part of your larger disaster recovery plan. Caché Shadowing and Mirroring also provide alternate mechanisms for disaster recovery.
For additional help with backup restore scenarios, contact the InterSystems Worldwide Response Center (WRC).
This section includes the following topics:
Backup Restore Scenarios
There are many scenarios where a backup restore is performed, often with unique sets of requirements and restore procedures. This section describes the following general restore scenarios, including variations for different backup strategies:
Important:
To avoid data incompatibility, the following requirements must be met when restoring or migrating a database to a different Caché instance than the one in which the backup was created:
Full System Restore
This scenario assumes the following starting point:
Full System Restore from External Backup or Cold Backup
If you used External Backup or Cold Backup, your databases are already restored to a physically consistent state but require journal restore to recover newer updates and transactional consistency. The procedure is:
  1. Start Caché in maintenance mode as described in the Starting Caché for Maintenance section in this chapter, to perform a journal restore before users are allowed to access the system.
    Important:
    This procedure assumes that the CACHE.WIJ file was backed up as part of the backup snapshot and restored along with the databases and other files/file systems, which is the recommended way to plan your backup/backup restore procedures. However, if this was not the case, see the Starting Caché Without Automatic WIJ and Journal Recovery section for information about how to start Caché.
  2. Restore the journals as described in the Journal Restore Following Backup Restore section in this chapter.
  3. After the journal restore is complete, you can perform application validation or additional maintenance.
  4. Restart Caché normally to allow users to access the system.
Full System Restore from Caché Online Backup or Legacy Concurrent External Backup
The remainder of this section discusses the full system restore for users of Caché Online Backup or Legacy Concurrent External Backup. You must perform a Caché online backup restore to restore the databases from the backup output file. For Caché online backup, the backup output file is written to the backup media as part of the full system backup, as described in the Caché Online Backup section in this chapter.
Caché online backup restore can only be performed on a running instance of Caché. Therefore, in this full system restore scenario, you must have a separate, secondary instance of Caché installed to run the restore of the primary instance’s databases. The databases being restored do not need database or namespace definitions in the secondary instance.
The secondary instance can be installed as part of this restore procedure by running the Caché installer and selecting an instance name and installation directory that is different from the primary instance. Alternatively, to avoid this step at restore time install the secondary “restore” instance when you decide to use the Caché online backup strategy. This secondary instance should be shut down at all times and its installation directory backed up as part of the full system backup (that is, it would be a Cold Backup for the secondary instance). It could simply be started during a full system restore in order to run the Caché online backup restore of the primary instance.
To restore from a Caché online backup or legacy concurrent external backup after a full system restore:
  1. Using the secondary instance of Caché, follow the instructions in the Caché Online Backup Restore Utility section in this chapter to:
    1. Restore the last full backup (if using Legacy Concurrent External Backup, the full backup was already restored externally during the filesystem restore).
    2. If you have done cumulative backups since the full backup, restore the last one; otherwise, continue with the next step.
    3. Restore all incremental backups done since the last cumulative backup (if there is one), or the last full backup (if there is no cumulative), in the order in which the backups were run.
  2. Using the secondary instance of Caché, follow the instructions in the Journal Restore Following Backup Restore section in this chapter.
  3. Shut down the secondary instance of Caché.
  4. IMPORTANT: Start the primary instance as described in the Caché Without Automatic WIJ and Journal Recovery section in this chapter. This step leaves Caché running in maintenance mode, which lets you perform application validation or additional maintenance.
  5. Restart Caché normally to allow users to access the system.
Database-Only Restore
This scenario assumes the following starting point:
Note:
If you used External Backup or Cold Backup and you have many database that need to be restored, a simpler procedure may be to shut down Caché, restore ALL CACHE.DAT files, and perform the restore procedures described in the Full System Restore section in this chapter. This is especially true if the CACHESYS database must be restored.
To perform a database-only restore:
  1. If Caché is not started already, start it as described in the Starting Caché for Maintenance section in this chapter. Starting Caché ensures that any pending automatic recovery to existing databases occurs immediately and does not conflict with the databases that you are about to restore on subsequent startup.
    If Caché is already started and you are restoring databases that users may attempt to access during the restore process, InterSystems recommends that you shut down and restart as described in the Starting Caché for Maintenance.
    The following table describes recommended procedures to resolve the problems that prevent Caché from starting.
    Problem Solution
    1. Caché fails to start
    Starting Caché for maintenance allows Caché to start even if a database that is required for startup cannot be mounted. However, if there is automatic journal recovery pending for a database that is marked as required for startup, Caché does not skip it.
    Therefore, if damaged databases are still preventing Caché from starting:
    1. Rename the CACHE.DAT files to make the database completely inaccessible.
    2. Change the configuration to mark those databases as not required for startup,
    3. Try again to start Caché as described in the Starting Caché for Maintenance.
    2. If Caché cannot start due to a damaged CACHESYS database
    Temporarily replace the CACHESYS database with a copy from an External Backup, or from a new install of the same version of Caché. This is temporary solution to get Caché started to complete the restore procedure.
    3. Caché still does not start
    You may need to restore all databases following the procedure in Full System Restore.
    For additional help, contact the InterSystems Worldwide Response Center (WRC).
  2. Depending on the strategy you used to back up the database, restore each database as follows:
    Backup Strategy Used Database Restoration Sub-procedure
    External Backup or Cold Backup
    For all databases except CACHESYS:
    1. Dismount the database from Caché.
    2. Copy the CACHE.DAT files from the backup media to their original locations.
    3. Remount the database.
    If you are restoring the CACHESYS database, restore it to an alternate directory temporarily.
    Caché Online Backup
    Follow the instructions in the Caché Online Backup Restore Utility section in this chapter to:
    1. Restore the last full backup.
    2. If you have done cumulative backups since the full backup, restore the last one; otherwise, continue with the next step.
    3. Restore all incremental backups done since the last cumulative backup (if there is one), or the last full backup (if there is no cumulative), in the order in which the backups were run.
    Legacy Concurrent External Backup
    Perform the same steps as documented for External Backup (in this table) to restore the “dirty” copy of the CACHE.DAT files, then apply the incremental backup as documented for Caché Online Backup (in this table).
  3. Follow the instructions in the Journal Restore Following Backup Restore section in this chapter.
  4. If you started Caché as described in the Starting Caché for Maintenance section in this chapter, and you are ready to allow users on the system, stop and restart Caché normally. You can perform application validation or additional maintenance before restarting.
    Note:
    If you restored the CACHESYS database from External Backup or Cold Backup to a temporary alternate directory as described in the table in step 2 of this procedure, you must replace the existing CACHESYS database with the CACHE.DAT file from the temporary directory after shutting down (before restarting) Caché.
Restore/Migrate Database to Different Systems
This scenario assumes the following starting point:
The purpose of this type of restore includes, but is not limited to:
To restore/migrate databases to a different system:
Important:
Do not attempt to replace the CACHESYS database on the destination system with a restore of the CACHESYS database from the source unless it is part of a full system restore. Any data needed from the source CACHESYS database can be exported and then imported into the destination CACHESYS database.
If the source and target systems use a different endianness, see the Considering Endianness subsection following this procedure. If the source or target systems use database encryption, see the Considering Database Encryption subsection following this procedure.
  1. Start Caché if not started already. Starting Caché ensures that any pending automatic recovery to existing databases occurs immediately and does not conflict with the databases that you are about to restore.
    If you are restoring databases that users may attempt to access during the restore process, you should start as described in the as described in the Starting Caché for Maintenance section in this chapter.
  2. Depending on the strategy you used to back up the database, restore each database as follows:
    Backup Strategy Used Database Restoration Sub-procedure
    External Backup or Cold Backup
    To restore databases:
    1. Dismount any databases being restored if they are mounted on the target instance.
    2. Copy the CACHE.DAT files from the backup media to the desired locations.
    3. Add any new databases to the configuration.
    4. Remount the database that you dismounted.
    Caché Online Backup
    Follow the instructions in the Caché Online Backup Restore Utility section in this chapter to:
    1. Restore the last full backup.
    2. If you have done cumulative backups since the full backup, restore the last one; otherwise, continue with the next step.
    3. Restore all incremental backups done since the last cumulative backup (if there is one), or the last full backup (if there is no cumulative), in the order in which the backups were run.
    Legacy Concurrent External Backup
    Perform the same steps as documented for External Backup (in this table) to restore the “dirty” copy of the CACHE.DAT files, then apply the incremental backup as documented for Caché Online Backup (in this table).
  3. Follow the instructions in the Journal Restore Following Backup Restore section in this chapter.
    Note:
    If you are restoring from Caché Online Backup to add databases to a backup or async mirror member (see the Mirroring chapter in the Caché High Availability Guide) or synchronize with the shadowing destination (see the Shadowing chapter in this guide), skip this step; journals are applied automatically in these cases.
  4. If you started Caché as described in the Starting Caché for Maintenance section in this chapter, and you are ready to allow users on the system, stop and restart Caché normally.
Considering Endianness
Depending on the strategy you used to back up the database, an extra step is required to restore a backup on a target system whose Endianness (big-endian vs. little-endian) is different from the source system. For information about the Endianness of supported platforms, see “Platform Endianness” in the “Supported Technologies” section of InterSystems Supported Platforms.
Considering Database Encryption
When you restore a database on a target system, it may be necessary to change the database encryption key for the restored database. Depending on the strategy you used to back up the database, you may have to convert the key on the restored database, as follows:
Starting Caché for Maintenance
During any restore procedure it is critical that no application activity occurs in the databases being restored until you are completely finished with the backup restore and journal restore, and you have completed any desired application-level validation. If you have, in your application or operating environment, a mechanism to ensure that no user activity can occur when Caché is started you can use that mechanism; for example, if your application is entirely web-based, shutting down the web servers may be sufficient to ensure that only administrators involved in the restore procedure have access to the system.
Caché provides a mechanism to let you start Caché with limited access while maintenance is performed.
Caution:
The following procedure is modified from earlier versions to utilize enhancements to emergency access mode introduced with version 2011.1; if you are using an earlier version of Caché, see the version 2010.2 documentation.
To start Caché for maintenance:
  1. Start Caché in emergency access mode, specifying a unique username and password to be used for all maintenance activity; this username and password should not match any existing user:
    For more information, see the Emergency Access section of the “System Management and Security” chapter of the Caché Security Management Guide.
  2. Perform the remaining portions of the restore procedure as documented for your restore scenario.
  3. After completing the restore procedure — including any journal restore, application validation, or other maintenance activities — make the system available to users as follows:
    1. Shut down Caché.
    2. Start Caché without the EmergencyId switch.
Journal Restore Following Backup Restore
It is necessary to apply journal files following backup restore. As described in the Importance of Journals section of this chapter, you usually have journal files available at restore time that are newer than the backup. Applying these journal files restores all journaled updates from the time of the backup to the time of the disaster.
Additionally, applying journals is necessary to restore the transactional integrity of your restored database (which may have partial transactions) by rolling back uncommitted transactions. This is required even if you only have journal files up to the moment of the backup and not newer.
Important:
If you do not have journal files at least up to the moment of the backup, do not apply any journal files.
When you start the restore, you must select a start point for journal restore. The journal restore may then need to look backwards in the journal stream to find the beginning of a transaction that began prior to the backup. When you use Caché Online Backup, the backup stores a suggested start point; when you back up using the ^DBACK or ^BACKUP utilities, the utility displays information about the oldest journal file required for transaction rollback during restore at the beginning of the third and final pass.
For information about how to apply journals following the backup restore, see the Restore Journal Files section in the “Journaling” chapter of this guide.
Starting Caché Without Automatic WIJ and Journal Recovery
Some of the restore procedures described in this chapter require starting Caché in a way that prevents the automatic recovery of databases at startup from occurring. This is specified when all of the recovery is to be done manually in the restore procedure and the automatic startup recovery may be incompatible with the manual recovery effort.
Caution:
The restore procedures documented in this chapter explicitly state when the following procedure is necessary. Performing the procedure at any other time is extremely dangerous and could damage database integrity. In addition, it is modified from earlier versions to utilize enhancements to emergency access mode introduced with version 2011.1; if you are using an earlier version of Caché, see the documentation for that specific version.
To start Caché without automatic WIJ and Journal Recovery:
  1. Remove but do not delete the CACHE.WIJ file, so that it remains available for analysis, as follows:
    1. Check the startup.last file in the manager directory for the line wijlast=.
    2. Move or rename the CACHE.WIJ file in the directory specified in that line. If a null directory is specified, the CACHE.WIJ file is located in the manager directory.
  2. Start Caché in emergency access mode, specifying a unique username and password to be used for all maintenance activity; this username and password should not match any existing user:
    For more information, see the Emergency Access section in the “System Management and Security” chapter of the Caché Security Management Guide.
  3. In most cases, Caché does not start completely due to the missing journal recovery information in the WIJ. If Caché starts normally, skip the remainder of this procedure.
  4. Follow the instructions in the cconsole.log to enter Caché with the -B option and run do ^STURECOV:
    1. Select option 8 to reset Caché to start without journal recovery.
    2. Select option 9 to shut down Caché (using the displayed instructions).
  5. Start Caché in emergency access mode again, as described in step 2.
  6. Perform the remaining portions of the restore procedure as documented for your restore scenario.
  7. After completing the restore procedure — including any journal restore, application validation, or other maintenance activities — you can make the system available to users as follows:
    1. Shut down Caché.
    2. Start Caché without the EmergencyId (/EmergencyId on Windows platforms) switch.
Configuring Caché Online Backup Settings
Caché online backup is one of the backup strategies that you can implement. For information about the supported strategies and the best practices for using them, see the Backup Strategies section in this chapter.
You can configure the Caché online backup settings using the choices in the System Administration > Configuration > Database Backup menu.of the Management Portal. You can also perform some of these tasks using the methods in the Backup.General class. This section points you to the appropriate method where it applies.
From the System Management portal you can perform the following configuration tasks:
Note:
The configuration tasks are in the management portion of the Management Portal application; you must have the appropriate manager-level security to configure the backup settings.
Define Database Backup List
Caché maintains a database list that specifies the databases to back up. You can display this list by navigating to the [System Administration] > [Configuration] > [Database Backup] > [Database Backup List] page of the Management Portal.
Use the arrow buttons to move the databases you do not want to back up to the Available list and the databases you do want to back up to the Selected list. Click Save. If you do not select any databases, the system backs up all databases.
When you add a new database to your system, Caché automatically adds it to the database list. If you do not need to include the new database in your backup plan, be sure to remove it from the Backup Database List.
Note:
The defined database list is ignored by the FullAllDatabases backup task, which performs a backup of all databases excluding the CACHETEMP, CACHELIB, and DOCBOOK databases.
You can also maintain the backup database list using the ^BACKUP routine or the Backup.General.AddDatabaseToList() and Backup.General.RemoveDatabaseFromList() methods. See the Backup.General class description in the InterSystems Class Reference for details on using these methods.
Configure Backup Tasks
Caché provides different types of backup tasks; each is listed as an item on the Database Backup Settings menu. The configuration backup tasks are:
These are predefined backup tasks that you can run on-demand from the [System Operation] > [Backup] page of the portal. You can also schedule combinations of these backup tasks using the Task Manager. See the Schedule Backup Tasks section in this chapter for details.
The process for configuring each of these tasks is the same. The Name, Description, and Type fields are read-only and reflect the menu choice as described in the following table.
Backup Task Descriptions
Name Description Type
FullAllDatabases Full backup of all commonly updated databases, whether or not they are in the Backup Database List. Full
FullDBList Full backup of the Caché databases listed in the Backup Database List. Full
IncrementalDBList Incremental backup of changes made to the data since the last backup, whether full or cumulative. Backup is performed on the databases currently listed in the Backup Database List. Incremental
CumuIncrDBList Cumulative and Incremental backup of all changes made to the data since the last full backup. Backup is performed on the databases currently listed in the Backup Database List. Cumulative
You can send backup output to a directory on disk or to magnetic tape. Select one of the two options:
  1. To back up to a directory on disk, specify the file pathname in the Device field. Click Browse to select a directory.
  2. To back up to magnetic tape, select the Save to Tape check box, and specify a Tape Number from the list of available tape device numbers.
    See the Identifying Devices section of the Caché I/O Device Guide for detailed information regarding tape numbers.
    Note:
    InterSystems does not recommend backing up to tape.
    The Save to Tape option is not available on OpenVMS platforms; to save to tape, use the ^BACKUP routine (see Perform Backup and Restore Tasks Using ^BACKUP).
The Define Database Backup List section describes how to maintain the Backup Database List.
Backup File Names
By default, backup files are stored in install-dir\Mgr\Backup. The backup log files are stored in the same directory. Backup files have the suffix .cbk. Backup log files have the suffix .log.
Backup files and backup log files use the same naming conventions:
Where nnn is a sequence number incremented for that backup task on that date.
Schedule Backup Tasks
You should ideally set up a schedule for running backups. Backups are best run at a time when there are the least amount of active users on the system.
In addition to the four on-demand backup tasks supplied with Caché, you can create additional definitions of these four backup tasks. For example, you could create two full backup tasks, one to save the backup to a disk file, the other to save the backup to a tape. Or, to alternate backups between two disk drives, you could create a backup task for each drive.
Use the Caché Task Manager to schedule these backup tasks:
  1. Navigate to the [System Operation] > [Task Manager] page of the Management Portal.
  2. Specify the Task name, Description, Task type, in addition to any changes to the defaults and click Next.
  3. Enter your desired scheduling information and click Finish.
You can now view your task on the [System Operation] > [Task Manager] > [View Task Schedule] page and manage it as you do other tasks by clicking Details on its row.
Managing Caché Online Backups
Caché online backup is one of the backup strategies that you can implement. For information about the supported strategies and the best practices for using them, see the Backup Strategies section in this chapter.
You can manage Caché online backups from both the Management Portal and the Caché ^BACKUP utility. This section focuses on the portal procedures and, where applicable, points to the section that describes the utility procedure.
You can run Caché database backup tasks and view backup history from the [System Operation] > [Backup] page of the Management Portal. If you schedule additional backup tasks using the Task Manager, you can manage those from the [System Operation] > [Task Manager] page of the Management Portal.
You can perform the following backup tasks from the System Management portal:
When you add a new database to your system, you must perform a full backup. You cannot perform an incremental backup until a full backup exists. If you intend to use the incremental and cumulative backup options, you must maintain the backup database list and run a full backup on that list.
After installing Caché, InterSystems recommends that you perform a FullDBList backup to establish a complete backup for subsequent use by the other backup tasks.
Note:
These backup tasks are in the operations portion of the Management Portal application; you must have the appropriate operator-level security to run the backup tasks.
Run Backup Tasks
There are four types of backup tasks you can run from the Management Portal [System Operation] > [Backup] page, each having its own menu item:
You must have performed a full backup on a database before performing an incremental or cumulative backup on that database. Use the following procedure to run an online backup:
  1. Click the menu item of the appropriate backup type.
  2. Verify that the settings in the Run Backup Task box are correct.
  3. If the backup options are correct, click OK to start the backup.
    Otherwise, follow the procedures in the Configuring Caché Online Backup Settings section to update them.
  4. While the backup is running, you can view the status of the running backup by clicking the text next to Backup started. See View Backup Status for details.
You can also run the last three of these backup tasks by choosing option 1) Backup from the ^BACKUP utility or running the ^DBACK utility. See Back Up Databases Using ^DBACK for details.
Multivolume Backups
A backup may require multiple tape volumes, or multiple disk files. Currently, there is no way to perform a multivolume backup using the Management Portal. If you require a multivolume backup, use the ^BACKUP utility. If a disk-full condition occurs, ^BACKUP prompts you for the name of another disk file on another disk.
In the event of an error during backup, you cannot restart the backup on a second or subsequent volume. You must restart the backup from the beginning.
See Estimate Backup Size Using ^DBSIZE for instructions on estimating the size of your backup before you run these tasks.
View Backup Status
Click View Backup Status from the [System Operation] > [Backup] page or click View on the running backup process to monitor the progress of the backup operation. The same information is recorded in the log file for that backup operation, which you can later view from the View Backup History page.
When Caché begins a backup, it updates the Time and Status columns of the listing. The Time column records the date and time you initiate the backup, not when it completes. The Status column is updated to Running.
Upon completion of a backup, Caché again updates the Status column to indicate the final status of the backup. For example:
The associated backup log contains helpful information; click View next to the task to view the backup log.
The next section, Abort a Running Backup describes an additional option that appears for a backup that is running.
Abort a Running Backup
There are three ways for you to abort a running backup:
View Backup History
Every backup operation creates a separate backup log file. The logs follow the naming convention described in Backup File Names.
From the portal you can view a list of system backup logs from completed backup tasks:
  1. Navigate to the [System Operation] > [Backup] page of the Management Portal.
  2. Click View Backup History in the right-hand column to display the [System Operation] > [Backup] > [Backup History] page, which lists information about the completed backups.
  3. To view the results of a particular backup, click View in the right-hand column of the appropriate row. You can view the contents of a backup log file and search for a string within that file.
Backup Errors
If a backup encounters any I/O errors, the backup aborts and logs a system error in the backup log file. Information in these log files allows you to quickly see where the problem occurred so that you can fix it.
One cause of backup failure is trying to perform a backup on a dismounted database. In the event of an error during backup, the backup utility allows you to retry the device on which the error occurred. Alternatively, you can abort the backup.
Caché Online Backup Utilities
Caché provides utilities to perform backup tasks. The ^BACKUP routine provides menu choices to run common backup procedures, which you can also run independently and in some cases non-interactively using scripts.
The utility names are case-sensitive. Run all these utilities from the %SYS namespace:
Caché maintains a bitmap list of database blocks modified since the last backup; you can use this list to keep track of database updates during backup stages. The ^DBSIZE utility, which inspects these bitmaps, helps you calculate the size of a backup. The Caché ^BACKUP utility uses a multipass scan of these lists to back up only the blocks modified since the last pass.
Estimate Backup Size Using ^DBSIZE
Immediately before performing a Caché backup, you can estimate the size of its output using the ^DBSIZE utility. It is only an estimate, since there is no way of knowing how many blocks will be modified once the backup starts. You can obtain a more accurate estimate by preventing global updates while running ^DBSIZE, and then running your backup before resuming global updates.
You can estimate the size of backups in two ways:
Note:
A database must be in the database backup list before you can evaluate it with ^DBSIZE. See the Define Database Backup List section for details.
Run ^DBSIZE Interactively
The following procedure describes the steps necessary to run ^DBSIZE interactively:
  1. Open the Caché Terminal and run the utility from the %SYS namespace:
    %SYS>Do ^DBSIZE
    
  2. Caché displays the ^DBSIZE main menu:
                   Incremental Backup Size Estimator
     
     
    What kind of backup:
       1. Full backup of all in-use blocks
       2. Incremental since last backup
       3. Cumulative incremental since last full backup
       4. Exit the backup program
    1 => 
    
  3. Enter the appropriate menu option to select the type of backup for which you want an estimate: full, incremental, or cumulative. The prompts are the same for each type.
  4. At the following prompt either press Enter to suspend updates so that you get a more accurate estimate or enter No to allow updates:
    Suspend Updates?  Yes=>
    If you choose to suspend updates, you receive the following message:
    WARNING: Switch is set and may affect production for up to 30 seconds.
    Waiting for disk cleanup to finish... ready.
  5. The output first shows you how many Caché blocks you need to do the type of backup you selected. It shows an estimate for each directory in the backup list and a total. The following is an example of the display for a full backup:
                                                              In-Use   Block
         Directory                                            Blocks    Size
     
    c:\mycache\mgr\                                           19,963   (8KB)
    c:\mycache\mgr\cacheaudit\                                   189   (8KB)
    c:\mycache\mgr\docbook\                                   16,015   (8KB)
    c:\mycache\mgr\user\                                          61   (8KB)
                                                      --------------
         Total number of database blocks:                     36,228
    
    The display for an incremental and cumulative backup looks similar to this:
                                                             Modified  Block
         Directory                                            Blocks    Size
     
    c:\mycache\mgr\                                                5   (8KB)
    c:\mycache\mgr\cacheaudit\                                     3   (8KB)
    c:\mycache\mgr\docbook\                                        1   (8KB)
    c:\mycache\mgr\user\                                           1   (8KB)
                                                      --------------
         Total number of database blocks:                         10
    
  6. On Microsoft Windows and UNIX® platforms, the utility then displays information about backup disk file space:
    Total backup size, including overhead of volume and pass labels:
     
         For a disk file:
              Number of 512-byte blocks:  598,092  (306,223,104 bytes)
    On OpenVMS platforms, the utility then displays information about backup RMS file space:
    For an RMS file:
      Total Number of 512 Blocks including overhead of backup
           volume and pass labels:  24064
         Pre Allocation quantity is: 32016
  7. Finally, the utility provides information about the amount of space used if you send the backup to magnetic tape:
         For magnetic media:
              Number of 58KB blocks:  4  (237,568 bytes)
Use the ^DBSIZE Function
You can also call ^DBSIZE from a routine. To do so, you use the following function:
$$INT^DBSIZE(backup_type)
Important:
The values of backup_type differ from the menu option numbers when running ^DBSIZE interactively.
backup_type Description
1 Incremental backup
2 Full backup
3 Cumulative incremental backup
For example, to see the size estimate for running a full backup:
%SYS>w $$INT^DBSIZE(2)
18950^5^160952320^2710^160309248^313104^313104
The returned value is seven numbers separated by a caret (^). In this example, the returned value 18950 is the total estimated size of the backup, in blocks; the returned value 5 indicates the number of database directories to back up. The following table shows what is contained in each piece of the output.
Position of output Description
Piece 1 Number of database blocks for backup
(-1 if error during processing or invalid parameter)
Piece 2 Number of directories to back up
Piece 3 Number of bytes for magnetic media (not including inter-record gaps)
Piece 4 Number of blocks for magnetic media
Piece 5 Number of bytes for a disk file
Piece 6 Number of 512-byte blocks for a disk file
Piece 7 Pre-allocation estimate of disk file blocks (for use on OpenVMS)
The following shows the output of calling the ^DBSIZE function for each type of backup:
%SYS>w $$INT^DBSIZE(1)
466^5^4157440^70^4122624^8052^8052

%SYS>w $$INT^DBSIZE(2)
18950^5^160952320^2710^160309248^313104^313104

%SYS>w $$INT^DBSIZE(3)
466^5^4157440^70^4122624^8052^8052
Perform Backup and Restore Tasks Using ^BACKUP
The Caché ^BACKUP utility allows you to perform Caché backup and restore tasks from a central menu as shown in the following example:
%SYS>Do ^BACKUP
 
 
1) Backup
2) Restore ALL
3) Restore Selected or Renamed Directories
4) Edit/Display List of Directories for Backups
5) Abort Backup

6) Display Backup volume information
7) Monitor progress of backup or restore

Option?
Enter the appropriate menu option number to start the corresponding routine. Press Enter without entering an option number to exit the utility.
Subsequent sections in this document describe the utilities started by choosing the corresponding option:
Back Up Databases Using ^DBACK
The Caché ^DBACK utility allows you to backup Caché databases. Running the ^DBACK utility is equivalent to choosing option 1 from the ^BACKUP utility menu. The following is an example of running the utility from the Caché Terminal:
  1. First, make sure you have defined your database backup list and choose your output device for the backup file.
  2. From the %SYS namespace run the ^DBACK routine:
    %SYS>Do ^DBACK
     
     
                     Cache Backup Utility
                  --------------------------
    What kind of backup:
       1. Full backup of all in-use blocks
       2. Incremental since last backup
       3. Cumulative incremental since last full backup
       4. Exit the backup program
    
  3. Select which Caché backup type (full, incremental, or cumulative) to run by entering the appropriate menu option number. The procedure for running the backup is the same regardless of what type you run.
  4. Enter the output device and a description of the backup:
    Specify output device (type STOP to exit)
    Device: c:\mycache\mgr\backup\FullDBList_20081201_003.cbk =>
    
    Backing up to device: c:\mycache\mgr\backup\FullDBList_20081201_003.cbk
    Description: Full Backup using ^DBACK
    
    The device defaults to that of the last backup. This example uses the format of the online backup device.
  5. The utility then displays a list of the database directories to back up (those in your database backup list). For example:
     Backing up the following directories:
     c:\mycache\mgr\
     c:\mycache\mgr\cacheaudit\
     c:\mycache\mgr\docbook\
     c:\mycache\mgr\user\
     
    
  6. Answer Y to start the backup. The journal file switches and you see a display of the backup progress:
    Start the Backup =>  [answer Y or N] => y
    Journal file switched to:
    c:\mycache\mgr\journal\20081201.004
    . 
    Starting backup pass 1
  7. At the beginning of the third and final pass, the utility displays information about the oldest journal file that will be required for transaction rollback when the backup is restored, for example:
    Starting backup pass 3
     
    Journal file 'c:\intersystems\cache62\mgr\journal\20120919.003' and the subsequent ones
    are required for recovery purposes if the backup were to be restored
     
    Journal marker set at
    offset 197180 of c:\intersystems\cache62\mgr\journal\20120919.003
    This information is available in the backup log.
  8. When the backup finishes successfully, you see the following:
    ***FINISHED BACKUP***
     
    Global references are enabled.
     
    Backup complete.
     
    %SYS>
The next section, External Entry Points for ^DBACK, explains how to call this utility from your external backup procedures using the provided entry points.
External Entry Points for ^DBACK
The entry points provided for the ^DBACK utility are for you to use in your external backup procedures. You must use them as described to ensure the integrity of the backup. All of the entry points return 1 if they are successful or 0 if they fail. The following external entry points are available for the ^DBACK routine:
BACKUP^DBACK
This procedure invokes a backup using the passed arguments to satisfy the questions that are asked during the interactive execution of ^DBACK.
BACKUP^DBACK(argfile,TYPE,DESC,OUTDEV,kiljrn,LOGFILE,MODE,clrjrn,swjrn,
nwjrnfil,quietimeout,taskname)
The arguments that are capitalized are the ones most important to the backup procedure in this release of Caché. Due to changes in the journaling mechanism, you can no longer delete the current journal file, clear the current journal file, or specify a new journal file name in the backup utilities. As a result, this version of Caché ignores many of the arguments as described in the following tables.
Argument Description
argfile No longer used; always use a null value.
DESC Description stored in the backup label and in the backup history global. Free form text string that can be empty.
TYPE Type of backup (required)
Values:
I — Incremental
C — Cumulative
F — Full
E — External full backup using a third-party or operating system backup utility
External (type E) backups ignore the arguments in the following table. Whether they are ignored or required for other backup types is also indicated in the table.
Argument Description
clrjrn No longer indicates to clear the current journal file; the function now interprets the values as indicated:
Y — switch the journal file
N — (ignored)
kiljrn No longer indicates to delete the journal file; the function now interprets the values as indicated:
Y — switch journal file
N — (ignored)
LOGFILE Indicates whether or not to log and where to write the output of the function:
File name — writes all messages that would be sent to the terminal to this file (recommended)
Null value — no log file
MODE Indicates what output to write to the terminal during the procedure; this does not control what is written to the log file.
Values:
“NOISY” — write all text on terminal (default)
“QUIET” — only write text related to abnormal conditions
“NOINPUT” — do not send any output as no terminal is attached to this process; if a read is required, the backup aborts
nwjrnfil (Ignored)
OUTDEV Output device for the backup; can be a file name or tape device (required).
swjrn Indicates whether or not to switch the journal file:
Y — switch the journal file (recommended)
N — do not switch the journal file (due to the journal file changes, if the clrjrn or kiljrn arguments have a value of Y, swjrn converts to Y.
The following are two optional arguments:
Argument Description
quietimeout Number of seconds to wait for the system to quiesce before aborting the backup. A zero (0) or negative value indicates to wait indefinitely (default = 60).
taskname Task name used internally by Caché for backup types of F, I, and C.
Using these external entry points requires read/write access to the ^SYS global for all modes. An external (type E) backup deletes the .IND, .INE, and .INF files in the directories in the ^SYS global. The routine also records this backup with the description in the backup history global as being the LASTFULL backup.
If you set switch 10 when you call this routine, it remains set throughout the backup. If you set switch 13, then the procedure converts it into a switch 10 while the backup performs necessary Set and Kill commands and then restores it to switch 13 upon exit.
The routine performs the New command on variables defined by this entry point, but does not on those defined within the body of the ^DBACK procedure. As a result, you must be careful to protect all other variables in any calling routine prior to calling ^DBACK.
Return values:
LISTDIRS^DBACK
This procedure opens an output file and writes a list to it of database directories included in a backup. If the list is empty, the procedure backs up all database directories (except CACHETEMP). The format of the function is as follows:
LISTDIRS^DBACK(file,mode)
Argument Description
file Name of the output file name to which the function writes the list of database directories in the backup list.
mode Indicates what output to write to the terminal during the procedure.
“QUIET” — Only display return value and text related to abnormal conditions.
Any other value — Display the directory list at the terminal.
The following is an example of the output displayed on the terminal:
%SYS>w $$LISTDIRS^DBACK("c:\temp\listdirs.txt","NOISY")
 
List of directories to be backed up
     c:\mycache\mgr\cacheaudit\
     c:\mycache\mgr\cachelib\
     c:\mycache\mgr\
     c:\mycache\mgr\docbook\
     c:\mycache\mgr\samples\
     c:\mycache\mgr\user\
1
%SYS>
Notes for this procedure:
CLRINC^DBACK (Legacy Concurrent External Backup Only)
This procedure is called to clear the incremental backup bitmaps that mark blocks as modified for the databases in the backup list. At the same time it also deletes the backup history as it is no longer possible to do any sort of a backup without first performing a full backup. This procedure is designed to be used prior to doing an external full backup with Caché running. If you perform an external backup with Caché down, then before shutting down the system, call this entry point. The format of the function is as follows:
CLRINC^DBACK(mode)
Argument Description
mode Indicates what output to write to the terminal during the procedure.
“QUIET” — Only display return value and text related to abnormal conditions.
Any other value — Display the directory names as they are processed.
For example:
%SYS>w $$CLRINC^DBACK("QUIET")
1
%SYS> 
%SYS>Do CLRINC^DBACK("NOISY")
 
     Cleared incremental backup bitmap in c:\mycache\mgr\
     Cleared incremental backup bitmap in c:\mycache\mgr\cacheaudit\
     Cleared incremental backup bitmap in c:\mycache\mgr\docbook\
     Cleared incremental backup bitmap in c:\mycache\mgr\samples\
   Cleared incremental backup bitmap in c:\mycache\mgr\user\
%SYS>
Notes for this procedure:
Edit/Display List of Directories for Backup Using ^BACKUP
Important:
When editing the database list use the database name, not the directory name. This is consistent with the way the backup configuration works in the Management Portal.
Options of the Caché ^BACKUP utility allow you to backup Caché databases or to restore an already created backup. If you have not created a list of databases, then the utility includes all databases in the backup. When you create a list, it applies to all aspects of the Caché backup system including calls to the entry points of the ^DBACK utility in scripted backups.
The following examples show sample output from each option on the menu:
  1. From the ^BACKUP menu, choose option 4 to display the database backup list maintenance menu:
    %SYS>Do ^BACKUP
     
     
    1) Backup
    2) Restore ALL
    3) Restore Selected or Renamed Directories
    4) Edit/Display List of Directories for Backups
    5) Abort Backup
    6) Display Backup volume information
    7) Monitor progress of backup or restore
     
    Option? 4
     
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
    
  2. To add a database to the list choose option 1. This example also uses option 3 to show that the database is added to the current list.
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
     
    Option? 1
    Enter database to add? SAMPLES
    Enter database to add?
    You've selected SAMPLES to be added to the backups
    Are you sure you want to do this (yes/no)? y
    Completed.
     
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
     
    Option? 3
    The following 5 databases are included in backups
         CACHEAUDIT               C:\MyCache\Mgr\cacheaudit\
         CACHESYS                 C:\MyCache\Mgr\
         DOCBOOK                  C:\MyCache\Mgr\Docbook\
         SAMPLES                  C:\MyCache\Mgr\Samples\
         USER                     C:\MyCache\Mgr\User\
    
  3. To remove a database to the list choose option 2. This example also uses option 3 to show that the database is removed from the current list.
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
     
    Option? 2
    Enter database to remove (^ when done)?  SAMPLES
    Enter database to remove (^ when done)?
    You've removed SAMPLES from the backups
    Are you sure you want to do this? y
    Completed.
     
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
     
    Option? 3
    The following 4 databases are included in backups
         CACHEAUDIT               C:\MyCache\Mgr\cacheaudit\
         CACHESYS                 C:\MyCache\Mgr\
         DOCBOOK                  C:\MyCache\Mgr\Docbook\
         USER                     C:\MyCache\Mgr\User\
    
  4. To display a list of all databases in this instance choose option 4:
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
     
    Option? 4
    The following is a list of all databases in the configuration.
    Databases which are part of the backup are marked with (*)
         (*) CACHEAUDIT           c:\MyCache\mgr\cacheaudit\
             CACHELIB (Read Only) c:\MyCache\mgr\cachelib\
             CACHE                c:\MyCache\mgr\cache\
         (*) CACHESYS             c:\MyCache\mgr\
             DOCBOOK              c:\MyCache\mgr\docbook\
             SAMPLES              c:\MyCache\mgr\samples\
         (*) USER                 c:\MyCache\mgr\user\
     
    
  5. To display information about the last full backup choose option 5:
    1) Add a database to the backup
    2) Remove a database from the backup
    3) Show current list of databases included in backups
    4) Show list of available databases
    5) Display last full backup information
     
    Option? 5
     
    =====Last Full Backup Information=====
     
    Date: 19 Jan 2011
    Description: Full backup of all databases that are in the backup database list.
    Device: c:\MyCache\mgr\backup\FullDBList_20110119_001.cbk
    
Abort a Running Backup Using ^BACKUP
You can abort a running backup using menu option 5 of the ^BACKUP utility.
%SYS>Do ^BACKUP
 
 
1) Backup
2) Restore ALL
3) Restore Selected or Renamed Directories
4) Edit/Display List of Directories for Backups
5) Abort Backup
6) Display Backup volume information
7) Monitor progress of backup or restore
 
Option? 5
Are you sure you want to abort the backup operation ? <No> Yes
Backup abortion succeed.
If no backup is running when you choose this option, you receive the following message:
No Backup operation is currently running.
Display Information About a Backup Volume Using ^BACKUP
When you select option 6 from the ^BACKUP menu, you are prompted for the pathname of a backup file, as shown in the following:
Enter the backup volume you want to display information from
 (Type STOP to exit)
Device: c:\131u1\mgr\backup\FullAllDatabases_20120802_001.cbk =>
 
This backup volume was created by:
Cache for Windows (x86-64) 2013.1 (Build 257U) Sun Jul 1 2012 23:35:31 EDT
 
The volume label contains:
   Volume number       1
   Volume backup       AUG 2 2012 12:27PM Full
   Previous backup     AUG 2 2012 11:35AM Cumulative Incremental
   Last FULL backup    AUG 2 2012 11:24AM
   Description         Full backup of ALL databases
   Buffer Count        0
   Mirror name         JEFF122
   Failover member     NONNIE20/CACHE122A   
   Journal File        c:\131u1\mgr\journal\20120802.005
   Log file            c:\131u1\mgr\Backup\FullAllDatabases_20120802_001.log
   Backup Status       Completed
 
Database                                Size(mb)  Mirror DB Name 
--------                                --------  --------------
c:\131u1\mgr\                                191
c:\131u1\mgr\cacheaudit\                      11
c:\131u1\mgr\user\                          2113  MUSER
Total of 3 databases, totaling 2315 mb
Backup volume size is 2365 mb
Monitor Backup or Restore Progress Using ^BACKUP
To monitor the progress of a running backup or restore job started using ^BACKUP, select option 7 from the ^BACKUP menu. You can start the monitor in a separate Terminal window before starting the backup or restore job.
For a running backup job, the following information is displayed:
                                 Backup Status
                                 -------------
 
Status:                       Running
Backup process pid:           13052
Backup file:                  c:\132u1\mgr\stcfull.bck
Description:
Log file:                     c:\132u1\mgr\cachebackup.log
Type:                         Full
Start time:                   2012-09-05 14:09:02
Estimated finish time:        2012-09-05 14:09:45
Total time (hh:mm:ss):        00:00:18
Time remaining (hh:mm:ss):    00:00:25
Estimated backup size:        7.68GB
Current backup size:          3.12GB
Current Backup rate:          184MB/sec
% Completed                   41
For a running restore job, the following information is displayed:
                                 Restor Status
                                 -------------
 
Status:                       Running
Restore process pid:          13052
Restore file:                 c:\132u1\mgr\stcfull.bck
Description:
Type:                         Full
Start time:                   2012-09-05 14:10:49
Estimated finish time:        2012-09-05 14:12:07
Total time (hh:mm:ss):        00:00:34
Time remaining (hh:mm:ss):    00:00:44
Restore file size:            7.68GB
Restore size completed:       3.28GB
Current restore rate:         103MB/sec
% Completed                   43
Note:
When doing an incremental backup, some of the fields are not available and are displayed as N/A. This includes Time remaining, Estimated backup size, and % Completed.
A restore job cannot be monitored if switch 10 was set when starting the restore.
Tape backup and restore jobs cannot be monitored using this utility.
Caché Online Backup Restore Utility
The Caché Online Backup Restore Utility (^DBREST) utility performs the following actions:
The ^DBREST menu options 1, 2 and 3 are the same as options 2, 3 and 6 from the ^BACKUP menu.
When you select one of these restore options, the utility asks you to enter the name of the device holding the first backup to restore. The default the first time you enter a restore option is the device to which the last full backup was sent, if there was one.
Caution:
When you are restoring an incremental or cumulative backup, the target database must be in exactly the same state as when you restored it from the last full backup.
You must prevent all updates to the restored databases until you restore all subsequent incremental backups. Failure to heed this warning can result in the incremental or cumulative restore producing a degraded database.
The following is an example of running the utility from the Caché Terminal:
%SYS>Do ^DBREST
 
                        Cache DBREST Utility
         Restore database directories from a backup archive
 
Restore: 1. All directories
         2. Selected and/or renamed directories
         3. Display backup volume information
         4. Exit the restore program
    1 => 
The following sections describe the process of choosing each option:
You can also perform these functions non-interactively in a script. See the External Entry Points of ^DBREST section for details.
Restore All Databases Using ^DBREST
Choosing 1 from the ^DBREST menu is equivalent to choosing 2 from the ^BACKUP menu.
Note:
If you are restoring mirrored databases, review Mirrored Database Considerations in this section before you perform this procedure.
The following procedure is an outline of an example that restores all directories. It shows the beginning prompts of the restore process. As it continues, the utility asks you very specific questions while stepping through the restore process.
  1. Select to restore all directories from the utility menu. This option restores all directories that are on the backup medium.
    %SYS>Do ^DBREST
     
                            Cache DBREST Utility
             Restore database directories from a backup archive
     
    Restore: 1. All directories
             2. Selected and/or renamed directories
             3. Display backup volume information
             4. Exit the restore program
        1 => 1
    
  2. Confirm that you want to restore all directories:
    Proceed with restoring ALL directories Yes=>
  3. Next you are asked to enter the top path you want all the databases to be restored to. The system prefixed it to the original path of the database to be restored. So all the databases are restored under this directory with their original directory as a subdirectory to this directory. Press Enter to ignore it and restore the databases to their original path.
    Top directory for all Databases to be restored to (? for Help)?
  4. Indicate whether you want to suspend Caché processes while restoring takes place. InterSystems recommends suspending processes.
    Do you want to set switch 10 so that other processes will be
    prevented from running during the restore? Yes =>
  5. Specify the first file from which to restore. You can press Enter to accept the default file, which is the last full backup.
    Specify input file for volume 1 of backup 1
     (Type STOP to exit)
    Device: c:\mycache\mgr\backup\FullAllDatabases_20110323_001.cbk =>
    
  6. Check that the description of the backup is correct and verify that this is the file you want to restore.
    This backup volume was created by:
       Cache for Windows (Intel) 5.1
     
    The volume label contains:
       Volume number      1
       Volume backup      MAR 23 2011 09:52AM Full
       Previous backup    MAR 22 2011 11:00AM Incremental
       Last FULL backup   MAR 16 2011 11:00AM
       Description        Full backup of ALL databases, whether or not they are in
                          the backup database list.
       Buffer Count       0
    Is this the backup you want to start restoring? Yes =>
    
  7. The utility tells you which directories it will restore, and the restore proceeds.
    The following directories will be restored:
    c:\mycache\mgr\
    c:\mycache\mgr\cacheaudit\
    c:\mycache\mgr\samples\
    c:\mycache\mgr\test\
    c:\mycache\mgr\user\
    
     
    ***Restoring c:\mycache\mgr\ at 10:46:01
    146045 blocks restored in 241.3 seconds for this pass, 146045 total restored.
    
  8. Specify the input file for the next incremental backup to restore, or enter stop if there are no more input files to restore.
    Specify input file for volume 1 of backup following MAR 23 2011  09:52AM
     (Type STOP to exit)
    Device: stop
    
  9. Indicate whether you want to restore other backups. When you answer Yes, the procedure repeats. When you respond No, Caché mounts the databases you have restored.
    Do you have any more backups to restore? Yes => No
    Mounting c:\mycache\mgr\
        c:\mycache\mgr\       ... (Mounted)
     
    Mounting c:\mycache\mgr\cacheaudit\
        c:\mycache\mgr\cacheaudit\  ... (Mounted)
     
    Mounting c:\mycache\mgr\samples\
        c:\mycache\mgr\samples\  ... (Mounted)
     
    Mounting c:\mycache\mgr\test\
        c:\mycache\mgr\test\  ... (Mounted)
     
    Mounting c:\mycache\mgr\user\
        c:\mycache\mgr\user\  ... (Mounted)
     
    
  10. Specify which journal entries you want to apply to the restored databases and the name of the journal file you are restoring. Normally, you select option 1 and apply only those changes that affect the directories you have just restored.
    Restoring a directory restores the globals in it only up to the
    date of the backup.  If you have been journaling, you can apply
    journal entries to restore any changes that have been made in the
    globals since the backup was made.
     
    What journal entries do you wish to apply?
     
         1. All entries for the directories that you restored
         2. All entries for all directories
         3. Selected directories and globals
         4. No entries
     
    Apply: 1 =>
    
  11. Restore from the journal files begins after confirming several pieces of information:
    We know something about where journaling was at the time of the backup:
    0: offset 172940 in c:\mycache\mgr\journal\20110323.002
     
    Use current journal filter (ZJRNFILT)? No
    Use journal marker filter (MARKER^ZJRNFILT)? No
    Updates will not be replicated
     
    The earliest journal entry since the backup was made is at
    offset 172940 in c:\mycache\mgr\journal\20110323.002
     
    Do you want to start from that location? Yes => Yes
    Final file to process (name in YYYYMMDD.NNN format): <20110323.003> [?]
          =>
     
    Prompt for name of the next file to process? No => No
     
    Provide or confirm the following configuration settings:
     
    Journal File Prefix: =>
     
    Files to dejournal will be looked for in:
         c:\mycache\mgr\journal\
         c:\journal\altdir\
    in addition to any directories you are going to specify below, UNLESS
    you enter a minus sign ('-' without quotes) at the prompt below,
    in which case ONLY directories given subsequently will be searched
     
    Directory to search: <return when done>
    Here is a list of directories in the order they will be searched for files:
         c:\mycache\mgr\journal\
         c:\journal\altdir\
    The journal restore includes the current journal file.
    You cannot do that unless you stop journaling or switch
         journaling to another file.
    Do you want to switch journaling? Yes => Yes
    Journaling switched to c:\mycache\mgr\journal\20110323.004
     
    You may disable journaling the updates for faster restore; on the other hand,
    you may not want to do so if a database to restore is being shadowed.
    Do you want to disable journaling the updates? Yes => yes
    Updates will NOT be journaled
    
  12. The utility displays its progress and indicates when it is complete:
     
     
    c:\mycache\mgr\journal\20110323.002
      61.32%  65.03%  68.44%  72.21%  75.86%  79.26%  82.73%  86.08%  89.56%  
      92.99%  96.07%  98.87%100.00%
    ***Journal file finished at 11:03:31
     
     
    c:\mycache\mgr\journal\20110323.003
      16.17%  17.10%  17.90%  18.90%  20.05%  21.33%  22.58%  23.81%  25.15%  
      26.32%  27.65%  28.85%  30.08%  31.37%  32.59%  33.98%  35.16%  36.25%  
      37.32%  38.41%  39.55%  40.72%  41.81%  42.83%  43.85%  44.89%  46.00%  
      47.15%  48.24%  49.28%  50.32%  51.41%  52.54%  53.71%  54.76%  55.80%  
      56.85%  57.97%  59.10%  60.16%  61.17%  62.19%  63.24%  64.32%  65.18%  
      66.02%  66.87%  67.71%  68.52%  69.34%  70.14%  70.96%  71.76%  72.60%  
      73.58%  74.51%  75.43%  76.35%  77.26%  78.17%  79.07%  79.69%  80.31%  
      80.93%  81.56%  82.20%  82.83%  83.47%  84.27%  87.00%  88.57%  91.65%  
      93.03%  96.09%  97.44%  99.04%100.00%
    ***Journal file finished at 11:03:32
     
    Journal reads completed. Applying changes to databases...
      14.29%  28.57%  42.86%  57.14%  71.43%  85.71% 100.00%
     
    [journal operation completed]
    
Restore Selected or Renamed Databases Using ^DBREST
Choosing 2 from the ^DBREST menu is equivalent to choosing 3 from the ^BACKUP menu. This option lets you select which directories to restore from the backup medium. It also allows you to restore a database to a different directory name or to a different device.
Note:
If you are restoring mirrored databases, review Mirrored Database Considerations in this section before you perform this procedure.
The following example shows how to restore selected or renamed directories.
  1. Choose option 2 from the ^DBREST utility:
    %SYS>Do ^DBREST
     
                            Cache DBREST Utility
             Restore database directories from a backup archive
     
    Restore: 1. All directories
             2. Selected and/or renamed directories
             3. Display backup volume information
             4. Exit the restore program
        1 => 2
    
  2. Indicate whether you want to suspend Caché processes while restoring takes place. InterSystems recommends suspending processes.
    Do you want to set switch 10 so that other Cache processes
    will be prevented from running during the restore? Yes =>
  3. Specify the first file from which to restore. You can press <Enter> to accept the default file, which is the last full backup.
    Specify input file for volume 1 of backup 1
     (Type STOP to exit)
    Device: c:\mycache\mgr\backup\IncrementalDBList_20110323_001.cbk =>
    
  4. Check that the description of the backup is correct and verify that this is the file you want to restore.
    This backup volume was created by:
       Cache for Windows (Intel) 5.1
     
    The volume label contains:
       Volume number      1
       Volume backup      MAR 23 2011 11:03AM Full
       Previous backup    MAR 23 2011 09:52AM Full
       Last FULL backup   MAR 23 2011 09:52AM
       Description        Incremental backup of all databases that are in the backup
                          database list.
       Buffer Count       0
    Is this the backup you want to start restoring? Yes =>
    
  5. As the utility prompts you with directory names, specify which databases you want to restore, and in which directories you want to restore them:
    For each database included in the backup file, you can:
     
     -- press RETURN to restore it to its original directory;
     -- type X, then press RETURN to skip it and not restore it at all.
     -- type a different directory name.  It will be restored to the directory
        you specify.  (If you specify a directory that already contains a
        database, the data it contains will be lost).
     
    c:\mycache\mgr\ =>
    c:\mycache\mgr\cacheaudit\ =>
    c:\mycache\mgr\test\ =>
    c:\mycache\mgr\user\ =>
    
    
  6. After responding to each directory prompt, you see the prompt:
    Do you want to change this list of directories? No =>
    
    Answer Yes if you want to edit your choices, or press Enter to confirm them.
  7. The process then continues the same as the procedure for restoring all directories, as specified in the previous section.
You can use this procedure to restore a backup performed on different system from the one on which you are restoring it.
Restoring Databases Using the Backup History
The Caché backup utility maintains a backup history to help you restore backups in logical order. The restore utility prompts you for the backups to restore according to their type and order in the backup history.
After restoring the last full backup, the utility uses the information in the backup history to suggest the next logical backup for you to restore and continues through the history. It prompts you to restore subsequent backups in the following order:
  1. The most recent cumulative backup after the last full backup, if one exists.
  2. All incremental backups since the last cumulative backup (or if none exists, since the last full backup). It does so in order from the first to the most recent.
You can override the suggested backups in the restore process. Remember, however, that an incremental or cumulative backup does not represent a complete copy of the databases. You can restore an incremental backup only after restoring a full backup.
Important:
On Caché platforms that support access to a database from cluster (for example, OpenVMS) nodes, you should always back up a given database directory from the same node so that its complete backup history is available if you need to restore the directory.
External Entry Points of ^DBREST
The Caché restore utility, ^DBREST, provides a non-interactive execution option using external entry points.
Note:
If you are restoring mirrored databases, review Mirrored Database Considerations in this section before you perform an unattended restore.
You can write a script to implement unattended restores by calling one of these two entry points:
Both entry points are functions, which return the status of the call. All arguments are input only. The following table describes the input arguments used for both functions except where indicated.
Argument Description
allowupd Indicator whether or not to allow updates during the restore process:
1 — allow updates during the restore process
0 — do not allow updates
dirlist Name of file containing a list of directories to restore. One record for each directory to be restored has to be present. Ignored for the EXTALL entry point. See Directory List File Requirements.
inpdev Input device that contains the backup. If this device is a tape device, the utility prompts you to specify the device for the next volume.
jdirglo Only used when jrnopt is 3. This is the name of the file containing selection criteria for directories and globals for the journal restore. See Directory and Global Selection Criteria.
jrnfile Journal file. If null, the utility uses the current file, which is stored in the ^%SYS("JOURNAL“,”CURRENT") global.
jrnopt Options to restore the journal:
1 — All directories for which you just restored the backup
2 — All directories in the journal
3 — Selected directories and globals specified by the jdirglo argument
4 — No directories
quietmode A value indicates the operation is in quiet (non-interactive) mode; must be a non-null value for this external call, typically 1.
The following return codes are possible from calling these functions:
Return Code Description
3 No errors; successful completion
-1 Cannot open input device (device to restore from)
-2 Volume label does not match label in backup history
-3 Backup/Restore already in progress
-4 Invalid device for reading selection criteria (for selective restore of directories)
-5 Invalid journal restore option
-6 Invalid journal file or file for selection criteria for journal restore cannot be opened
Directory List File Requirements
Requirements of the file indicated by dirlist:
For example, assuming you have created a text file (RestoreList.txt) in the C:\Backup\ directory that contains the string:
C:\intersystems\cache\mgr\user\,C:\intersystems\cache\mgr\,Y
you could execute the following routine in the %SYS namespace to restore the database from C:\intersystems\cache\mgr\user\ to C:\intersystems\cache\mgr\:
set SourceDir = "C:\intersystems\cache\mgr\user\"
set BackupDir = "C:\Backup\"
set BackupListFile="C:\Backup\RestoreList.txt"
do EXTSELCT^DBREST(1,0,BackupDir_"back1.cbk",BackupListFile,4,"","")
Directory and Global Selection Criteria
Requirements of the file indicated by jdirglo:
Argument Description
DirName Name of the directory on which you want to restore the journal.
Globals A list of globals separated by commas for journal restore. Only used if RestAll is N. If the list of globals is large, you can enter the remaining global names on the next line but you must specify the directory name again followed by N and then the list of globals.
RestAll Whether or not to restore journal entries for all globals in the directory; not case-sensitive and required.
Y — restore journal on all globals in this directory
N — specify globals for journal restore in globals list
Examples of different records:
DUA0:[TEST1],Y
DUA1:[TEST2],N,GLO1,GLO2,GLO3
DUA1:[TEST2],N,GLO4,GLO5,GLO6
DUA1:[TEST3],n 
The last record could also be completely omitted if you do not want to restore the journal for that directory.
Mirrored Database Considerations
When a mirrored database is the target of a Caché backup restore, the source database must match the target (that is, it must be the same mirrored database).
Note:
Mirrored database backups created on a failover mirror member can be restored to any member of that mirror (that is, another failover member or an async member). If you are restoring from a backup created on an async mirror member, see Restoring from Async Mirror Members in this section.
Caché backup restore in a mirror behaves differently depending on whether it is being restored on the mirror member where the backup was created or on a different system:
Full Backup Restores of Mirrored Databases
The following differences apply to full backup restores of mirrored databases, whether they are done interactively via the ^DBREST utility (see Caché Online Backup Restore Utility in this chapter) or non-interactively via the EXTALL entry point (see External Entry Points of ^DBREST in this chapter):
Following a full backup restore the system attempts to:
  1. Activate the mirrored databases by restoring the required journal files.
  2. Link the mirrored databases into the active mirror (if the mirror exists and a copy of the database does not already exist).
Selective Backup Restores of Mirrored Databases
The following differences apply to selective backup restores of mirrored databases:
As with full backup restores, following a selective backup restore, the system attempts to:
  1. Activate the mirrored databases by restoring the required journal files.
  2. Link the mirrored databases into the active mirror (if the mirror exists).
Restoring from Async Mirror Members
The following considerations apply when restoring from mirrored databases created on async mirror members: