ashii Posted July 6, 2012 Share Posted July 6, 2012 I am sorry if someone else has come up with this topic earlier. (please let me know if that was solved) I want to take a backup of my mysql db using php, and I went searching for some solutions in google, but yet I couldn't find a right one, so could anyone post me the code or the link which really works for you! thank you. Link to comment https://forums.phpfreaks.com/topic/265293-mysql-backup-using-php/ Share on other sites More sharing options...
xyph Posted July 6, 2012 Share Posted July 6, 2012 Did you want it done at a certain interval, or manually? Link to comment https://forums.phpfreaks.com/topic/265293-mysql-backup-using-php/#findComment-1359587 Share on other sites More sharing options...
ashii Posted July 6, 2012 Author Share Posted July 6, 2012 I need it to be done manually thank you. Link to comment https://forums.phpfreaks.com/topic/265293-mysql-backup-using-php/#findComment-1359590 Share on other sites More sharing options...
trq Posted July 6, 2012 Share Posted July 6, 2012 Is there a particular reason you need php to do this? It can be done simply enough from the command line. mysqldump nameofdb | gzip > nameofdb.bkp.sql.gz If you need it to be done via php you can use exec to execute this same command. Link to comment https://forums.phpfreaks.com/topic/265293-mysql-backup-using-php/#findComment-1359592 Share on other sites More sharing options...
ashii Posted July 6, 2012 Author Share Posted July 6, 2012 Thank you for the reply, I wrote the code and it throws me an error saying "mysqldump is not recognized as an internal or external command, operable program or batch file." The reason is I am going to port this code into my drupal module. Thank you. Link to comment https://forums.phpfreaks.com/topic/265293-mysql-backup-using-php/#findComment-1359602 Share on other sites More sharing options...
trq Posted July 6, 2012 Share Posted July 6, 2012 You might need to supply the full path to mysqldump. eg; /usr/local/bin/mysqldump nameofdb | gzip > nameofdb.bkp.sql.gz You will likely also need to pass it a user and password. Link to comment https://forums.phpfreaks.com/topic/265293-mysql-backup-using-php/#findComment-1359608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.