[web] Dumping a database to a text file

Started by
12 comments, last by Sander 18 years, 2 months ago
Quote:Original post by Arkantis

have PHP write it to a temporary text file on the server than forward the user to a download location....

Or even better, google an existing PHP zip file class than have the server dump the tables into a formatted string(that you'd write to a text file or whatnot in any format you'd like) than zip the file using the zip class and send the header information that this is a zip file and echo the zip file the zip class makes for you...

Theres a bunch of ways


No need to mess around with temporary files. Simply put all the text in a variable and echo() that to the browser. Just hake sure you use header() to set the correct headers.

As for a zip class, phpmyadmin has a good one you could re-use under the GPL.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Advertisement
Rather than using INTO OUTFILE, use INTO LOCAL OUTFILE instead... your MySQL account might not have the server file access privilege.

Before assuming that /temp exists, please verify it - on Linux / Unix machines, /temp does not normally exist hence you won't be able to use that.

If you're getting "fork failed" that indicates that either there is a problem with the server, or that your user has reached its quota of processes (or similar).

It's possible that if you're running in one of these dodgy "virtual servers" (The ones which aren't virtual servers at all, just some kind of lame partitioning scheme) you're in some kind of restricted environment which prohibits spawning child processes.

Using mysqldump is the right and correct way of doing this.

PHPMyAdmin uses a lame and highly flawed approach; its backups are frequently silently truncated, or have encoding or other problems. This makes restoring them problematic (i.e. impossible)

Mark
By the way, in case you failed to get the message from that last post,

PHPMyAdmin is a steaming pile of

Mark
Quote:Original post by markr
By the way, in case you failed to get the message from that last post,

PHPMyAdmin is a steaming pile of

Mark


That doesn't mean you shouldn't re-use parts of its code into your own product. It just shows that you need to understand that which you re-use. Also, phpMyAdmin is pretty decent if you don't have access to the back-end (i.e. a regular shared hosting account), though full backups should be made through the cpanel's interface to mysqldump.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement