TFBAdmin
English · Français
TFBAdmin
is a component that aids in Interbase/Firebird administration tasks. It can be found on the SQLdb tab of the Component Palette and resides in the FBAdmin unit. It provides the following functionality:
- add, modify or delete database users
- backup and restore databases using single or multiple (split) files
- get general database information
- get the database log file listing important database events and errors
There is also a Lazarus component and demo that allows use of the FPC TFBAdmin component.
Example
This shows how to create a multi file backup of a database on a Linux server; 3 backup files, size limited to 600MB; backup progress shown in a TMemo:
procedure TForm1.logadm(Sender: TObject; msg: string; IBAdminAction: string);
begin
Memo1.Lines.add(IBAdminAction+' : '+msg);
end;
procedure TForm1.backup;
var
Admin:TFBAdmin;
sl:TStringList;
begin
Admin:=TFBAdmin.Create(self);
sl:=TStringList.create;
try
Admin.UseExceptions:=true;
Admin.Host:='192.168.2.98';
Admin.Protocol:=IBSPTCPIP;
Admin.User:='sysdba';
Admin.Password:='masterkey';
Admin.Port:= 3050; //change if not using the default port
Admin.Connect;
Admin.OnOutput:=@logadm;
sl.Add('/home/firebird/test.bak1');
sl.Add('/home/firebird/test.bak2');
sl.Add('/home/firebird/test.bak3');
Admin.BackupMultiFile('/home/firebird/test.fdb',sl,600000000,[IBBkpVerbose]);
finally
sl.Destroy;
Admin.Destroy; //disconnects automatically
end;
end;A demo program is also available in the examples directory of the fcl-db package.
The following example shows how to backup to and restore from a single file on a Windows-server:
uses
FBAdmin;
procedure TForm1.logadm(Sender: TObject; msg: string; IBAdminAction: string);
begin
Memo1.Lines.add(IBAdminAction + ' : ' + msg);
end;
procedure Backup(Database, Backupfile: string);
var
Admin: TFBAdmin;
begin
Admin := TFBAdmin.Create(nil);
try
Admin.UseExceptions := True;
Admin.Host := '192.168.1.66';
Admin.Protocol := IBSPTCPIP;
Admin.User := 'SYSDBA';
Admin.Password := 'masterkey';
Admin.Port := 3050; //change if not using the default port
Admin.Connect;
Admin.OnOutput := @Form1.logadm;
Admin.Backup(Database, Backupfile, [IBBkpVerbose]);
finally
Admin.Free; //disconnects automatically
end;
end;
procedure Restore(Database, Backupfile: string);
var
Admin: TFBAdmin;
begin
Admin := TFBAdmin.Create(nil);
try
Admin.UseExceptions := True;
Admin.Host := '192.168.1.66';
Admin.Protocol := IBSPTCPIP;
Admin.User := 'SYSDBA';
Admin.Password := 'masterkey';
Admin.Port := 3050; //change if not using the default port
Admin.Connect;
Admin.OnOutput := @Form1.logadm;
Admin.Restore(Database, Backupfile, [IBResVerbose, IBResReplace]);
finally
Admin.Free; //disconnects automatically
end;
end;
procedure TForm1.btBackupClick(Sender: TObject);
begin
Backup('c:\data\demo.fdb', 'c:\temp\demo.fbk');
end;
procedure TForm1.btRestoreClick(Sender: TObject);
begin
Restore('c:\data\demo_restored.fdb', 'c:\temp\demo.fbk');
end;See also
- Firebird Using Firebird with FPC/Lazarus sqldb.
From the Free Pascal wiki, page "TFBAdmin", as it stood on 2020-03-01 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
