使用rsync备份MySQL
我使用以下 rsync 命令将 MySQL 数据备份到 LAN 网络内的计算机上。它按预期工作。
rsync -avz /mysql/ root:[email protected]:: /root/testme/
我只是想确保这是使用 rsync 的正确方法。
我还想知道 5 分钟的 crontab 条目是否有效。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
root
用户。事实上,永远不要直接连接到 root 用户,这是一个主要的安全风险。在这种情况下,只需创建一个具有很少权限的新用户,该用户只能写入备份位置mysqldump
创建一个MySQL 运行时转储数据库。然后您可以安全地复制该转储。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 locationmysqldump
to create a dump of your database while MySQL is running. You can then safely copy that dump.我发现进行 MySQL 备份的更好方法是使用复制功能。
将您的备份计算机设置为主计算机的从属计算机。然后,每笔交易都会自动镜像。
您还可以关闭从属服务器并从它执行到磁带的完整备份。当您重新启动从站时,它会再次与主站同步。
I find a better way of doing backups of MySQL is to use the replication facility.
set up you backup machine as a slave of your master. Each transaction is then automatically mirrored.
You can also shut down the slave and perform a full backup to tape from it. When you restart the slave it synchronises with the master again.
我真的不知道你的 rsync 命令,但我不确定这是使用 MySQL 进行备份的正确/最佳方法;你可能应该看看手册的这一页:6.1。数据库备份
数据库备份并不一定像人们想象的那么简单,考虑到诸如锁、延迟写入以及 MySQL 可以对其数据进行的任何优化等问题......特别是如果您的表没有使用 MyISAM 引擎。
关于“5 分钟 crontab”:您每五分钟进行一次备份吗?如果您的数据如此合理,您可能应该考虑其他措施,例如复制到另一台服务器,以始终拥有最新的副本。
I don't really know about your rsync command, but I am not sure this is the right/best way to make backup with MySQL ; you should probably take a look at this page of the manual : 6.1. Database Backups
DB backups are not necessarily as simple as one might think, considering problems suchs as locks, delayed write, and whatever optimizations MySQL can do with its data... Especially if your tables are not using the MyISAM engine.
About the "5 minutes crontab" : you are doing this backup every five minutes ? If your data is that sensible, you should probably think about something else, like replication to another server, to always have an up-to-date copy.