Performing a daily backup of the IBExpert User Database
The following example demonstrates the usage of ibec_reg_xxx functions to perform a daily backup of the IBExpert User Database:
execute ibeblock as begin CurrentDate = ibec_Date(); reg = ibec_reg_Open(__HKEY_CURRENT_USER, 0); try if (ibec_reg_OpenKey(reg, 'Software\HK Software\IBExpert\CurrentData', FALSE)) then begin try UDBLastBackupDate = ibec_reg_ReadDate(reg, 'UDBLastBackupDate'); if (UDBLastBackupDate = CurrentDate) then Exit; except end; UDBConnectString = ibec_reg_ReadString(reg, 'UDBConnectString'); UDBClientLib = ibec_reg_ReadString(reg, 'UDBClientLib'); UDBUserName = ibec_reg_ReadString(reg, 'UDBUserName'); UDBPassword = ibec_reg_ReadString(reg, 'UDBPassword'); end finally ibec_reg_Close(reg); end; if ((UDBConnectString is null) or (UDBConnectString = ´´)) then Exit; ibec_Progress('Starting backup of IBExpert User Database...'); BackupDir = 'D:\Backups\IBExpert User Database\'; ibec_ForceDirectories(BackupDir); ibec_DecodeDate(CurrentDate, iYear, iMonth, iDay); BackupFileName = BackupDir || iDay || '-' || iMonth || '-' || iYear || '.fbk'; res = ibec_BackupDatabase(UDBConnectString, BackupFileName, 'ClientLib=' || UDBClientLib || '; Password=' || UDBPassword || '; User=' || UDBUserName, null); if (ibec_FileExists(BackupFileName)) then begin ibec_Progress('Compressing ' || BackupFileName || '...'); res = ibec_Exec('"C:\Program Files\WinRAR\rar.exe" a "' || BackupFileName || '.rar" "' || BackupFileName || '" -m5 -ri1', ´´, null); if (res = 0) then ibec_DeleteFile(BackupFileName); end if (res = 0) then begin reg = ibec_reg_Open(__HKEY_CURRENT_USER, 0); try if (ibec_reg_OpenKey(reg, 'Software\HK Software\IBExpert\CurrentData', FALSE)) then ibec_reg_WriteDate(reg, 'UDBLastBackupDate', CurrentDate); finally ibec_reg_Close(reg); end; end end
See also:
IBExpert User Database
back to top of page
<< RunMe.ibeblock | IBEBlock | Disable and enable IBExpert features >>