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. Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/ 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. Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789625 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 Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789629 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 Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789632 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 ^^ Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789633 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 Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789638 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 Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789669 Share on other sites More sharing options...
pcw Posted March 20, 2009 Author Share Posted March 20, 2009 Can anyone help with this? Thanks Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789733 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 Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789740 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 Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789836 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. Link to comment https://forums.phpfreaks.com/topic/150349-solved-mysql-table-backup/#findComment-789850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.