Web架构-如何高效保存和恢复DB快照
我需要一些关于为网站后端创建/保存/恢复数据库快照的最佳方式的建议。
以下是技术细节(但我猜答案可以与 API 无关):
- PHP : 5.3
- PHP 框架 : Kohana 3.*
- DB : MySQL 5.1
我的 web 应用程序可以比作一个简单的库存管理工具。 DB 包含带有价格的产品。在某些时候,用户会对这些产品执行操作(例如订单)。此时,仅使用相关项目生成数据库的部分快照。稍后,在主数据库中,产品可能会被删除或其价格可能会发生变化。
我的目标是存储这些快照,然后使用为完整数据库编写的代码恢复它们,以最大限度地减少代码开发和复杂性。
由于我的数据库最初位于 MySQL 中,因此我计划将部分数据库转储到文本文件中并对其进行压缩。要恢复它,请解压缩并将其重新注入到另一个数据库中(不要覆盖属性已更改的同名项目)。
- 这是创建和存储数据库部分的正确方法吗?或者智能设计能更有效地处理这个问题吗?
- Kohana 具体:如何处理 ORM 和多个 DB 连接?对象仅绑定到一个数据库。默认数据库连接似乎是在会话中指定的。不幸的是,一次似乎只允许一个会话...
谢谢!
I need some advices on the best way to create/save/restore database snapshots for a website backend.
Here are the technical details (but I guess answers can be API independant) :
- PHP : 5.3
- PHP framework : Kohana 3.*
- DB : MySQL 5.1
My webapp can be compared to a simple stock managment tool. The DB contains products with prices. At some point, users perform actions on these products (eg an order). At this moment, a PARTIAL snapshot of the DB is produced with only the related items. Later, in the main DB, products may be deleted or their price might change.
My goal is to store these snapshots, then, later, restore them using the code written for the full DB, to minimize code development and complexity.
As my DB is originally in MySQL, I plan to dump parts of the DB in a text file and zip it. To restore it, unzip, and reinject it in another DB (to not override items with the same names whose attributes have changed).
- Is this an correct way to create and store parts of a DB? Or do smart designs handle that more efficiently?
- Kohana specific : How to deal with ORM and multiple DB connections ? Objects are bound to only one DB. The default DB conection seems to be specfied in the session. Unfortunatelly, only one session seems to be allow at a time...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 Minion 任务迁移 https://github.com/kohana-minion/tasks-migrations< /a>
Have a look at Minion task migrations https://github.com/kohana-minion/tasks-migrations