Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Web Hosting Forum


You are currently viewing our Web Hosting Forum as a guest. Please register to participate.
Login



Reply
CPanel Cron Job - What command to run SQL backups
Old 07-17-2010, 11:05 PM CPanel Cron Job - What command to run SQL backups
TWD
TWD's Avatar
King Spam Talker

Posts: 1,190
Trades: 0
Hi

I am using a hosting account with standard CPanel which includes
the CronJob utility.

Question:

What do I need to enter in the command line in order to backup a database?
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-18-2010, 09:40 AM Re: CPanel Cron Job - What command to run SQL backups
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,381
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

use CTRL+F to find "cron"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-18-2010, 03:49 PM Re: CPanel Cron Job - What command to run SQL backups
XeHSean's Avatar
Super Talker

Posts: 126
Trades: 0
I assume you are FTPing these backups elsewhere? If you are just keeping them in your account, you may wish to check with your provider if they are already taking backups for you - most do take daily backups
__________________

Please login or register to view this content. Registration is FREE
- Hosting websites since 1999!
Shared Hosting, Reseller Hosting, VPS Hosting, and Dedicated Servers
Free End-User Support, WHMCS, and WHMReseller on Reseller Hosting Plans
XeHSean is offline
Reply With Quote
View Public Profile Visit XeHSean's homepage!
 
Old 07-19-2010, 03:21 AM Re: CPanel Cron Job - What command to run SQL backups
Webmaster Talker

Posts: 687
Name: Rob Smith
Trades: 0
Quote:
Originally Posted by XeHSean View Post
I assume you are FTPing these backups elsewhere? If you are just keeping them in your account, you may wish to check with your provider if they are already taking backups for you - most do take daily backups
Yes that is truth. In any case he seems to be looking for the backups which should be issued om schedule.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
- Fully Managed Dedicated and since 1999.

Please login or register to view this content. Registration is FREE
- Low cost hosting from $2.79!
WebhostGIANT-Rob is offline
Reply With Quote
View Public Profile
 
Old 07-19-2010, 08:18 AM Re: CPanel Cron Job - What command to run SQL backups
TWD
TWD's Avatar
King Spam Talker

Posts: 1,190
Trades: 0
Well yes, most probably the hosting company does run some kind of backups.

Color me paranoid but I would rather not entrust critical processes like
site backups to a third party. I believe it even says something to that effect in the Hosting T.O.S.

Hence I'd like to take control of the process by setting up a cron job myself.
Ideally, with the backups emailed to a separately hosted mail account.

Thanks Chris for the links. Will do some research.
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is offline
Reply With Quote
View Public Profile
 
Old 07-26-2010, 05:24 AM Re: CPanel Cron Job - What command to run SQL backups
~ServerPoint~'s Avatar
Defies a Status

Posts: 1,687
Name: Travis
Trades: 0
I believe that would be useful for you as well to have several third party backup solutions. Just try to avoid keeping all egges in the same basket.
__________________
ServerPoint.com - a true hosting company since 1998
Web Hosting, colocation,
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
~ServerPoint~ is offline
Reply With Quote
View Public Profile
 
Old 07-31-2010, 02:30 AM Re: CPanel Cron Job - What command to run SQL backups
Average Talker

Posts: 24
Name: Justin
Trades: 0
I have used the following script for automated MySQL backups. Just create it as a PHP file on your account, and configure the settings. Set the cron to run on the same days every month, and will will rotate them out by unlinking them - as it creates the file based on the day. So if you ran it daily, it would keep 30 days backups and rotate them. If you ran it on the 5th only, it would rotate that out on the next 5th.

PHP Code:
 <?php
$emailaddress 
"XXXXXX@yourdomain.com";
$host="XXXXXX"// database host
$dbuser="XXXXXX"// database user name
$dbpswd="XXXXXX"// database password
$mysqldb="XXXXXX"// name of database
$path "/home/user/dbbackups"// full server path to the directory where you want the backup files (no trailing slash)
// modify the above values to fit your environment
$filename $path "/backup" date("d") . ".sql";
if ( 
file_exists($filename) ) unlink($filename);
system("mysqldump --user=$dbuser --password=$dbpswd --host=$host $mysqldb > $filename",$result);
$size filesize($filename);
switch (
$size) {
  case (
$size>=1048576): $size round($size/1048576) . " MB"; break;
  case (
$size>=1024): $size round($size/1024) . " KB"; break;
  default: 
$size $size " bytes"; break;
}
$message "The database backup for " $mysqldb " has been run.\n\n";
$message .= "The return code was: " $result "\n\n";
$message .= "The file path is: " $filename "\n\n";
$message .= "Size of the backup: " $size "\n\n";
$message .= "Server time of the backup: " date(" F d h:ia") . "\n\n";
mail($emailaddress"Database Backup Message" $message"From: Website <>"); 
?>
And to set up the cron, let's say you saved the file as dbbackup.php, then you would enter the following in the crontab to run it daily at midnight.

0 * * * * php -q /home/user/dbbackup.php
__________________

Please login or register to view this content. Registration is FREE
- Premium free cPanel hosting!
justinp is offline
Reply With Quote
View Public Profile Visit justinp's homepage!
 
Reply     « Reply to CPanel Cron Job - What command to run SQL backups
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60376 seconds with 12 queries