Lodius2000 Posted January 17, 2009 Share Posted January 17, 2009 Hi guys... im trying to make a db backup script and I got this code from the intarwebs, and wouldnt you know, its not working in produces a .gz file that when uncompressed is a blank file whats wrong, i am betting its in the $command line but i dont really know what all that stuff means, other than the variables in there <?php //config.php contains all variables used in $command line, all of which are copy pasted from db_login.php include ('../../dbbackups/config.php'); require ('../install/PEAR/DB.php'); require ('../../dbfiles/db_login.php'); $backupFile = '../../dbbackups/' . date("Y-m-d") . '.gz'; $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile"; system($command); ?> thanks for your help Link to comment https://forums.phpfreaks.com/topic/141166-simple-mysqldump-cron-script/ Share on other sites More sharing options...
phparray Posted January 17, 2009 Share Posted January 17, 2009 When calling and external command from php you need to use the full path to the command. If you have ssh access to your server login and run which mysqldump to find the path. If you don't have ssh access contact your server provider. Edit the command to include the full path. A common path is /usr/bin/mysqldump Also I doubt you need the PEAR/DB.php file unless you put it there for a reason. Link to comment https://forums.phpfreaks.com/topic/141166-simple-mysqldump-cron-script/#findComment-738908 Share on other sites More sharing options...
Lodius2000 Posted January 17, 2009 Author Share Posted January 17, 2009 yeah i need the pear because my dblogin is written using peardb edit: im on the horn with my tech support now and they didnt tell me to use a file path to mysqldump...weird Link to comment https://forums.phpfreaks.com/topic/141166-simple-mysqldump-cron-script/#findComment-738912 Share on other sites More sharing options...
Lodius2000 Posted January 17, 2009 Author Share Posted January 17, 2009 do i even need to connect to my db, or does mysqldump do that for me? i mean it seems odd that i am putting in the same usn pw and hostspecs twice? Link to comment https://forums.phpfreaks.com/topic/141166-simple-mysqldump-cron-script/#findComment-738916 Share on other sites More sharing options...
phparray Posted January 17, 2009 Share Posted January 17, 2009 do i even need to connect to my db, or does mysqldump do that for me? i mean it seems odd that i am putting in the same usn pw and hostspecs twice? You do not. But what you do need is the full path to mysqldump and the apache or whatever user php runs as needs write permissions on the destination folder. The apache error logs file should tell you what the problem is. Link to comment https://forums.phpfreaks.com/topic/141166-simple-mysqldump-cron-script/#findComment-738938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.