Jump to content

Database Back Up Using Php Script


Recommended Posts

Hello everyone - I want to take backup of my database using cron. I found following php script with the help of google.<?php/*Quickly and easily backup your MySQL database and have the tgz emailed to you. You need PEAR installed with the Mail and Mail_Mime packages installed. Read more about PEAR here: http://pear.php.net. This will work in any *nix enviornment. Make sure you have write access to your /tmp directory.*/// mysql & minor details..$tmpDir = "/tmp/";$user = "root";$password = "pass";$dbName = "db";$prefix = "db_";$sqlFile = $tmpDir.$prefix.date('Y_m_d').".sql";$creatBackup = "mysqldump -u ".$user." --password=".$password." ".$dbName." > ".$sqlFile;exec($creatBackup);?>I have made try with this script, but still i don't get the desired result. So, can anyone help me for the above issue..?Thanks in advance...@:-Deep

Link to post
Share on other sites

What debugging steps have you taken? Is error reporting on? Echo some stuff at various stages to see where the scritp contains bad data, like echo the query before the call to exec(). Do you have permissions for the tmp dir = 0777?Is the exec() enabled?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...