简体   繁体   English

实施异地备份php / mysql的最佳方法

[英]Best way to implement offsite backup php / mysql

Looking for some suggestions on best way / possibility of implementing offsite backup of the data in my php app. 寻找有关在我的php应用程序中实现数据异地备份的最佳方法/可能性的建议。

So we have an PHP app that runs on the clients local site, which dumps the MySQL data to a datefile.sql each night. 因此,我们有一个在客户端本地站点上运行的PHP应用程序,每晚将MySQL数据转储到datefile.sql。 what's the best way to get this moved to an external server. 将其转移到外部服务器的最佳方法是什么。

We host a server that currently we manually FTP files to each morning. 我们托管一台服务器,目前每天早上我们手动将它们发送到FTP文件。 How best can we automate this, would we need to hard code in FTP credentials, what if we had multiple clients how could we separate out this so no hard coded credentials are needed. 我们如何最好地自动化它,我们是否需要在FTP凭据中进行硬编码,如果我们有多个客户端怎么办,如何将其分离出来,从而不需要硬编码的凭据?

The ideal situation would be to have a MySQL instance running on the external server that the local clients server replicates the data across to this on the fly and back if required. 理想的情况是让一个MySQL实例在外部服务器上运行,本地客户端服务器可以将数据即时复制到该实例上,并在需要时将其复制回来。 Not even sure that's possible? 甚至不确定这是否可能?

Happy to try and explain further if needed. 乐于尝试并在需要时进一步解释。

Thanks, 谢谢,

Any ideas? 有任何想法吗?

You can achieve this using cron. 您可以使用cron来实现。 Just create a cronjob and schedule it to run when you need it to. 只需创建一个cronjob并安排它在需要时运行即可。 For all the file-transfering hasle, you may use rsync (which also provides ways to transfer only different data etc). 对于所有文件传输麻烦,您可以使用rsync(它还提供了仅传输不同数据等的方式)。

Also, I think that MySQL has a build-in feature for replication and backups, but I'm not sure about this or how to configure it.. 另外,我认为MySQL具有用于复制和备份的内置功能,但是我不确定这一点或如何配置它。

您可以创建一个在服务器上运行的bash脚本,在晚上由cron调用,该脚本使用rsync从客户端服务器中获取sql文件(如果您与它们之间有ssh连接),然后将其还原到您自己的计算机上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM