Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using rsync to backup MySQL

Tags:

unix

mysql

rsync

I use the following rsync command to backup my MySQL data to a machine within the LAN network. It works as expected.

rsync -avz /mysql/ root:[email protected]:: /root/testme/

I just want to make sure that this is the correct way to use rsync.

I will also like to know if the 5 minute crontab entry for this will work.

like image 733
shantanuo Avatar asked Sep 07 '09 11:09

shantanuo


1 Answers

  1. don't use the root user of the remote machine for this. In fact, never directly connect to the root user, that's a major security risk. In this case, simply create a new user with few privileges that may only write to the backup location
  2. Don't use a password for this connection, but instead use public-key authentication
  3. Make sure that MySQL is not running when you do this, or you can easily get a corrupt backup.
  4. Use mysqldump to create a dump of your database while MySQL is running. You can then safely copy that dump.
like image 108
Joachim Sauer Avatar answered Oct 09 '22 19:10

Joachim Sauer