Merhaba,
Yedekleme ile ilgili forumda yaptığım aramada;
backup:
procedure TFrm_Yedekleme.Btn_YedekleClick(Sender: TObject);
var
gun, ay, yil : Word;
gun_ay_yil : string;
begin
DecodeDate(Date, yil, ay, gun);
gun_ay_yil := IntToStr(gun) + '_' + IntToStr(ay) + '_' + IntToStr(yil);
Memo1.Lines.Clear;
// fmSqlMonitor.btClearClick(nil);
with IBBackupService1 do begin
Active := True;
Screen.Cursor := crHourGlass;
try
// CloseAllTables;
DatabaseName := DM.IBDatabase1.DatabaseName;
BackupFile.Clear;
BackupFile.Add(ExtractFilePath(Application.ExeName) + '\Yedek\PERSONEL_' + gun_ay_yil +'.gbk');
ServiceStart;
While not Eof do
Memo1.Lines.Add(GetNextLine);
MessageDlg('Yedekleme başarıyla tamamlandı!', mtInformation, [mbOK], 0);
finally
Active := False;
// OpenAllTables;
Screen.Cursor := crDefault;
end;
end;
end;
Yedekleme yaptım ise de, Restore yapamadım.
Yardımcı olabilirmisiniz.
Teşekkürler.
Data'ları Yedekleme
IBBackupService bileşenine ait Width bloğunda yapılan bir işlem olduğuna göre yedek alma işini bu bileşen yapıyor... Yani bir de RestoreService olacak...
- Ankara dışında olduğumdan deneyerek bir kod yazamıyorum ama yardımcı olacağını değerlendirdiğim google'da yaptığım arama sonucu bulduğum sonucu buradan copy/paste yapıyorum...
- Not : Sen de yukarda göreceğin code webbuttonu yardımı ile kodlarını buradan yazarsan aşağıdakiş gibi düzgün görünür, bizler de kolaylıkla analiz edebiliriz...
- Ankara dışında olduğumdan deneyerek bir kod yazamıyorum ama yardımcı olacağını değerlendirdiğim google'da yaptığım arama sonucu bulduğum sonucu buradan copy/paste yapıyorum...
- Not : Sen de yukarda göreceğin code webbuttonu yardımı ile kodlarını buradan yazarsan aşağıdakiş gibi düzgün görünür, bizler de kolaylıkla analiz edebiliriz...
Kod: Tümünü seç
(These examples has been taken from the " TIBBackupService.Options" and
"TIBrestoreService.Options" topics of the InterBase Express Help of Delphi
6.0):
TIBBackupService:
=============
This example shows a component that backs up a database with the click of a
button. The second example shows how to back up a database to multiple
files.
procedure TForm1.Button1Click(Sender: TObject);
begin
with IBBackupService1 do
begin
// You have to define the IBBackupService1.ServerName property if the
IBBackup.Protocol is not Local
ServerName := 'Poulet';
LoginPrompt := False;
Params.Add('user_name=sysdba');
Params.Add('password=masterkey');
Active := True;
try
Verbose := True;
Options := [NonTransportable, IgnoreLimbo];
DatabaseName := 'c:\interbase\examples\database\employee.gdb'
;
BackupFile.Add('c:\temp\employee1.gbk');
ServiceStart;
While not Eof do
Memo1.Lines.Add(GetNextLine);
finally
Active := False;
end;
end;
end;
To back up a database to multiple files:
==========================
procedure TForm1.Button2Click(Sender: TObject);
begin
with IBBackupService1 do
begin
ServerName := 'Poulet';
LoginPrompt := False;
Params.Add('user_name=sysdba');
Params.Add('password=masterkey');
Active := True;
try
Verbose := True;
Options := [MetadataOnly, NoGarbageCollection];
DatabaseName := 'c:\interbase\examples\database\employee.gdb';
BackupFile.Add('c:\temp\e1.gbk = 2048');
BackupFile.Add('c:\temp\e2.gbk' = 4096);
BackupFile.Add('c:\temp\e3.gbk'); ServiceStart;
While not Eof do
Memo1.Lines.Add(GetNextLine);
finally
Active := False;
end;
end;
end;
TIBRestoreService:
============
This example shows how to set up a component that restores a database with
the click of a button. The second example shows how to restore a database
from multiple files.
procedure TForm1.Button1Click(Sender: TObject);
begin
with IBRestoreService1 do
begin
// You have to setup the IBRestoreService1.ServerName property if the
IBRestoreService1.Protocol is not Local
ServerName := 'Poulet';
LoginPrompt := False;
Params.Add('user_name=sysdba');
Params.Add('password=masterkey');
Active := True;
try
Verbose := True;
Options := [Replace, UseAllSpace];
PageBuffers := 3000;
PageSize := 4096;
DatabaseName.Add('c:\interbase\tutorial\tutorial.gdb');
BackupFile.Add('c:\interbase\tutorial\backups\tutor5.gbk');
ServiceStart;
Whilenot Eof do
Memo1.Lines.Add(GetNextLine);
finally
Active := False;
end;
end;
end;
To restore a database from multiple files:
==========================
procedure TForm1.Button3Click(Sender: TObject);
begin
with IBRestoreService1 do
begin
ServerName := 'Poulet';
LoginPrompt := False;
Params.Add('user_name=sysdba');
Params.Add('password=masterkey');
Active := True;
try
Verbose := True;
Options := [Replace, UseAllSpace];
PageBuffers := 3000;
PageSize := 4096;
BackupFile.Add('c:\temp\e1.gbk');
BackupFile.Add('c:\temp\e2.gbk');
BackupFile.Add('c:\temp\e3.gbk');
DatabaseName.Add('c:\interbase\examples\database\employee.gdb');
ServiceStart;
Whilenot Eof do
Memo1.Lines.Add(GetNextLine);
finally
Active := False;
end;
end;
end;
==============================