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!
Have a look at Minion task migrations https://github.com/kohana-minion/tasks-migrations
精彩评论