pcw Posted March 20, 2009 Share Posted March 20, 2009 Hi, I am having a prob with this script. It is creating the backup file, but is not writing the contents of the table into it. include_once("data/required.php"); $date = date("d-m-Y"); $backupFile = "$date-profiles.sql"; $backupDir = "/home/moveitho/public_html/sitebuilder/backup/"; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); $back = $backupDir.$backupFile; $strCommand = sprintf("mysqldump moveitho_sitebuilder profiles -h%s -u%s -p%s > %s",$host,$user,$pass,$back) or die (mysql_error()); echo shell_exec($strCommand); echo "Backup file $backupFile has been created successfully"; echo "This file has been saved in $backupDir"; This was working yeaterday, but I think I might have accidently changed something. Quote Link to comment Share on other sites More sharing options...
sloth456 Posted March 20, 2009 Share Posted March 20, 2009 could it be this mysqldump moveitho_sitebuilder profiles -h%s -u%s -p%s > %s it says "moveitho" should that be "moveito" Sorry if I'm being completely idiotic, I'm not familiar with shellexec(), it just struck me as looking a bit like a typo. Quote Link to comment Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Nope, moveitho_ is the prefix to the database name and username. This is correct. It has no problem in connecting to the database or creating the backup file, its just not writing the contents Quote Link to comment Share on other sites More sharing options...
webref.eu Posted March 20, 2009 Share Posted March 20, 2009 Complete guess but could it be some kind of file write permissions issue? Whatever ac is trying to write doesn't have the correct permissions? Rgds Quote Link to comment Share on other sites More sharing options...
sloth456 Posted March 20, 2009 Share Posted March 20, 2009 hmmm, well I'm out of ideas, unless you or whoever is hosting put php under safe mode in which case shell_exec wouldn't work. Just read that at the php manual ^^ Quote Link to comment Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Hi guys, thanks for your help, but the write permissions are correct. Its just for some reason, the contents of the table are not written into the file Quote Link to comment Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Ok, it appears that shell_exec is disabled on my server. How else can I backup mysql tables with PHP? Thanks Quote Link to comment Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Can anyone help with this? Thanks Quote Link to comment Share on other sites More sharing options...
ninedoors Posted March 20, 2009 Share Posted March 20, 2009 I use this script. It is pretty good and I was able to tweak it perfectly for my site. It allows you to select only certain tables if thats what you need. PHP MySQL Auto Backup Hope that works for you. Nick Quote Link to comment Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Hi Nick, thanks for your reply. That script is just what I needed, and have now modified it to do what I need. Many thanks Quote Link to comment Share on other sites More sharing options...
ninedoors Posted March 20, 2009 Share Posted March 20, 2009 Your welcome, I know I was pumped when I found it myself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.