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

Post by law »

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

Post by stOrM! »

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......

Post by jamiguel77 »

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:

Post by mdaems »

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...

Post by jamiguel77 »

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:

Post by mdaems »

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!

Post by jamiguel77 »

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....

Post by jamiguel77 »

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:

Post by mdaems »

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....

Post by jamiguel77 »

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...

Post by jamiguel77 »

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:

Post by mdaems »

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:

Post by law »

'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

Post by gioloi »

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

Post by sandeep_c24 »

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

Regards

Sandeep
Post Reply