With my continuing my interest in redmine / ChiliProject, I’m really wanting a way of backing up my data that is database independent. I did a bunch of searching around, and the best solution I found was here. However, it appears a little out dated, and didn’t work in Rails 2.3 for a few reasons:
- There isn’t always a 1:1 mapping between tables and models. (Example: many-many relationships create extra tables).
- The excluded tables list was outdated (probably from an earlier Rails)
There were also some comments about the export being quite slow. This could have been because every record of every table was loaded up in an ActiveRecord model instance before being dumped to the YML files.
I addressed these issues and made a new version. Can’t attach a file to this blog, so it’s on pastie for now: http://pastie.org/1877530
I’ve tested this getting data out of mysql and into sqlite3 and that works just fine. This is really handy for getting the data into a test environment quickly without having to set up more mysql databases, users, etc.
: I’m testing this for Rails 2.3.11 as Redmine and ChiliProject are Rails 2.3.x apps.
If this saves you some time, or could be improved, please let me know.