MySQL backup

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


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-16-2004
Andy Jacobs
 
Posts: n/a
Default MySQL backup

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

Reply With Quote
  #2 (permalink)  
Old 11-16-2004
Pedro Graca
 
Posts: n/a
Default Re: MySQL backup

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.
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:23 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0