Jump to content

Mysql Backup


Iklekid

Recommended Posts

Hi I would like to make a back up of my websites myswl databse everyday at midnight! I have been told that I can do this using a crontab! I have crontabs on my server but I dont know what coding/command line on the cron tab to use! There is only one databse I would like to back up! Anyoen know how to do this?

 

Thanks in advance for any help!

 

Iklekid :D

Link to comment
Share on other sites

You could use my Backup Utility:

 

http://www.phpfreaks.com/script/view/11.php

 

Alternatively, I would create a PHP script to do this.

 

Something like this:

 

[php:1:6356097178]<?php

 

$filename = \"mysqldb\".time().\".sql\";

 

passthru(\"mysqldump -u (username) -p(password) --opt (database_name) > /my/backup/directory/$filename\");

?>[/php:1:6356097178]

 

Then using my PHP CRON Tutorial, you can set it up on a CRON TAB.

 

http://www.phpfreaks.com/tutorials/28/0.php

 

Good luck.

Link to comment
Share on other sites

<?php  

 

$filename = \\\"mysqldb\\\".time().\\\".sql\\\";  

 

passthru(\\\"mysqldump -u (username) -p(password) --opt (database_name) > /my/backup/directory/$filename\\\");  

?>

 

Do i replace the /my/backup/directory with my full server path to a folder I would like the backups put into??

 

And also do i jsut do a wget fucntion in the cron tab command?

 

Thanks

 

Iklekid

Link to comment
Share on other sites

Yes, common sense to me would tell me to replace that path to the directory where I want the backup to be stored.

 

Also, please read the tutorial for the cron tab. It tells you how to use a CGI version of PHP as well as lynx to access your php script.

 

Thanks,

Link to comment
Share on other sites

Hi I am using the script U have created but it dosent seem to want to work!

 

I have a cron tab set to wrok at midnight

 

the cron command is

 

php /home/dwog/public_html/*****/dbsender.php > dev/nul

I am asking for it to email me the fille, I have chmod the directory but still no luck.

 

Any ideas?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.