A API do firedac traz um componente que encapsula o nbackup do firebird o que facilita
personalizar o controle de backups. TFDFBNBackup.
Exemplo Nivel 1:
TNBackup.ExecuteNBackup(‘localhost’,’c:\dados\meubanco.fdb’,’sysdba’,’masterkey’,1,’c:\backup\b
ackup2.nbk’);
- Segestão de como utilizar NIVEL (level):
a) fazer backup FULL Nivel 0 para um intervalo de período (semanal);
b) fazer backup Nivel 1, diário;
c) fazer backup Nivel 2 para backup a cada hora.
Código base:
uses FireDAC.Phys.IBWrapper,FireDAC.Phys.FB,FireDAC.Phys.FBDef,FireDAC.Comp.UI,FireDAC.Phys; type TNBackup = record private class function GetNBackup(AHost, ABanco, AUser, APass: string; ANivel: integer; ADestino: String): TFDFBNBackup;static; class function ExecuteNBackup(AHost, ABanco, AUser, APass: string; ANivel: integer; ADestino: String): boolean;static; end; class function TNBackup.ExecuteNBackup(AHost, ABanco, AUser, APass: string; ANivel: integer; ADestino: String): boolean; begin result := false; with TNBackup.GetNBackup(Ahost,ABanco,AUser,APass,ANivel,ADestino) do try Backup; // gerar backup. result := true; finally free; end; end; class function TNBackup.GetNBackup(AHost, ABanco, AUser, APass: string; ANivel: integer; ADestino: String): TFDFBNBackup; var nBackup:TFDFBNBackup; FDGUIxWaitCursorX: TFDGUIxWaitCursor; FDPhysFBDriverLinkX: TFDPhysFBDriverLink; begin result:=TFDFBNBackup.create(nil); try FDGUIxWaitCursorX:= TFDGUIxWaitCursor.Create(result); FDPhysFBDriverLinkX:= TFDPhysFBDriverLink.Create(result); with result do begin Level := ANivel; host := AHost; username := AUser; password := APass; protocol := ipTCPIP; Database := ABanco; backupfile := ADestino; DriverLink := FDPhysFBDriverLinkX; end; finally // liberar a instancia no metodo chamador end; end;