Subject Re: [IBO] Firebird Backup and Restore
Author niegil_firebirddev
Hi Alan ,

I tried with ur code but found the same error . Is it that IBOAdmin
works with only FB1.5 because in IBOAdmins code i notice it checks
for a FB1.5 login . I have to actually backup and restore a Firebird
2.0 database . Should i go for NBackupTool ..


Tks & Regards

Niegil Thomas

--- In IBObjects@yahoogroups.com, "Alan McDonald" <alan@...> wrote:
>
> > Hi All,
> >
> > My new requirement is that i have to programitically backup my
firebird
> > database . I tried using IBOAdmin's backup service but found that
it
> > shows a error that Interbase client gds32.dll not not found in
the path.
> > Can any one suggest a best option for backup and restore a
database
> > file ..........
> >
> > If possible by with some code example
> >
> >
> > Regards
> >
> > Niegil Thomas
>
> I think they call this cross-posting and you are asked to not do
it. Post
> one message on one forum at a atime please.
> You might get the drift of this code.
> Alan
>
> procedure TMain.acnBackupExecute(Sender: TObject);
> var
> sBackupName: String;
> SearchFile: TSearchRec;
> BackupPath: String[79];
> iBackups: Integer;
> begin
> {#ToDo1 Check file count and warn past a certain number}
> iBackups := 0;
> BackupPath := ExcludeTrailingPathDelimiter(srBackupDir)+'\*.fbk';
> kbmMemTableFileList.Open;
> kbmMemTableFileList.EmptyTable;
> if FindFirst(BackupPath, faArchive, SearchFile)=0 then
> repeat
> inc(iBackups);
> kbmMemTableFileList.Insert;
> kbmMemTableFileList.FieldByName('FileDate').AsDateTime :=
> SearchFile.Time;
> kbmMemTableFileList.FieldByName('FileName').AsString :=
SearchFile.Name;
> until FindNext(SearchFile)<>0;
> FindClose(SearchFile);
> if not brIgnoreBUCount then begin
> kbmMemTableFileList.SortOn('FileDate', []);
> kbmMemTableFileList.First;
> while iBackups>=riBackupCount do begin
> DeleteFile(ExcludeTrailingPathDelimiter(srBackupDir)
+'\'+kbmMemTableFi
> leList.FieldByName('FileName').AsString);
> DeleteFile(ChangeFileExt(ExcludeTrailingPathDelimiter
(srBackupDir)+'\'
> +kbmMemTableFileList.FieldByName('FileName').AsString,'.log'));
> kbmMemTableFileList.Delete;
> kbmMemTableFileList.Next;
> Dec(iBackups);
> end;
> end;
> StatusBar.Panels[0].Text := 'Backing up application database';
> sBackupName := CreateBackupName;
> if not DirectoryExists(srBackupDir) then begin
> end;
> fBackupName := ExcludeTrailingPathDelimiter(srBackupDir)+'\acsaa'+
> sBackupName + '.fbk';
> brBackupVerbose := True;
> if (brBackupVerbose and (dlgVerbose=nil)) then begin
> dlgVerbose := TdlgVerbose.Create(self);
> dlgVerbose.Caption := 'Backup Database';
> dlgVerbose.Memo1.Lines.Clear;
> end;
> with IBOBackupService1 do begin
> BackupFile.Clear;
> Params.Clear;
> Params.Add('user_name=' + dmLocalStore.IB_Connection1.Username);
> Params.Add('password=' + dmLocalStore.IB_Connection1.Password);
> try
> Verbose := brBackupVerbose;
> Options := [];
>
> LoginPrompt := false;
> ServerName := '';
> DatabaseName := dmLocalStore.IB_Connection1.Path;
> Protocol := cpLocal;
>
> BackupFile.Add(fBackupName);
> Active := True;
> Screen.Cursor := crHourGlass;
> ServiceStart;
> if (brBackupVerbose and (dlgVerbose<>nil)) then begin
> while not eof do begin
> Application.ProcessMessages;
> Screen.Cursor := crHourGlass;
> dlgVerbose.Memo1.Lines.Add(GetNextLine);
> dlgVerbose.Memo1.Update;
> end;
> dlgVerbose.Memo1.Lines.Add('Backup file - ' + fBackupName);
> dlgVerbose.Memo1.Lines.Add('Backup complete...');
> dlgVerbose.WriteLog (ExcludeTrailingPathDelimiter
(srBackupDir) +
> '\acsaa' + sBackupName + '.log');
> end;
> finally
> Active := False;
> screen.cursor := crdefault;
> end;
> end;
> StatusBar.Panels[0].Text := 'Backup complete';
> msgbBackupFinished := True;
> end;
>