Backup an entire database

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Backup an entire database

Post by ads42 » Tue 08 Jan 2013 14:19

Hi,
what is the simple way to back an entire database ?
The structure of the database may vary, and the name/number of tables also.
So table name or parameters should be retrieved automatically.

Same question for restoring the database.
Regards

Armindo

AndreyZ

Re: Backup an entire database

Post by AndreyZ » Wed 09 Jan 2013 12:55

Hello,

To create a full database backup, we suggest you to use the TMyDump component. TMyDump creates a SQL script that contains the structure of the tables and theirs data. Here is a code example of the TMyDump usage:
backup:

Code: Select all

MyDump1.BackupToFile('C:\backup.sql');
restore:

Code: Select all

MyDump1.RestoreFromFile('C:\backup.sql');
For more information about TMyDump, please refer to the MyDAC documentation.

ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Re: Backup an entire database

Post by ads42 » Thu 10 Jan 2013 10:05

Thanks Andrey.

AndreyZ

Re: Backup an entire database

Post by AndreyZ » Thu 10 Jan 2013 10:56

If any other questions come up, please do not hesitate to contact us.

ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Re: Backup an entire database

Post by ads42 » Mon 26 Aug 2013 17:02

I can backup and restore my database, except that I have a big problem, all accents are replaced by stranger char.
So the datas of the databse is corrupted. :(

my database is ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

I'm wondering if the dump file is saved as a utf8 file ?

any idea of how to solve this ?

Regards

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Backup an entire database

Post by DemetrionQ » Tue 27 Aug 2013 10:02

Hello.

To solve the issue, you should set the TMyConnection.Options.UseUnicode property to False, and the TMyConnection.Options.Charset property - to 'utf8'. For example:

Code: Select all

  MyConnection1.Options.UseUnicode := False;
  MyConnection1.Options.Charset := 'utf8';
  MyDump1.Connection := MyConnection1;
  MyDump1.BackupToFile('C:\backup.txt');

ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Re: Backup an entire database

Post by ads42 » Tue 27 Aug 2013 14:09

Thanks it works now. :)

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Backup an entire database

Post by DemetrionQ » Tue 27 Aug 2013 14:17

If any other questions come up, please contact us.

ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Re: Backup an entire database

Post by ads42 » Thu 29 Aug 2013 19:54

Hi,
The problem is that I have to disconnect to the database for backup/restoring, then changing the TMyConnection properties because if I use the same settings I will have strange char in my DB controls this time.
Then after using backup/restore I will have to set back the older properties... :(

Isn't there a way to have right datas at the same time in backup/restore and in DB controls ?

Thanks

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Backup an entire database

Post by DemetrionQ » Fri 30 Aug 2013 10:52

You can perform database backup/restore via a separate connection, having created a new TMyConnection object.

ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Re: Backup an entire database

Post by ads42 » Fri 30 Aug 2013 11:36

That's what I've finally done.
Thanks

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Backup an entire database

Post by DemetrionQ » Fri 30 Aug 2013 13:03

If any other questions come up, please contact us.

Best regards,
Demetrion
Devart Team

Post Reply