Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1103
  • Last Modified:

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

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
shaunwingin
Asked:
shaunwingin
1 Solution
 
tiago_avizCommented:
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
 
shaunwinginAuthor Commented:
Will Test
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now