Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2007-01-23, 08:48 AM   #1
Fonz
Former pr0n slinger.
 
Fonz's Avatar
 
Join Date: Aug 2003
Location: Antwerp, Belgium
Posts: 7,932
Backing up a MySQL database to a .txt file using a PHP script

I'm looking for some way to back up a huge MySQL database to a downloadable .txt file. I have found some PHP scripts like this one: http://www.zend.com/codex.php?id=634&single=1 but that doesn't seem to do anything.

Can anyone (cd34 or so ) can help me out here please?
Thanx!
__________________
See how I abuse little trees on my Shumi no Bonsai Blog
Fonz is offline   Reply With Quote
Old 2007-01-23, 09:02 AM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
if it is huge, you're likely to run into timeouts on apache that aren't going to allow it to be downloaded completely.

What you can try is something like forking a process that does

mysqldump -q -u username -ppassword databasename > /tmp/dump.sql

and writing the pid of the forked process so that you can check to see if the process is still running. With most apache servers, in 2-3 minutes a php script (or any cgi script) will time out and kill the process -- resulting in an incomplete dump.

Alternatively you can write your own dump that will go through the records one by one and output a . or space to the screen to keep apache from timing out.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2007-01-23, 09:20 AM   #3
Fonz
Former pr0n slinger.
 
Fonz's Avatar
 
Join Date: Aug 2003
Location: Antwerp, Belgium
Posts: 7,932
Thanx, I'll give that a try

Oh and does there has to be a space between -p password?
__________________
See how I abuse little trees on my Shumi no Bonsai Blog
Fonz is offline   Reply With Quote
Old 2007-01-23, 09:52 AM   #4
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
it needs to be -ppassword or -p'password' if there are characters that the shell might escape.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2007-01-29, 06:13 PM   #5
CPR
Internet! Is that thing still around?
 
Join Date: Jan 2007
Location: DK
Posts: 5
Send a message via ICQ to CPR
I would generally recommend using mysqlhotcopy, mainly because its faster than mysqldump, although it uses locks.
But since you need a PHP script to do the work you probably don't have access to the server?!

Check it out http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
CPR is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:35 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc