开发者

Backing up a database to SVN

I want to start getting into this whole SVN thing ... I have a mac server which ships with svn, one question i do have though.

If im putting in sites that i develop, i understand that the files have to be added, but how do you go about b开发者_StackOverflowacking up the database accossiated with the site?

If anyone could let me know how they go about this, that would be great.

Cheers


The point here is that you don't just want backups of your db schema and static data, you want to be able to reproduce a specific state of the schema at a given revision.

Here is a solutions which I use, it's not the best because it needs your diligence, but it is an easy and well working solution.

In a subfolder called "db" I have three files which are versioned under SVN:
- schema.sql
- start-data.sql
- increments.sql

When there are bigger changes or "tags" branched off, I take a new export of the schema and the start-data and empty the increments.sql.

When there are small changes in the schema, I add the respective queries to the increments.

This way I can always reproduce a given DB state for every given revision. If I don't forget to ammend the increments, that is.


I don't "backup" databases in a version control system. I use whatever the "best practice" is to backup a database (and it's different for different dbms). Sometimes it's a simple dump on a cron. Other times I simply use a tool which manages it for me.

I do check-in and managed my ddl SQL (schema) and dml SQL for invariant data (static data) into flat sql files in a vcs. I generally do this in the same vcs as the source code so they can be versioned together and I can always know what the schema looked like for a particular revision.


How to dump a backup depends on what type of database you are using. For mysql you can dump your whole schema and data to a single file with the mysqldump command. Then put this file under version control, and update it regularly.

I don't know the size of your database, but for a typical wordpress/joomla/drupal site the size of the database usually isn't big enough that I would care about incremental backup, just do a complete dump each time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