radiations3 Posted August 4, 2011 Share Posted August 4, 2011 I want to know that is it possible through php coding to back up the table of our database into specified location?? And did you ever backup your database???? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 yes, it's possible, and yes, I back up my databases. what I normally do is tar -czf the entire mysql folder. I actually have a cron tab set up to do this every day at midnight. you can do the same with php, or you could dump the database to a csv file. Quote Link to comment Share on other sites More sharing options...
SOliver Posted August 4, 2011 Share Posted August 4, 2011 http://www.noupe.com/how-tos/10-ways-to-automatically-manually-backup-mysql-database.html There's a bunch of methos for mysql here, hope that helps. Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 well thanks for letting me know i am a newbie and don't know the things you mentioned for backing up the database. if you any link or file regrading backing up the database then kindly do share so i can do it as well.. Thanks! Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 http://www.noupe.com/how-tos/10-ways-to-automatically-manually-backup-mysql-database.html There's a bunch of methos for mysql here, hope that helps. okay i'll try... Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 "Do or Do not, there is no try" -- Yoda Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 yes, it's possible, and yes, I back up my databases. what I normally do is tar -czf the entire mysql folder. I actually have a cron tab set up to do this every day at midnight. you can do the same with php, or you could dump the database to a csv file. I got this code : <?php include 'config.php'; include 'opendb.php'; $dbuser = "root"; $dbpass = ""; $dbhost = "localhost"; $dbname = "bakery"; $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz'; $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile"; system($command); include 'closedb.php'; ?> But when i run it i got following error messages kindly help to resolve them... Warning: include(config.php) [function.include]: failed to open stream: No such file or directory in D:\DBMS\DB.php on line 2 Warning: include() [function.include]: Failed opening 'config.php' for inclusion (include_path='.;C:\php\pear') in D:\DBMS\DB.php on line 2 Warning: include(opendb.php) [function.include]: failed to open stream: No such file or directory in D:\DBMS\DB.php on line 3 Warning: include() [function.include]: Failed opening 'opendb.php' for inclusion (include_path='.;C:\php\pear') in D:\DBMS\DB.php on line 3 Warning: include(closedb.php) [function.include]: failed to open stream: No such file or directory in D:\DBMS\DB.php on line 14 Warning: include() [function.include]: Failed opening 'closedb.php' for inclusion (include_path='.;C:\php\pear') in D:\DBMS\DB.php on line 14 Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 because that script relies on 3 external files that you don't seem to have: config.php, opendb.php and closedb.php the error says: "No such file or directory" Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 because that script relies on 3 external files that you don't seem to have: config.php, opendb.php and closedb.php the error says: "No such file or directory" I corrected it but now i am not able to see that where my backup file is getting saved i am very close to solve this problem kindly help my current code: <?php //include 'config.php'; //include 'opendb.php'; $dbuser = "root"; $dbpass = ""; $dbhost = "localhost"; $dbname = "bakery"; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz'; $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile"; system($command); //include 'closedb.php'; mysql_close($conn); ?> Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 Kindly help anyone?? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 this is all you need: (except you need to specify the path to mysqldump correctly) $u = 'username'; $p = 'password'; $db = 'databasename'; system("/Applications/MAMP/Library/bin/mysqldump -u$u -p$p $db > test.sql"); Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 this is all you need: (except you need to specify the path to mysqldump correctly) $u = 'username'; $p = 'password'; $db = 'databasename'; system("/Applications/MAMP/Library/bin/mysqldump -u$u -p$p $db > test.sql"); Did it what you told but a file of 0byte got saved named as test.sql Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 the you didn't do it properly. that EXACT same script worked for me. read my previous post again and locate where you mysqldump is, then replace the path with the correct one. this: /Applications/MAMP/Library/bin/mysqldump will only work if you're on a Mac using Mamp. You need to specify YOUR path. Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 the you didn't do it properly. that EXACT same script worked for me. read my previous post again and locate where you mysqldump is, then replace the path with the correct one. this: /Applications/MAMP/Library/bin/mysqldump will only work if you're on a Mac using Mamp. You need to specify YOUR path. How can i specify my path?? So that i'll use the right path to process my code properly??? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 what are you using? Xamp, Mamp, Wamp? on Windows, Linux or Macintosh ? Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 I am using easy php on windows 7 Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 Well thanks all for helping me out i'll try to google it to solve my issue.... Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 Well thanks all for helping me out i'll try to google it to solve my issue.... I gave you the answer. If you can't find the path to your mysqldump, google won't help you much. Quote Link to comment Share on other sites More sharing options...
TOA Posted August 4, 2011 Share Posted August 4, 2011 Well thanks all for helping me out i'll try to google it to solve my issue.... You need to give more than 14 minutes to help Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 Well thanks all for helping me out i'll try to google it to solve my issue.... I gave you the answer. If you can't find the path to your mysqldump, google won't help you much. Actually i am a newbie so i am not very good at it ... so i am trying to find some other to backup the database you really helped me out at your level best but due to my lack of knowledge i am not able to solve my issue.... Thank You for the help!!! Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 I got the following path: C:\Program Files (x86)\EasyPHP-5.3.6.0\mysql\bin\mysqldump.exe Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 $u = 'root'; $p = ''; $db = 'bakery'; system("C:\Program Files (x86)\EasyPHP-5.3.6.0\mysql\bin\mysqldump -u$u -p$p $db >upload/test.sql"); Nothing happened again 0byte file Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 you found this path: C:\Program Files (x86)\EasyPHP-5.3.6.0\mysql\bin\mysqldump.exe then you used this one: C:\Program Files (x86)\EasyPHP-5.3.6.0\mysql\bin\mysqldump See what's wrong there? Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 4, 2011 Author Share Posted August 4, 2011 you found this path: C:\Program Files (x86)\EasyPHP-5.3.6.0\mysql\bin\mysqldump.exe then you used this one: C:\Program Files (x86)\EasyPHP-5.3.6.0\mysql\bin\mysqldump See what's wrong there? I TRIED BOTH ABOVE MENTIONED PATH AND I AM NOT GETTING WHY THE BACKUP IS NOT CREATING IF YOU HAVE ANY PHP FILE FOR BACKING UP THE DATABASE THEN KINDLY SHARE IT I'LL BE VERY THANKFUL TO YOU Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 as I said before, I use cron tabs and a simple shell script to compress the entire folder. I only work with linux and macintosh, you're using windows. 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.