For the next version of my installer, I’d love a generic, DB-agnostic way to perform database backups under Rails. Ideally, I’d be able to serialize (and unserialize) an entire DB to YAML. That way the installer could easily perform backups for people before they upgrade, and the backups would be portable between databases. So someone could start out with SQLite and move to PostgreSQL or MySQL.

The problem is that I don’t actually want to have to write this myself, but I’m not having a lot of luck searching for one. It seems like a pretty obvious tool, though, so perhaps I’m just searching wrong. It shouldn’t be very hard to write the serializer, but the hard part will be getting the deserializer right–with Postgres, you’re going to have to play games to get the DB’s internal sequence numbers set right. Other databases will probably have similar (but different) issues.

Any pointers?