This is a discussion on MySQL backup within the PHP Language forums, part of the PHP Programming Forums category; I've got a feeling that I may have asked this before but I can't find the answer if ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've got a feeling that I may have asked this before but I can't find the
answer if there was one offered so apologies for that... I've written a little content management system and I want to give the user the ability to back up their database. I've looked at the relevant pages in PHPMyAdmin but I'm not any closer to an answer. I just want something very simple where they click on a link and it displays a complete dump of the tables and the inserts for them to copy and paste into a .txt file. Any ideas please. Andy |
|
|||
|
Andy Jacobs wrote:
> ... I want to give the user > the ability to back up their database. > ... > I just want something very > simple where they click on a link and it displays a complete dump of the > tables and the inserts for them to copy and paste into a .txt file. php$ cat dbbackup.php <?php $db = 'test'; $table = 'foo'; /* $table=''; // for all tables in the db */ echo '<pre>'; echo `mysqldump -uCENSORED -pCENSORED $db $table`; // ^ ^ // These are BACKTICKS! They are not single quotes echo '</pre>'; ?> php$ php dbbackup.php <pre>-- MySQL dump 9.11 -- -- Host: localhost Database: test -- ------------------------------------------------------ -- Server version 4.0.21-log -- -- Table structure for table `foo` -- CREATE TABLE `foo` ( `bar` datetime default NULL ) TYPE=MyISAM; -- -- Dumping data for table `foo` -- INSERT INTO `foo` VALUES ('2004-01-01 08:00:00'); INSERT INTO `foo` VALUES ('2004-02-01 08:00:00'); INSERT INTO `foo` VALUES ('2004-01-01 08:00:01'); INSERT INTO `foo` VALUES ('2004-02-01 08:00:01'); </pre> php$ -- Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/ == ** ## !! !! ## ** == TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may bypass the spam filter. I will answer all pertinent mails from a valid address. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|