Backup mysql database

How can I make automatic backup for mysql database in ubuntu linux.
Jose BredariolPMPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Assuming you want a daily backup, put an entry in /etc/cron.daily to execute a shell script.  For example, to run the backup at 11:30pm put:
 30 23 * * * /root/mysqldump.sh

In the shell script (located at /root/mysqldump.sh) put all the database backup commands you need using the mysqldump utility -ex:
#!/bin/bash

#backup your local db server
mysqldump -u root -pmysql123 –all-databases | gzip > /root/db_backups/MySQLDB_`date ‘+%m-%d-%Y’`.sql.gz

#backup a remote server (ip=10.10.10.10)
mysqldump -h 10.10.10.10 -u root -pmysql123 –all-databases  | gzip > /root/db_backups/MySQLDB-10.10.10.10_`date ‘+%m-%d-%Y’`.sql.gz

Open in new window


FYR:
http://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job
http://www.comentum.com/mysqldump-cron.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jose BredariolPMPAuthor Commented:
Thanks
theGhost_k8Database ConsultantCommented:
Even though mysqldump provides you logical backup but it's not efficient solution as database become larger. There are plenty of other tools available, I would mention two of them.

If you want logical backup, mydumper will be quicker.
If you need physical backup, you can use  holland backup framework with percona's xtrabackup to setup your backups.

Hope this helps.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Storage Software

From novice to tech pro — start learning today.