Django n00b here. I was wondering, are django fixtures a reliable way to backup my data, instead of actually backup up the database? What if my database is very large?
Thanks.
Django n00b here. I was wondering, are django fixtures a reliable way to backup my data, instead of actually backup up the database? What if my database is very large?
Thanks.
Fixtures are intended to house data that should be populated into the database once a new model/entire app is added. This is really for the inevitable move of your code from development to production, where you will need this same data available immediately after syncing the database.
Now, based on this function, you could presumably create a base fixture consisting of essentially a database backup, but that's not really what fixtures are intended for.
Your best bet is to follow the standard practice of keep consistent and frequent SQL backups of your database through the use of cron or some other scheduling app.
Using fixtures as your db backup will work as long as your db is small. The problem with fixtures is that they take a long time to dump and load. If your models and apps are in flux, that means that each syncdb has to reload ALL your data for all your apps. You can avoid this by not putting them in the fixtures directory. And then you have to selectively (manually) load the fixtures you need when you change their models. So for large databases or projects where your models are constangly changing, it's much better to use south
to manage your migrations and avoid database reloads, whether or not you maintain your backups in fixtures or sql dumps.
And in django 1.4 datadump
and dataload
weren't even possible unless the data for each of your models (tables) could fit in RAM in its entirety, which means you probably wouldn't be using persistent storage for your db anyway.
For example, if you use Chris Patt's approach and your db is postgres, for me pg_dumpall
takes less than a 30 seconds on an 6GB database. datadump
would churn through swap for hours if you don't have sufficient RAM.