Page 1
© Copyright Medtech Limited Page 1 of 28
EMPOWERING HEALTH
Medtech32
InterBase Backup & Restore Guide
(March 2017)
This user guide contains important information for all Medtech32 users and IT Support Personnel.
Please ensure that the document is circulated amongst all relevant staff. We suggest that this
user guide is filed safely for future reference.
Page 2
© Copyright Medtech Limited Page 2 of 28
EMPOWERING HEALTH
Table of Contents
Introduction 3
Overview of InterBase Backup & Restore 3
PREREQUISITES CHECKLIST 3
InterBase Backup & Restore 4
AVAILABLE SPACE 4
STOPPING APPLICATIONS/UTILITIES THAT ACCESS INTERBASE DATABASE 5
BRIEFCASE CHECK-IN 5
InterBase Backup & Restore Steps 7
INTERBASE BACKUP 7
SEARCH FOR EXISTING .IBK FILES 7
LOGIN TO THE INTERBASE SERVER 11
REGISTER DATABASES 11
INTERBASE BACKUP STEPS USING IBCONSOLE 13
SELECT THE BACKUP OPTION 13
DEFINE THE BACKUP INFORMATION 13
INTERBASE RESTORE STEPS USING IBCONSOLE 15
SELECT THE RESTORE OPTION 16
DEFINE THE RESTORE INFORMATION 16
INTERBASE BACKUP USING BATCH SCRIPT 20
INTERBASE RESTORE USING BATCH SCRIPT 21
DATABASE DAILY CHECK 21
InterBase Database Backup & Restore Intervals 22
Benefits of InterBase Backup & Restore 22
On-Demand InterBase Restore 23
USING THE DIFFERENCE BETWEEN OLDEST ACTIVE AND NEXT TRANSACTION 23
USING DAILY GFIX ANALYSIS 24
Steps to verify Primary Key Index Corruption 25
IDENTIFY LIST OF CORRUPTED INDEXES 25
IDENTIFY LIST OF PRIMARY INDEXES HAS DUPLICATE KEYS 25
PREREQUISITES 25
Page 3
© Copyright Medtech Limited Page 3 of 28
EMPOWERING HEALTH
Introduction
This guide explains the detailed step-by-step information for performing an InterBase Backup
& Restore. This documents applies to:
InterBase XE Update 4
InterBase XE7 Update 5
Overview of InterBase Backup & Restore
WARNING: Before you proceed, please ensure that you have a successful Daily Backup of
your data – preferably from the latest database, either the InterBase File level copy (.IB) or
InterBase Backup copy (.ibk).
Please ensure that you are disconnected from the database before proceeding with the
restore.
Prerequisites Checklist
1. Check that a successful Daily Backup has been completed prior to
commencing the Backup & Restore process.
2. Disconnect from the Medtech32 application.
3. Stop Medtech Services and GP2GP Services.
4. Ensure that there is sufficient available disc space to store the InterBase
backup file.
5. Ensure that all Briefcasing laptops have been checked in prior to performing
the InterBase Backup & Restore.
6.
Stop all Medtech32-related components:
Medtech32 Scheduler
NIR Directory Tool
Generic Directory Monitor
ManageMyHealth Online Appointment
7. Stop Medtech InterBase Database-dependent third-party services;
e.g. Txt2Remind, Dr Info.
8. Login to the computer with Full Administrator Rights
Page 4
© Copyright Medtech Limited Page 4 of 28
EMPOWERING HEALTH
InterBase Backup & Restore
Regardless of which InterBase version is being used, Embarcadero (the US manufacturer)
recommends daily InterBase Backups and weekly InterBase Restores as a minimum. A Restore
verification should also be carried out on a regular basis.
On a daily basis, Embarcadero recommends executing the commands outlined below and if
they exceed the threshold, then an immediate InterBase Backup & Restore is required.
Run gStat –h If the number of next transactions approaches 2 billion, an InterBase Backup &
Restore is required.
Run gFix –V If any errors are identified, an InterBase Backup & Restore is required.
For example: "C:\Embarcadero\InterBase2011-MedTech\bin\gfix.exe" -v -full -user
SYSDBA -password masterkey "127.0.0.1/Medtech_IB11:T:\TRAINING DB\MT32.IB"
After the restore, re-run the above commands and verify the commands for no errors. If any
errors occur after the restore, contact Medtech for extended support.
Available Space
As a minimum you must have the total size of all databases combined as available space on
the server hard drive, in order to perform this procedure.
To locate this information on the server, double-click on the My Computer icon, then double-
click on the drive that contains Medtech32. Locate the MT32 folder and then double-click on
the Data folder.
Please note the size of the each of the database files MT32.ib, Blob.ib and Training.ib. To view
file size details, right-click on the file and select Properties Size.
Page 5
© Copyright Medtech Limited Page 5 of 28
EMPOWERING HEALTH
To ascertain available space: double-click on the My Computer icon, then right-click on the
drive that contains Medtech32 and select Properties. The amount of available space is listed.
Stopping applications/utilities that access InterBase database
Ensure that the Medtech Scheduler (normally located on the computer with HealthLink
installed), the NIR Directory Monitor Tool, the Generic Directory Monitor Utility and the
ManageMyHealth™ Online Appointments Manager have been stopped.
In order to determine if these applications are running, check the taskbar on the computer
with HealthLink installed. If these icons are present, then these applications need to be shut
down.
NOTE: if you restart the computer, it will attempt to reactivate the Utilities Tool if the ‘Run at
Windows Startup’ checkbox is ticked.
Briefcase Check-in
Open the Briefcase Administrator
Double-click on the Shortcut to bcadm.exe (Briefcase Administrator) icon from
your desktop. [The actual file is located in C:\MT32\Bin\BCADM.exe.]
Check-in the Database
Click on the ‘Merge the Changes …’ option or via the menu select Options ►
Merge Database Changes
Page 6
© Copyright Medtech Limited Page 6 of 28
EMPOWERING HEALTH
To continue, click the ‘Yes’ button.
Please wait while files are merged back to your Server
Database Merge Complete
Click ‘OK’ and exit the Briefcase Administrator
Page 7
© Copyright Medtech Limited Page 7 of 28
EMPOWERING HEALTH
InterBase Backup & Restore Steps
InterBase Backup
Search for existing .ibk files
Existing BAK files may cause some confusion when restoring databases. Therefore, we
recommend that you search for the existence of a file before proceeding.
Open IB Console
For InterBase XE
On the server, go to Start ► Programs ► Embarcadero InterBase XE [Instance =
MedTech_IB11 ► IBConsole.
For InterBase XE7
On the server, go to Start ► Programs ► Embarcadero InterBase XE7 [Instance =
MedTech_IBXE7 ► IBConsole.
For a 64-bit environment, launch the IBConsole from:
C:\Embarcadero\InterBase2011MedTech\bin\IBConsole.exe
Go to the InterBase Server, right-click and select ‘Add’.
Page 8
© Copyright Medtech Limited Page 8 of 28
EMPOWERING HEALTH
Click the ‘Browse network’ button to locate the Medtech Server computer on the
entire network.
Page 9
© Copyright Medtech Limited Page 9 of 28
EMPOWERING HEALTH
In the Specify the instance name field type in ‘MedTech_IB11’ and click ‘Next’.
The following screen will be displayed. Enter the password as ‘masterkey’ and click
‘Next’.
Page 10
© Copyright Medtech Limited Page 10 of 28
EMPOWERING HEALTH
The following screen will be displayed. You can enter a description for the server
(optional). Click the ‘Finish’ button.
The InterBase Server will now be displayed in the IB console.
Page 11
© Copyright Medtech Limited Page 11 of 28
EMPOWERING HEALTH
Login to the InterBase Server
Right-click on the server and select ‘Login’.
Enter the User Name ‘SYSDBA’ and the password ‘masterkey’ then click the
‘Login’ button.
Register Databases
Click on the plus (+) sign to the left of server to view the additional options.
Right-click on ‘Database’ and select ‘Add’.
Page 12
© Copyright Medtech Limited Page 12 of 28
EMPOWERING HEALTH
Enter the path to the MT32\Data directory:
C:\MT32\Data\MT32.IB.
NOTE: the Medtech32 databases will be listed under the Server/Databases menu once you
register the databases.
The name of the selected database will be displayed automatically within the ‘Alias’ field.
Click ‘OK’.
NOTE: repeat the process outlined above to register all the databases included within the
MT32\Data folder; for example, the ‘Training’ and ‘Blob’ databases.
Page 13
© Copyright Medtech Limited Page 13 of 28
EMPOWERING HEALTH
InterBase Backup Steps using IBConsole
Select the Backup option
Select Database ► Maintenance ►Backup/Restore ► Backup.
Define the Backup Information
This screen defines the path where the backup file will be saved to.
Database Section: the database ‘Alias’ should default the selected database; for example,
MT32.ib.
Backup Files Section: the server should default to ‘Server name -MedTech_IB11’.
Within the Alias field enter the name of the backup file (e.g. MT32.ibk) and within the File Name
field enter the path for the backup file (e.g. C:\MT32\DATA\MT32.ibk).
Page 14
© Copyright Medtech Limited Page 14 of 28
EMPOWERING HEALTH
Ensure the following recommended options are set for each property.
Property Recommended
Value
Format Transportable
Metadata Only False
Garbage Collection True
Transactions in Limbo Process
Checksums Process
Convert to Tables False
Verbose Output To Screen
Preallocated Pages 0
Click the ‘OK’ button.
Wait for the backup to complete.
This may take several hours.
Page 15
© Copyright Medtech Limited Page 15 of 28
EMPOWERING HEALTH
When the ‘Database Backup Completed’ prompt appears, click ‘OK’.
NOTE: if an error is displayed at the end of the process, DO NOT proceed any further. Please
contact Medtech Support [details at end of document].
InterBase Restore Steps using IBConsole
WARNING: ensure that you are disconnected from the database before performing the
Restore.
NOTE: the Restore option may take longer than the Backup option – in some instances, the
restore process could take twice as long. Restore must be performed for all databases
registered; e.g. MT32.ib, Blob.ib, Training.ib.
Page 16
© Copyright Medtech Limited Page 16 of 28
EMPOWERING HEALTH
Select the Restore Option
Select Database ► Maintenance ►Backup/Restore ► Restore.
Define the Restore Information
This screen defines where the data will be restored to.
Backup File Section: within the Alias drop down menu, select the File menu.
Click on the button and specify the Additional file when prompted. Enter the default path
where MT32.ibk is stored.
Page 17
© Copyright Medtech Limited Page 17 of 28
EMPOWERING HEALTH
Click ‘OK’ and the filename will be displayed in the Files section, as shown below:
Database Section: the Database Server should default to Servername- MedTech_IB2011 and
the Database Alias should default to MT32. The filename should default to the data directory
of Medtech32: C:\MT32\Data\Mt32.IB
Ensure the following recommended options are set for each property.
Property Recommended
Value
Page Size 4096 (keep the default)
Overwrite True
Commit After Each Table False
Create Shadow Files False
Deactivate Indices False
Validity Conditions Restore
Use All Space False
Verbose Output To Screen
Validation Check True
Preallocate Pages 0
SEP <Blank>
Decrypt Password <Blank>
EUA Username <Blank>
EUA Password <Blank>
Override Write Mode No
Page 18
© Copyright Medtech Limited Page 18 of 28
EMPOWERING HEALTH
Click ‘OK’. The following screen should be displayed:
Wait for the restore to complete.
This may take several hours.
When the ‘Database Restore Completed’ prompt appears, click ‘OK’.
Page 19
© Copyright Medtech Limited Page 19 of 28
EMPOWERING HEALTH
NOTE: if there is any Index page corruption observed in the Backup file, the Restore process will
fail to restore and will display the error shown below. Contact Medtech Support to correct the
duplicates [details at end of document].
Page 20
© Copyright Medtech Limited Page 20 of 28
EMPOWERING HEALTH
InterBase Backup using Batch Script
Use the following batch script to perform the InterBase Backup with all recommended
switches.
1. Copy the script below and save it in a file with (.bat) extension.
2. Use this batch script to automate the daily InterBase backup.
3. Input for all variables appropriate to the practice environment. Input variables are marked
in RED.
@ECHO OFF
REM Scrip to Backup Medtech Database on InterBase XE/XE3/XE7 Update 5
REM “Input all required variables.”
SET IB_InstallationPath="C:\Program Files\Embarcadero\InterBase\bin"
SET IB_UserName= SYSDBA
SET IB_Password= masterkey
SET IB_Data_File_path="192.168.2.35/MedTech_IBXE7:D:\MT32\data\MT32.ib"
SET IB_BLOB_File_path="192.168.2.35/MedTech_IBXE7:D:\MT32\data\BLOB.ib"
SET IB_Data_Backup_File_Path="D:\MT32\data\MT32.ibk"
SET IB_BLOB_Backup_File_Path="D:\MT32\data\BLOB.ibk" SET IB_Data_Logpath="D:\MT32\data\MT32_01.LOG"
SET IB_BLOB_Logpath="D:\MT32\data\BLOB_01.LOG"
REM “All Inputs ends here.”
IF EXIST %IB_Data_Logpath% ERASE %IB_Data_Logpath%
IF EXIST %IB_BLOB_Logpath% ERASE %IB_BLOB_Logpath%
PUSHD %IB_InstallationPath%
echo "Backup started for Medtech InterBase Data File"
gbak.exe -b -g -ig -user %IB_UserName% -password %IB_Password%
%IB_Data_File_path% %IB_Data_Backup_File_Path% -v -y %IB_Data_Logpath%
echo "Backup Completed for Medtech InterBase Data File"
echo "Backup started for Medtech InterBase BLOB File"
gbak.exe -b -g -ig -user %IB_UserName% -password %IB_Password%
%IB_BLOB_File_path% %IB_BLOB_Backup_File_Path% -v -y %IB_BLOB_Logpath%
echo "Backup Completed for Medtech InterBase BLOB File" echo press enter
to exit pause
>null exit
Page 21
© Copyright Medtech Limited Page 21 of 28
EMPOWERING HEALTH
InterBase Restore using Batch Script
Use the following batch script to perform the InterBase Restore with all recommended switches.
1. Copy the script below and save it in a file with (.bat) extension.
2. Use this batch script to automate the InterBase Restore.
3. Input for all variables appropriate to the practice environment. Input variables are marked
in RED.
@ECHO OFF
REM Scrip to Restore Medtech Database on InterBase XE/XE3/XE7 Update 5 REM “Input
all required variables.”
SET IB_InstallationPath="C:\Program Files\Embarcadero\InterBase\bin"
SET IB_UserName= SYSDBA
SET IB_Password= masterkey
SET IB_Data_Backup_File_Path="D:\MT32\data\MT32.ibk"
SET IB_BLOB_Backup_File_Path="D:\MT32\data\BLOB.ibk"
SET IB_Data_Restore_File_path="192.168.2.35/MedTech_IBXE7:D:\MT32\data\MT32.ib"
SET IB_BLOB_Restore_File_path="192.168.2.35/MedTech_IBXE7:D:\MT32\data\BLOB.ib"
SET IB_Data_Logpath="D:\MT32\data\MT32_01.LOG"
SET IB_BLOB_Logpath="D:\MT32\data\BLOB_01.LOG"
REM “All Inputs ends here.”
IF EXIST %IB_Data_Logpath% ERASE %IB_Data_Logpath%
IF EXIST %IB_BLOB_Logpath% ERASE %IB_BLOB_Logpath%
REM Specify InterBase Installation Path
REM Example - PUSHD "C:\Embarcadero\InterBase2011-Medtech\bin"
PUSHD %IB_InstallationPath%
echo "Restore started for Medtech InterBase Data File"
gbak.exe -r -va -user %IB_UserName% -
password %IB_Password%
%IB_Data_Backup_File_Path% %IB_Data_Restore_File_path% -v -y %IB_Data_Logpath%
echo "Restore Completed for Medtech InterBase Data File"
echo "Restore started for Medtech InterBase BLOB File"
gbak.exe -r -va -user %IB_UserName% -password %IB_Password%
%IB_BLOB_Backup_File_Path% %IB_BLOB_Restore_File_path% -v -y %IB_BLOB_Logpath%
echo "Restore Completed for Medtech InterBase BLOB File"
echo press enter to
exit pause >null exit
Database Daily Check
Run the following command on a daily basis to ensure all databases are in a healthier state
using command prompt:
"C:\Embarcadero\InterBase2011-MedTech\bin\gfix.exe" -v -full -user SYSDBA -password
masterkey
"MT-WIN7-240/Medtech_IB11:C:\MT32\Data\MT32.ib"
Ensure there are no errors.
Page 22
© Copyright Medtech Limited Page 22 of 28
EMPOWERING HEALTH
InterBase Database Backup & Restore
Intervals
The Backup & Restore process is vital to the health of the Medtech database. With normal
usage, over time the database starts to accumulate garbage, which can have an impact on
performance and can ultimately lead to database corruption.
How much garbage is accumulated depends on a number of factors, such as the number of
new entries and changes being made each day. It is difficult to give a precise estimate but as
a rule of thumb, a recommended minimum schedule is shown below:
Database Size (MT32 &
BLOB) Backup Frequency Restore Frequency
Under 5GB
Daily
Quarterly
5–10GB Every 6- to 8-weeks
10–50GB Monthly
Over 50GB Every 2 weeks
NOTE:
Daily backup of the InterBase Database is important to avoid data loss.
At a minimum, maintain one week of daily backups for data recovery support.
Ensure that there are no active connections on the InterBase Database during daily
backup and scheduled Backup & Restore.
Benefits of InterBase Backup & Restore
Proactive Detection of Data Corruption – performing daily database backups results in
early detection of any database corruption.
Indices Rebuild – by default, InterBase Restore performs the fresh creation of Indices in all
tables and solves the data fragmentation, resulting in better data read performance.
Garbage Collections–Full Sweep – by default, InterBase Restore eliminates the
obsolete/orphan record versions in Database files and results in the reclaiming of space
occupied by old versions of transactions.
Defragmentation of Database Pages – over time, data stored in InterBase database files
becomes fragmented. Performing Restore stores and sorts the data page sequentially,
resulting in good data read performance.
Page 23
© Copyright Medtech Limited Page 23 of 28
EMPOWERING HEALTH
On-Demand InterBase Restore
Using the Difference between Oldest Active and Next Transaction
By design, InterBase maintains a unique reference for each Read/Write request to the
InterBase database called Transactions. For a busy database, verify the difference between
the oldest active and next transaction. If the difference exceeds 2000, then On-Demand
Backup & Restore is required.
Perform the following steps by connecting to the InterBase database in IBConsole to verify the
Transactions details.
1. Login to the IBConsole and select the desired database.
2. Double-click the Database Statistics option from the right pane of IBConsole and select
Header Page from the drop down menu in the Show data for field (see below).
3. Click ‘OK’ to see the header information for the specific database.
Page 24
© Copyright Medtech Limited Page 24 of 28
EMPOWERING HEALTH
NOTE:
Check the difference between Oldest Active transaction and Next transaction. Where the
difference is >2000, an InterBase Database Restore needs to be initiated (separate from
any scheduled Backup & Restore).
This check should be done on a daily basis.
Using Daily GFIX Analysis
Run the above GFIX for each Medtech InterBase Database on a daily basis.
1. Run GFIX with –v –Full; a healthy database is expected to return no errors at the Record
Level and Database Page Level; i.e. a blank space.
2. Run GFIX with –mend –ig; a healthy database is expected to return no errors at the Record
Level and Database Page Level; i.e. a blank space.
3. If the above commands return any errors, initiate the On-Demand Backup & Restore
(separate from any scheduled Backup & Restore).
Page 25
© Copyright Medtech Limited Page 25 of 28
EMPOWERING HEALTH
Steps to verify Primary Key Index Corruption
The following steps need to be performed in sequence to make sure the MT32 and BLOB
databases are Index Corruption free.
It is a known issue on InterBase 2009 and lower that there is a high possibility of indexes
becoming corrupted and a high chance of duplicate keys get populated for primary indexes.
Outlined below are the steps to follow before upgrading to InterBase XE Update.
http://www.medtechglobal.com/wp-content/uploads/2014/02/Medtech32-Interbase-XE7-
Update5-Installer-Guide-v1.0.pdf
NOTE: The following steps MUST be executed by Medtech Certified Engineers during non-
production hours.
Identify List of Corrupted Indexes
Run GFIX command against the MT32 and BLOB Database.
Once the above command is executed, InterBase.log gives the list of index names. If there are
any corrupted indexes, do a Backup & Restore on the existing InterBase version to rebuild
indexes to clear the Index corruption.
Identify List of Primary Indexes has duplicate keys
Prerequisites
Download and install IBExpert from IBExpert download centre (Google IBExpert Download
centre).
1. Register MT32.IB Database under Database Explorer.
Page 26
© Copyright Medtech Limited Page 26 of 28
EMPOWERING HEALTH
2. Click ‘New SQL Editor’ as highlighted in the screenshot below:
3. Execute the following script in SQL Editor.
CSTRING(80)
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';
4. Press F9 to execute and Ctrl+Alt+C to commit.
5. Execute the following script in SQL Editor.
create procedure findduplicatesql returns (thesql varchar(400)) as declare variable
index_name varchar(67); declare variable relation_name varchar(67); declare variable
field_name varchar(67); declare variable fieldlist varchar (300); declare variable
fieldcount integer; begin
/*get index names of all unique indexes for all user tables*/ for select
rtrim(rdb$index_name), rtrim(rdb$relation_name) from rdb$indices a, rdb$relations b
where RDB$UNIQUE_FLAG=1 and a.rdb$relation_name=b.rdb$relation_name and
b.rdb$system_flag<>1 into :index_name, :relation_name do begin
fieldlist = '';
fieldcount = 0;
/*get fieldnames for index*/ for select rtrim(rdb$field_name) from rdb$index_segments
where rdb$index_name=:index_name into field_name do begin fieldcount = fieldcount
+ 1; if (fieldcount>1) then fieldlist = fieldlist || ' ,'; fieldlist = fieldlist || field_name; end
thesql = 'select "' || :relation_name ||'" TableName, count(*),' || fieldlist || ' from '
|| :relation_name || ' group by ' || fieldlist || ' having count(*)>1;'; suspend; end end;
6. Press F9 to execute and press Ctrl+Alt+C to commit.
7. To confirm, please verify “findduplicatesql” is available under procedures.
Page 27
© Copyright Medtech Limited Page 27 of 28
EMPOWERING HEALTH
8. Run the following script and press F9 to execute.
Select * from findduplicatesql
9. Wait for results to be populated under Results tab. Right-click on the Results tab to copy
the content to Clipboard.
Page 28
© Copyright Medtech Limited Page 28 of 28
EMPOWERING HEALTH
10. Press Ctrl + F12 to open Script Executive
OUTPUT 'C:\Duplicate.csv' DELIMITER ';'
FIELDNAMES
QUOTECHAR '"'
DECIMALSEPARATOR '.';
<Paste copied text here>
OUTPUT;
11. Remove the keyword ‘THESQL’ while pasting the scripts. The scripts will be ready to execute
as shown below:
12. Press F9 to execute the scripts.
13. Based on database size and hardware, the script execution time varies; e.g. for 50GB
database, execution time might be 4 hours to complete on standard hardware.
14. Look for C:\Duplicate.csv; if the file is empty, the database is good to restore on InterBase
XE7 Update 5. If the file has content, please contact Medtech Support to correct the
Duplicates before upgrading to InterBase XE7 Update 5 (this will be a chargeable
exercise).
15. Save C:\Duplicate.csv for future reference.
For further information, or if you require assistance with updating InterBase, please contact
Medtech Support via:
Medtech32 application [Help ► Contact Support]
Email: [email protected]
Phone: 0800 2 MEDTECH (633 832)