将SQL从一个服务器复制到另一个服务器并忽略重复项

问题描述:

I have 2 websites that offer exactly the same content just with different layouts, Im currently updating both sites daily putting the same content on both, I want to make a php script or something similar and run it on a cron to automatically copy the DB from one server to the other server but i don't want it to duplicate the content already there, The Database has a unique field for which it can check against.

Thanks

我有2个网站提供完全相同的内容,只是布局不同,我目前正在每天更新两个网站 两者的内容,我想制作一个PHP脚本或类似的东西,并在cron上运行它自动将数据库从一个服务器复制到另一个服务器,但我不希望它复制已经存在的内容,数据库有一个 它可以检查的唯一字段。 p>

谢谢 p> div>

You should have only the 1 database, with 2+ templates (skins) for displaying the content. Duplicating the same data in production, when there are no differences between the data sets, is somewhat pointless.

--EDIT-- May 15, 2012 @ 7:06 PM ET If you REALLY want to maintain duplicate production db's, I would suggest a web service that sends the data from one site to another. You can also think about using a trigger in your db. It really does depend on your setup, where the web server(s) are located, the DB server(s), etc.