MySQL backup component

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

law
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 28.12.2006, 15:12
Location: Eger
Contact:

MySQL backup component

Postby law » 27.11.2007, 01:58

I wrote a component to create backup from databases. Sorry for posting here, I can't find any email address to zeos dev.team. Delete this thread if this is not the right place for posting this component.

Component for Delphi (tested on D7) to backup MySQL databases (5.0.3 and above)
based on ZeosLib.
This is an experimental version, use it at your own risk.


Features:
- generates complete db backup which can be restored with ZSQLProcessor
- backup tables with keys and constraints, views, stored procedures,
stored functions and triggers
- uses SHOW statements to get DDL
- uses information_schema database for triggers
- data is saved to bulk inserts in the backup script
- hexadecimal blob backup (tested only with little blobs)
- unescape varchar and text fields


ZlawMySQLBackup derived from ZlawConnection, which is derived for ZConnection.
ZlawConnection read the connection properties from crypted ini file (sample ini
in the source directory). For crypting, I used DCPcrypt2 lib. If you don't want
to use it, just derive ZlawMySQLBackup from ZConnection.


Todo:
- test it
- get information about which chars to escape
- add support for more field types
- check data formats for decimal and date fields
- add options: create/drop database, drop objects, use lock around inserts, etc.
You do not have the required permissions to view the files attached to this post.
Last edited by law on 21.01.2008, 00:24, edited 1 time in total.

stOrM!
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 06.12.2007, 14:58

Postby stOrM! » 11.12.2007, 12:18

Thats what I was searching for!
You did a great job, maybe you could implement an event so that a progressbar and or time remining value can be shown to the user?

kindest regards
s!

jamiguel77
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.12.2007, 18:00

cant open the demo Delphi project......

Postby jamiguel77 » 26.12.2007, 22:49

i installed
ZlawMySQLBackup befire installed:

DCPCrypt2 is an open source library released under the MIT license.
You can find it here:

http://www.cityinthesky.co.uk/cryptography.html

and try install ZlawMySQLBackup. i go to Zeos Access Page and i see 2 components:

-ZlawMysqlBackup and Zlawconnection

when i try open the demo of ZlawMySQLBackup

ask me for: ZSQLProcessor
i checked the .pas files under \source folder and not found these component..


any advice?


thanks

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 27.12.2007, 00:02

I suppose you'll have to install zeoslib first...

Mark
Image

jamiguel77
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.12.2007, 18:00

i dont use Zeos components i use Zmysql components...

Postby jamiguel77 » 27.12.2007, 00:51

hi...

i dont use Zeos components i use Zmysql components...

Zeos Mysql Components....

and not install ZSQLProcessor


what need install?

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 27.12.2007, 02:49

Not sure if it's possible to install the Old ZMysql components next to the new ones. I'm afraid you can't combine these.
If you need the ZSQLProcessor : it's part of the ZeosDBO library. Best version is 6.6.2.

Mark
Image

jamiguel77
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.12.2007, 18:00

ouch!

Postby jamiguel77 » 27.12.2007, 15:27

ouch!

thanks for read and reply

you wrote:

Not sure if it's possible to install the Old ZMysql components next to the new ones

if i install the new release of zeos components what happend with my Zmysql Old components?

How change in my delphi programs, ZMysql to Zeos components? exist a way for change automatically or one by one?

thanks

jamiguel77
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.12.2007, 18:00

error when try install Zeos Components....

Postby jamiguel77 » 27.12.2007, 16:13

my scenario:
-using D7
- have installed ZMysql
- have installed ZlawMySQLBackup(i created new package named zbackup)
followed:

Unpack the archive to a folder

Copy the required dlls from lib directory to the windows system directory (usually Windows\System or winnt\system32)

Add the build Directory of the package you are about to install to Delphi's library path.

Locate the package directory associated with your compiler and open the ZeosDbo.bpg project group. Load the project and compile the following components in the order listed (or just choose compile all from Project-Menu):

ZCore.bpl
ZParseSql.bpl
ZPlain.bpl
ZDbc.bpl

If all the packages, listed above are successfully compiled you have to install the ZComponent.bpl. After that all ZEOS components are available in the IDE.

