Post Reply  Post Thread 
PHP script for backup of mysql database
Author Message
admin
~CM~
*******


Posts: 147
Group: Administrators
Joined: Jul 2007
Status: Offline
Reputation: 0
Thank 0
1 was given thank in 1 posts
Post: #1
PHP script for backup of mysql database

Following is script by which you can take database dump by PHP script. Class is ready to make the full backup of a mysql database, and can compress the dump in gzip format!

PHP Code:
//if t=1 dumps the data, otherwise the structure 
    
$data=$_GET['t']; 
    require(
"class_mysqldump.php"); 
     
    
//Instantiate the class: host name, user name, and password 
    
$dump = new MySQLDump("localhost""root"""); 
     
    
//If you want to compress the output uncomment the follow line 
    //$dump = new MySQLDump("localhost", "root", "", False); 
     
    
if ($data=="1") { 
            
$dump->dumpDatabaseData("dbname"$filename100); 
            
//If you don't want binary fields saved in hexadecimal 
            //format uncomment the follow line 
            //$dump->dumpDatabaseData("nomedb", $filename, 100, False); 
    

    else { 
            
//dump the structure 
            
$dump->dumpDatabaseStructure("nomedb"$filename); 
    } 
     
    
//send file to standard output 
    
header ('Content-Type: application/octet-stream'); 
    
header('Content-Disposition: attachment; filename="'.$filename.'"'); 
    
$file=fopen($filename,"r"); 
    
fpassthru($file); 
    
fclose($file); 
     
    
//delete temporary files 
    
unlink($filename); 


Check the attached file of class.



Attached File(s)
.zip File  class_mysqldumpphp.zip (Size: 2.59 KB / Downloads: 8)

Thanks & Regards
------------------
~CM~

ADD TO DEL.ICIO.US  ADD TO DIGG  ADD TO FURL  ADD TO NEWSVINE  ADD TO NETSCAPE 
ADD TO TECHNORATI FAVORITES  Technorati ADD TO SQUIDOO  ADD TO WINDOWS LIVE  ADD TO YAHOO MYWEB  ADD TO ASK 
ADD TO REDDIT  ADD TO STUMBLEUPON  ADD TO GOOGLE   

07-15-2007 03:33 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  PHP form, Image upload. Store in MySQL database. Retrieve admin 0 2,710 11-05-2007 07:50 PM
Last Post: admin
  PHP Script to parse /etc/passwd and how to use the new __get magic method (PHP5) admin 0 424 07-19-2007 03:46 PM
Last Post: admin
  Simple php script for site visitor counter admin 0 335 07-18-2007 07:19 PM
Last Post: admin
  PHP script to find difference between server time and local time admin 0 435 07-18-2007 04:36 AM
Last Post: admin
  GD test script Nilesh 0 626 07-15-2007 09:31 AM
Last Post: Nilesh
  Zend Optimizer test script Nilesh 0 1,040 07-15-2007 09:22 AM
Last Post: Nilesh
  How to Send Email from a PHP Script Using SMTP Authentication Nilesh 0 3,487 07-15-2007 09:17 AM
Last Post: Nilesh
  PHP script for Duration Calculator admin 0 304 07-15-2007 03:23 AM
Last Post: admin

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: