Django/MySQL database backup script

I’m sure everyone has one of these lying around, but here’s mine in case you are as lazy a programmer as I usually am. The only thing Django-specific about it is that it reads your database configuration directly out of your settings file.

If you run this via cron it will automatically create its backup directory and a zipped SQL dump with the name of the current day of the week. If one already exists, it simply overwrites it. This means you’ll have a week’s worth of daily rolling backups. If you need more granularity, add a timestamp to the datestamp. If you need more persistent backups, switch to a full date scheme.