使用 Mercurial 备份 Mysql
可以服用吗?我在谷歌上进行了研究,我发现很少有文章,但都是德语和其他语言的,所以不太理解。
如果我们能够使用 Mercurial [at localhost] 将 mysql 备份从服务器到本地主机,那就太好了。也许使用远程Mysql连接等,你知道有什么方法可以做到这一点吗?是否可以?
谢谢!!问候...
is it possible to take ? I researched at Google, I found few articles, but in German and other langs, so didnt understand well.
It would be great if we could get mysql back-up from server to localhost with Mercurial [at localhost]. maybe with Remote Mysql Connection, etc. do you know any way of doing this? is it possible?
Thanks!! Regards...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您想要在版本控制存储库中存储定期备份,需要执行三个步骤:
设置要存储数据库快照的 Mercurial 存储库。
以文件格式获取数据库。最简单的方法是通过
mysqldump
。仅备份原始数据库表文件是行不通的,因为它们可能处于不一致的状态。将数据库转储提交到版本控制存储库(在您的情况下为 Mercurial)。
最后 2 个步骤是您可能想要自动化的。
Presuming you want to store a periodic backup in a version control repository there are three steps:
Setup the mercurial repository where you want to store the database snapshots.
Get the database in a file format. The simplest way is via
mysqldump
. Just backing up the raw database table files won't work as they may be in an inconsistent state.Commit the database dump into the version control repository, in your case mercurial.
The last 2 steps are what you'll probably want to automate.
我认为这在很多层面上都是毫无意义且危险的做法。但是,如果您考虑一下 VCS 系统的工作原理,它会在当前版本和以前(或基准)版本之间进行比较,然后如果您恢复到以前的修订版,它(VCS)会将文件写到目录中。首先,如果您使用数据库执行此操作,然后进行比较,您会看到什么?您获得的数据库中的数据视图是通过 DBMS 进行过滤的,因此比较原始文件是没有意义的。在第二种情况下,如果您恢复了对工作数据库的修订,我认为除了废弃的数据库之外您不会得到太多。另外,视图、存储过程、触发器等会发生什么情况?
我唯一一次考虑类似的事情是仅转储数据库结构,不转储数据,并对它进行 VCS,这样我就可以比较以查看进行了哪些结构更改。然而,加强团队沟通解决了这个问题。
处理数据库的方法是使用一组适当的备份程序和过程,不要忘记一组恢复程序和过程以及测试制度以确保您的备份全部正常工作。
I think this would be a pointless and dangerous exercise on a number of levels. But if you think about how a VCS system works, it makes the diff between the current version and the previous (or the benchmark) version and then if you revert to a previous revision it (the VCS) writes out the files to the directory. In the first instance if you did this with a database and then did a diff what would you see? The view you get of the data in a database is filtered through the DBMS so diffing raw files would be pointless. In the second instance if you restored a revision to a working database i don't think you would get much except a trashed database. Also what would happen to views, stored procedures, triggers etc.?
The only time i considered anything like this was to dump the database structure only, no data, and VCS it so i could diff to see what structural changes had been made. However ramping up the communications in the team solved this problem.
THe way to deal with databases is to use a proper set of backup programmes and procedures, not forgetting a set of restore programmes and procedures and a test regime to make sure your backups are all working.