Solved

Mysql DB on CentOS, daily cron job to dump DB?

Posted on 2011-03-11
2
1,059 Views
Last Modified: 2012-05-11
Say, I'm looking for a way to do a 3am backup of a MySQL DB on  a CentOS machine to a  remote machine.
0
Comment
Question by:shaunwingin
2 Comments
 
LVL 5

Accepted Solution

by:
tiago_aviz earned 500 total points
ID: 35107920
1- mysqldump -uroot -ppassword --all-databases > /backup/backup.sql
2- create an account named backup on the remote CentOS system
3- on the centos that has the mysql database, run ssh-keygen -t rsa, answer all the prompts, leave key with no password.
4- on the CenOS that has the mysql database, cat /root/.ssh/id_rsa.pub and paste its contents on the other CentOS system, at /home/backup/.ssh/authorized_keys.
5- the command to copy the database would be scp /backup/backup.sql root@othercentossystem:/home/backup/
6- create a script with commands 1 and 5 somewhere on the first centos box
7- open crontab -e on the mysql centos system and put:

00 3 * * * /place/where/you/saved/the/script/mysql-backup.sh

Save it! You should be good to go.

Hope this helps!
0
 

Author Closing Comment

by:shaunwingin
ID: 35108026
Will Test
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question