Page 1 of 2
Backup / restore using UniDump
Posted: Mon 13 Jun 2011 12:44
by oz8hp
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.
Posted: Tue 14 Jun 2011 13:44
by AndreyZ
Hello,
Here is an example of backing up a table to a file:
Code: Select all
UniDump.TableNames := 'table_name';
UniDump.BackupToFile('backup_file_name');
And here is an example of restoring from backup file:
Code: Select all
UniDump.RestoreFromFile('backup_file_name');
For more information, please read the UniDAC documentation.
Posted: Tue 14 Jun 2011 15:42
by oz8hp
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.
Posted: Wed 15 Jun 2011 07:23
by AndreyZ
Please specify the exact database server you are working with. Also you can send the backup file that UniDump cannot restore to andreyz*devart*com for investigation.
Posted: Wed 15 Jun 2011 08:07
by oz8hp
No problem
My SQLyog says it is MySQL 5.1.36
I have send you a file with the table spec and 3 files that I have backed up using UniDump with different options.
Posted: Wed 15 Jun 2011 10:48
by AndreyZ
I cannot reproduce the problem. All three backup files you sent me were correctly restored. Please specify the following:
- the exact version of UniDAC. You can see it in the About sheet of TUniConnection Editor;
- the exact version of your IDE.
Posted: Wed 15 Jun 2011 11:17
by oz8hp
UniDAC 3.70.0.17
Delphi XE
Posted: Wed 15 Jun 2011 15:43
by AndreyZ
I still cannot reproduce the problem. Please try composing a small sample to demonstrate the problem and send it to andreyz*devart*com.
Posted: Thu 16 Jun 2011 17:55
by oz8hp
Here in Denmark we also use the saying 'an error 45' (the error is 45 cm behind the keyboard'
It toke the name of the backup from a list of files I show in a TListView and I wasn't aware that the text was followed by an CRLF so when I added a Trim to the filename it is working.
I am sorry for this.
Posted: Fri 17 Jun 2011 06:49
by AndreyZ
It's good to see that you've found a solution. If any other questions come up, please contact us.
Posted: Sat 18 Jun 2011 11:26
by oz8hp
But are there any special options that needs to be set in order to Backup a MySQL database and restore it to a MS Access database?
That gives me errors
Posted: Sun 19 Jun 2011 17:16
by oz8hp
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
Posted: Mon 20 Jun 2011 07:24
by 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';
Posted: Mon 20 Jun 2011 07:57
by oz8hp
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.
Posted: Mon 20 Jun 2011 11:46
by 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:
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;
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.