Backup / restore using UniDump
Backup / restore using UniDump
Any samples available that show how to use UniDump to restore from a file created by UniDump?
I can get the backup process to run and create a file on my disk containing a SQL script.
But restoring I can't figure out how to do.
And the sample in the demo provided with UniDAC is not helping me much.
I can get the backup process to run and create a file on my disk containing a SQL script.
But restoring I can't figure out how to do.
And the sample in the demo provided with UniDAC is not helping me much.
-
AndreyZ
Hello,
Here is an example of backing up a table to a file:And here is an example of restoring from backup file:For more information, please read the UniDAC documentation.
Here is an example of backing up a table to a file:
Code: Select all
UniDump.TableNames := 'table_name';
UniDump.BackupToFile('backup_file_name');Code: Select all
UniDump.RestoreFromFile('backup_file_name');My restore
procedure TfrmDBRestore.RestoreRun(aFilename: string);
begin
barProgress.Visible := True;
barProgress.Position := 0;
try
UniDump.RestoreFromFile(aFilename);
finally
barProgress.Visible := False;
end;
end;
My backup
procedure TfrmDBBackup.BackupRun;
begin
barProgress.Position := 0;
barProgress.Visible := True;
try
UniDump.BackupToFile(FilenameBuild);
finally
barProgress.Visible := False;
end;
end;
(FilenameBuild returns a filname formated yyyymmddhhnn)
The backup runs OK - it creates a file but the restore won't read the fil again. I get no errormessages at all.
The documentation is not to much help in this case.
procedure TfrmDBRestore.RestoreRun(aFilename: string);
begin
barProgress.Visible := True;
barProgress.Position := 0;
try
UniDump.RestoreFromFile(aFilename);
finally
barProgress.Visible := False;
end;
end;
My backup
procedure TfrmDBBackup.BackupRun;
begin
barProgress.Position := 0;
barProgress.Visible := True;
try
UniDump.BackupToFile(FilenameBuild);
finally
barProgress.Visible := False;
end;
end;
(FilenameBuild returns a filname formated yyyymmddhhnn)
The backup runs OK - it creates a file but the restore won't read the fil again. I get no errormessages at all.
The documentation is not to much help in this case.
-
AndreyZ
-
AndreyZ
-
AndreyZ
-
AndreyZ
I think it can have to do with this
http://stackoverflow.com/questions/6250 ... cess-query
-INSERT INTO needs to be on each line with values
http://stackoverflow.com/questions/6250 ... cess-query
-INSERT INTO needs to be on each line with values
-
AndreyZ
To make TUniDump component generate an INSERT statement for each row, you should set the UseExtSyntax specific option to False in the following way:
Code: Select all
UniDump.SpecificOptions.Values['UseExtSyntax'] := 'False';OK that did most of the trick.
I had to remove the headers as well.
UniDump.Options.GenerateHeader := False;
But the worst part is that I have to drop
UniDump.Options.AddDrop := False;
since Access doesn't understand TRUNCATE
(SQLite doesn't understand that either)
I have been searchin the chm and pdf doc I have for UniDump.SpecificOptions but can't locate them - are there any further documentation that I can access to get info about this?
I am especially looking for a way to avoid the errormessage when restoring a record that violates key - it is a lot of pressing OK.
And by the way if there is data with ' (e.g. Bill's that is backed up to Bill\s) it gives a constraint error on restore.
I had to remove the headers as well.
UniDump.Options.GenerateHeader := False;
But the worst part is that I have to drop
UniDump.Options.AddDrop := False;
since Access doesn't understand TRUNCATE
I have been searchin the chm and pdf doc I have for UniDump.SpecificOptions but can't locate them - are there any further documentation that I can access to get info about this?
I am especially looking for a way to avoid the errormessage when restoring a record that violates key - it is a lot of pressing OK.
And by the way if there is data with ' (e.g. Bill's that is backed up to Bill\s) it gives a constraint error on restore.
-
AndreyZ
You can find the information about MySQL specific options in the "Using UniDAC with MySQL" article of the UniDAC documentation.
To avoid error messages during execution, you can use the OnError event handler in the following way:In this case you won't see error messages about duplicate key values (when you run your application not from IDE).
Please note that the TUniDump component isn't not designed to create backup files for one database server and restore them to another database server.
To avoid error messages during execution, you can use the OnError event handler in the following way:
Code: Select all
procedure TForm1.UniDump1Error(Sender: TObject; E: Exception; SQL: String;
var Action: TErrorAction);
begin
if (EUniError(E).ErrorCode = 1062) then // ER_DUP_ENTRY
Action := eaContinue;
end;Please note that the TUniDump component isn't not designed to create backup files for one database server and restore them to another database server.