Create your own project and start adding the compoents through the IDE and set connection properties. For a quick tutorial, use the example provided with the project or browse the resources on the web page.


i added my build directory to Library path, opened the Project named:
ZeosDbo.bpg

i do a compile all from Project->Compile All projects

the step 5 isnt clear for me, then i go to: File->Open Project-> Choose *.dpk files
and open:
Zcore.dpk (located in packages\delphi7)
when click on Install buton display these error message:

Cannot Load Package 'Zcore70'. it contains unit named 'Zmessage', wich is also contained in package 'zbackup'.

how fix these error? uninstalling the zbackup package? if the answer is YES, and install correclty, Zeos components, what happend when install ZlawMySQLBackup? same error message? so so:(Cannot Load Package 'zbackup'. it contains unit named 'Zmessage', wich is also contained in package 'Zcore70'.)


?

thanks in advance

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 27.12.2007, 21:48

This may have to do with multiple ZMessage.pas files on your system. eg. in the old components and in the new components. Or old dcu's swimming around in the compiler search path.
Please try this. (I know it's a lot of work, I hope it's worth it))
- Uninstall the new and old z*-components and zbackup package
- Remove all dcu,'s bpl's, ... that result from compiling ZMysql, Zeosdbo and zbackup. Search your complete computer for z*.dcu, z*.bpl.
- Install zeosdbo. Open projectgroup, Compile all (as you did), install ComponentDesign package (last in the list) by right clicking on it and choosing install. You should get an anouncement that ZEOSDBO installed a few new components and these should be visible on the Zeos Acces tab page..
- Install the Zbackup project.
- If this works it may prove an incompatibility of the old components (do they contain a ZMessage file?)

Mark
Image

jamiguel77
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.12.2007, 18:00

ok worked....

Postby jamiguel77 » 27.12.2007, 23:53

finally i installed ZeosDBo and ZlawMySQLBackup and preserve my Zmysql components ....

when i test the Demo programof ZlawMySQLBackup i configure the database and user/pass i test the program and effectively generate a .sql file but only with these lines:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0

SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'

DROP DATABASE IF EXISTS prepa

CREATE DATABASE prepa

USE prepa


what happend with the rest of data? table definitions, etc...

of course my db have data and tables.


thanks

jamiguel77
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.12.2007, 18:00

tested again the code and.... get an error...

Postby jamiguel77 » 28.12.2007, 01:05

procedure TZlawMySQLBackup.WriteTableDefs;
begin
FTables.SQL.Text:='SHOW FULL TABLES WHERE Table_type=''BASE TABLE''';
FTables.Open;

when open the Query, say the error...


You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'TABLE
S WHERE Table_type='BASE TABLE'' at line 1


tested manually the query statment and get same error.....

mysql> use prepa;
Database changed
mysql> SHOW FULL TABLES WHERE Table_type='BASE TABLE';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'TABLE
S WHERE Table_type='BASE TABLE'' at line 1
mysql> select version();
+-----------+
| version() |
+-----------+
| 4.1.16-nt |
+-----------+
1 row in set (0.13 sec)

mysql>

Note: in the protocol i have been chosse: mysql-4.1 or mysql but get same error..

why?



thanks

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 28.12.2007, 12:41

Check with Law on this...
His mail is in the package and you can always send him a private message to get his attention...
Mark
Image

law
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 28.12.2006, 15:12
Location: Eger
Contact:

Postby law » 21.01.2008, 00:30

'show FULL tables' doesn't implemented in mysql 4.1.16, only 'show tables'.
maybe there's other errors on mysql below 5.0.3. check your mysql docs and write the right statements to zlawmysqlbackup.pas.
i uploaded a new version to the first post with some bugfixes and some new features.

gioloi
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 20.02.2008, 09:58

Postby gioloi » 20.02.2008, 10:11

Hi,
the download link don't works..
There's another place where download this usefull component?

Thanks

gioloi

sandeep_c24
Expert Boarder
Expert Boarder
Posts: 158
Joined: 06.11.2005, 01:43

Postby sandeep_c24 » 20.02.2008, 11:05

Should a new component be added to Zeos to handle Backup and restore?

Regards

Sandeep


Return to “6.5.1 (alpha) - 6.6.x (beta)”

Who is online

Users browsing this forum: No registered users and 1 guest