Sign in Join
Wiki copytemporary

TFBAdmin: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TFBAdmin

OldNewLine
1+**TFBAdmin** ![](/wiki-images/8/84/Tfbadmin.png) 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:
2+
3+- add, modify or delete database users
4+- backup and restore databases using single or multiple (split) files
5+- get general database information
6+- get the database log file listing important database events and errors
7+
8+There is also a Lazarus component and demo that allows use of the FPC TFBAdmin component.
9+
10+## Example
11+
12+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:
13+
14+``` pascal
15+procedure TForm1.logadm(Sender: TObject; msg: string; IBAdminAction: string);
16+begin
17+ Memo1.Lines.add(IBAdminAction+' : '+msg);
18+end;
19+
20+procedure TForm1.backup;
21+var
22+ Admin:TFBAdmin;
23+ sl:TStringList;
24+begin
25+ Admin:=TFBAdmin.Create(self);
26+ sl:=TStringList.create;
27+ try
28+ Admin.UseExceptions:=true;
29+ Admin.Host:='192.168.2.98';
30+ Admin.Protocol:=IBSPTCPIP;
31+ Admin.User:='sysdba';
32+ Admin.Password:='masterkey';
33+ Admin.Port:= 3050; //change if not using the default port
34+ Admin.Connect;
35+ Admin.OnOutput:=@logadm;
36+ sl.Add('/home/firebird/test.bak1');
37+ sl.Add('/home/firebird/test.bak2');
38+ sl.Add('/home/firebird/test.bak3');
39+ Admin.BackupMultiFile('/home/firebird/test.fdb',sl,600000000,[IBBkpVerbose]);
40+ finally
41+ sl.Destroy;
42+ Admin.Destroy; //disconnects automatically
43+ end;
44+end;
45+```
46+
47+A demo program is also available in the examples directory of the fcl-db package.
48+
49+The following example shows how to backup to and restore from a single file on a Windows-server:
50+
51+``` pascal
52+uses
53+ FBAdmin;
54+
55+procedure TForm1.logadm(Sender: TObject; msg: string; IBAdminAction: string);
56+begin
57+ Memo1.Lines.add(IBAdminAction + ' : ' + msg);
58+end;
59+
60+procedure Backup(Database, Backupfile: string);
61+var
62+ Admin: TFBAdmin;
63+begin
64+ Admin := TFBAdmin.Create(nil);
65+ try
66+ Admin.UseExceptions := True;
67+ Admin.Host := '192.168.1.66';
68+ Admin.Protocol := IBSPTCPIP;
69+ Admin.User := 'SYSDBA';
70+ Admin.Password := 'masterkey';
71+ Admin.Port := 3050; //change if not using the default port
72+ Admin.Connect;
73+ Admin.OnOutput := @Form1.logadm;
74+ Admin.Backup(Database, Backupfile, [IBBkpVerbose]);
75+ finally
76+ Admin.Free; //disconnects automatically
77+ end;
78+end;
79+
80+procedure Restore(Database, Backupfile: string);
81+var
82+ Admin: TFBAdmin;
83+begin
84+ Admin := TFBAdmin.Create(nil);
85+ try
86+ Admin.UseExceptions := True;
87+ Admin.Host := '192.168.1.66';
88+ Admin.Protocol := IBSPTCPIP;
89+ Admin.User := 'SYSDBA';
90+ Admin.Password := 'masterkey';
91+ Admin.Port := 3050; //change if not using the default port
92+ Admin.Connect;
93+ Admin.OnOutput := @Form1.logadm;
94+ Admin.Restore(Database, Backupfile, [IBResVerbose, IBResReplace]);
95+ finally
96+ Admin.Free; //disconnects automatically
97+ end;
98+end;
99+
100+procedure TForm1.btBackupClick(Sender: TObject);
101+begin
102+ Backup('c:\data\demo.fdb', 'c:\temp\demo.fbk');
103+end;
104+
105+procedure TForm1.btRestoreClick(Sender: TObject);
106+begin
107+ Restore('c:\data\demo_restored.fdb', 'c:\temp\demo.fbk');
108+end;
109+```
110+
111+## See also
112+
113+- [[Firebird]] Using Firebird with FPC/Lazarus sqldb.
114+
115+---
116+*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](/wiki-contact).*

Back to history