Forum Moderators: coopster

Message Too Old, No Replies

[PHP] How to backup mysql databse through exe() or system() functions

         

camilord

8:49 am on Feb 19, 2007 (gmt 0)

10+ Year Member



here's my code:

<?php
function mysql_backup() {
include("mysql_account.php");
$cmdDump = "/usr/bin/mysqldump zabyer_zabies -h localhost --user=".$mysql_user." --password=".$mysql_passwd." --all > /home/zabyer/public_html/backup/ZabyerDB_AutoBackUp_".date("mdY").".sql";
$last_line = system($cmdDump, $retval);
echo $retval."<br>".$last_line."<br>";
$last_line = system('tar -cvf /home/zabyer/public_html/backup/ZabyerDB_AutoBackUp_'.date("mdY").'.tar /home/zabyer/public_html/backup/ZabyerDB_AutoBackUp_'.date("mdY").'.sql',$rval);
echo $rval."<br>".$last_line."<br>";
$last_line = system('gzip -9 /home/zabyer/public_html/backup/ZabyerDB_AutoBackUp_'.date("mdY").'.tar',$rval);
echo $rval."<br>".$last_line."<br>";
}
mysql_backup();
echo "Backup Done...";
?>

but it seems there's no output at all...

dreamcatcher

9:01 am on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi camilord,

Try putting the following at the top of your script:

error_reporting(ALL);

Then try again and see if you get any errors outputted to the screen.

dc

camilord

9:17 am on Feb 19, 2007 (gmt 0)

10+ Year Member



still didn't display any error...

could it be my php is in safe_mode?

cameraman

9:33 am on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Possibly:
global $mysql_user, $mysql_passwd;
just inside the function declaration?

camilord

9:36 am on Feb 19, 2007 (gmt 0)

10+ Year Member



the variable $mysql_user and $mysql_passwd are just inside the function... its not a global variable at all...