[thelist] MySQL Backup Statement

A Maynes andrew at milords.com
Fri Aug 5 10:08:26 CDT 2005


I have just knocked this up but it doesn't seem to be cooperating can
anyone help out 

<?php 

ob_start(); 

$username = ""; 
$password = ""; 
$hostname = "localhost"; 
$sConnString = mysql_connect($hostname, $username, $password) 
or die("Unable to connect to MySQL"); 

//create a connection object 
$connection = mysql_select_db("dbname",$sConnString) 
or die("Could not select DB"); 

$command = "mysqldump --add-drop-table --host=localhost --user=''
--password='' dbname"; 
system($command); 

$dump = ob_get_contents(); 
ob_end_clean(); 

//The database dump now exists in the $dump variable... write it to a
file using... 

$fp = fopen("dump.sql", "w"); 
fputs($fp, $dump); 
fclose($fp); 

?> 


Andrew


> -----Original Message-----
> From: A Maynes [mailto:andrew at milords.com] 
> Sent: 05 August 2005 15:12
> To: 'Dan McCullough'; thelist at lists.evolt.org
> Subject: RE: [thelist] MySQL Backup Statement
> 
> 
> I'm not too fmailiar with shell which part would I put in the 
> .sh file?
> 
> Could you point me to a shell tutorial for this setup please?
> 
> Would I need to have gz installed?
> 
> Andrew
> 
> 
> > -----Original Message-----
> > From: Dan McCullough [mailto:dan.mccullough at gmail.com]
> > Sent: 05 August 2005 15:02
> > To: thelist at lists.evolt.org
> > Subject: Re: [thelist] MySQL Backup Statement
> > 
> > 
> > you could so a simple shell script and cron it.
> > 
> > 
> > #!/bin/sh
> > #backup.sh
> > 
> > date=`date -I`
> > rm -f /var/backup/dbname-bak-*.sql.gz 
> /opt/mysql/bin/mysqldump --opt 
> > --quote-names -u <user> -p<pass> dbname
> > | gzip > /var/backup/dbname-bak-$date.sql.gz
> > 
> > 
> > 
> > On 8/5/05, A Maynes <andrew at milords.com> wrote:
> > > I need to run a simple MySQL Backup statement without
> > causing too much
> > > strain on the server what would be the best method?
> > > 
> > > I am thinking about running a cron to run a PHP script 
> which simply
> > > dumbs the backup file in a DIR on a daily basis?
> > > 
> > > Anyone have a pointer to the PHP code please
> > > 
> > > Andrew
> > > 
> > > --
> > > 
> > > * * Please support the community that supports you.  * *
> > > http://evolt.org/help_support_evolt/
> > > 
> > > For unsubscribe and other options, including the Tip Harvester and
> > > archives of thelist go to: http://lists.evolt.org Workers 
> > of the Web,
> > > evolt !
> > >
> > --
> > 
> > * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 
> 
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 
> 



More information about the thelist mailing list