var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
Simplest way to auto cron a mysql database
I use a php script usually but that does not work for large files.
I have a 130mb mysql database on linux using cPanel.
What is the easiest way to set up say a monthly cron to back this up to the root server?
Any help appreciated.
mysqldump -u username -ppassword dbname > dbname.sql would do the trick I suppose?
To load it
mysql -u username -ppassword dbname < dbname.sql
█ █ We Have Generated Over 7 Million cPanel Backups Come Dance Together With Us Y'all!
█ █ Offer Your Own Backup Hosting Service - (Private Label / WHMCS Ready) SiteAutoBackup.Com
█ █ WebHostingBusinessBook.Com | YouTube.com/WebHostingTutorial | NowOpenOnline.Com
Is that complete?
Just that in a cron.
I have had something similar which didn't work.
If that is complete I will try again thanks
If you ae using cPanel, you can setup cronjob from your control panel. It is much easier. There are tutorials on how to setup a cronjob on cPanel.
yes there are but none show the exact syntax to use.
The tuts just show how to enter info in the cron control panel.
I am fine with that.
I have found many syntax examples but have probs with them not working.
For instance this one does not work for me...
/usr/bin/mysqldump –opt –all-databases -u root -pPASSWORD > /foo/bar/db-`date +%Y-%m-%d`.sql
That's why I am asking for the exact syntax to simply do this...
Backup database to server.
I am currently trying this one...
mysqldump -u DBUSER -pDBPASSWORD --all-databases | gzip -9 -c > /home/yourlogin/randombackupnamehere.`date +%d-%m-%Y`.sql.gz
Last edited by Pete eteP; 10-03-2009 at
and this is the error I get via email for that one
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Its more than likely your naming that is messing things up:
Remove that section, and see what happens. I've used and recommended to others similar syntax:
mysqldump -u username --password='password' db_name > /home/user/file.sql
Make sure you place the single quotes around the password field if your password contains any type of special character.
this one works for me.i have a vbulletin forum
# mysqldump --opt -Q -u dbusername -p dbname > backupname.sql
Gearbox..but that doesn't seem to designate a folder on server to save to?
Does it do this by default?
RSH that could be my prob...I didn't use the quotes.
I WILL get this and report when successful...
This is the error I get.
Username and password I am using are the ones to access cPanel.
mysqldump: Got error: 1045: Access denied for user 'cpanelusernamehere'@'localhost' (using password: YES) when trying to connect
you should be having a separate database username and dbase password.it is different from your cpanel account.
Originally Posted by
Z Web Design
this will create the backup in the directory you are presently in.
Originally Posted by
Z Web Design
you can use the following one.
mysqldump --opt -Q -u dbaseusername -p dbasename > /path/to/backupname.sql
and do i add it is this form
or like this?
This is what I had. No joy.
mysqldump -u cpaneluser_cpaneluser_dbname --password='cpanelpassword' Cpaneluse_dbname > /home/cpaneluser/backups/file.sql
Please spell it out exactly using say
cpanel username of cpanelusername
database password as dbpassword
cpanel password as cpanelpassword
dbusername as dbusername
There are quite a few interpretations of this.. so I want to get it right.
/cpanleusername/bin/mysqldump ľopt ľall-databases -u cpanelusername -pcpanelpassword > /cpanelusername/backups/db.sql
This one give an email message:
/bin/sh: /cpanelusername/backups/db.sql: No such file or directory
For accessing the database, you won't be able to use the cPanel password/username. cPanel doesn't insert that data into the MySQL username tables.
If you're running cPanel, your files will be located within /home/<your cpanel username>/ so backups will need to go there as well
Remember to replace the parts in  with the required bits, removing the brakets. Your database username will be your cpanel username_dbuser ie cold_user your password will be whatever you used when you made the database. The database name will be your cPanel username_dbname ie cold_db1.
mysqldump -u [database username] -p [database password] [database name] > /home/[your cpanel username]/backup.sql
Hope that helps,
mysqldump -u cold_user -p mypass cold_db1 > /home/cold/backup.sql
appreciate your perseverance.
mysqldump -u paperflo_pete -p databasepassword paperflo_database > /home/paperflo/backups/backup.sql
Enter password: mysqldump: Got error: 1045: Access denied for user 'paperflo_pete'@'localhost' (using password: NO) when trying to connect
Maybe its blocked or not allowed by my reseller host?
mysqldump -u paperflo_pete --password='password' paperflo_database > /home/paperflo/backups/backup.sql
Make sure to change the password to your current db pass.
I will contact my reseller host and ask them.
I will report back the outcome.
Appreciate the help.
Still get this...
Originally Posted by
mysqldump: Got error: 1045: Access denied for user 'paperflo_pete'@'localhost' (using password: YES) when trying to connect
Sounds like you have the wrong password then. If you have forgot the password, you should be able to locate it in your database connection settings for the script you are using.
Or just add a new username in cPanel.
Z Web: That error is actually telling you that your password or username are wrong. You need to make sure that you've applied the user account to the database you want to use.
yes i did apply and did set a new user and database.
Reseller host also says should work so I will persist.
We'll get there....:-)
mysqldump -u DATABASEUSER -pDATABASEPASSWORD DATABASENAME > DATABASEBACKUPFILE.sql
I think I was putting in the database password as databasename_password instead of just password.
But to be honest I have tried so many variables I'm not sure.
Now I will mod this slowly adding date to backup file etc until I get it how I want it.
I have noted this working one down for future reference too!
1000 thanks for your patience!
Glad to see you got it sorted
I gave up on this 12 mths ago.
I think it was worth the pain this time.
It's an essential I should know how to do.
Thanks again for all your help
And I just got the gzip version to work now too. :-)
By dotham in forum Hosting Security and Technology
Last Post: 12-25-2008, 01:18 PM
By qualityinterfaces in forum Hosting Software and Control Panels
Last Post: 08-03-2007, 02:17 AM
By keliix06 in forum Programming Discussion
Last Post: 01-10-2007, 02:12 PM
By Abdo-sa in forum Hosting Security and Technology
Last Post: 11-05-2006, 07:39 AM
By Jim_UK in forum Hosting Security and Technology
Last Post: 10-21-2002, 08:37 PM