I’m wondering what solutions other folks use for backup and restoration of their Django sites?
Seems like there are two main paths to go down here:
- Use the functionality of your infrastructure - i.e. above Django on the stack.
- Use Django aware tooling - most likely a management command or series of management commands.
1 seems to be most appropriate for deployments on complicated infrastructure. For me, I don’t manage anything super duper complex so I’m more interested in 2. I also like to keep my sites as infrastructure agnostic as possible so I don’t get locked into any particular vendor.
I’ve been looking around the community and haven’t found an existing solution that satisfies all my needs so I’m considering rolling a new library. My needs being:
- Backup/restore from any Django storage implementation.
- Optionally encrypt backups w/ overridable/pluggable encryption strategies
- Backup all website/python state: databases (all flavors, using native dumps), python dependency versions, media files, and all other custom state. To satisfy the custom state requirement the command will need to have a plugin system.
- Restore from specific timepoints.
- Configurable backup retention strategy (optional, seems appropriate this could be handled external to the tool)
- Warnings and blocks configurable in settings on restore to avoid accidentally wiping a production system.
- Warnings when restoring to a snapshot made on differing python stack.
- A single command should backup everything, but certain artifacts can be elided from the backup based on CLI parameters. (e.g. ./manage.py backup or ./manage.py backup database media)
- Incremental backups - diffs to save file space. Not a deal breaker but would be awesome.
- Optional atomicity - i.e. lock the site during backup so disk state and db state are consistent. (not a dealbreaker but nice to have)
Aside from platform agnostic backups to avoid vendor lock-in my primary use case is to be able to pull production state into a local development environment easily.
These are the existing tools I’ve found that still seem to be alive:
- django-dbbackup - this is closest tool to what I’m looking for, but theres no plugin system for custom state and each state artifact is treated separately.
- django-pgclone - just for postgres databases
- django-pg-copy - just for postgres databases
Am I missing anything?
It’d be nice if there were a generic CLI scaffold custom state backup/restore needs could be attached to so we didn’t have to separately reinvent the storage/encryption/snapshot bits. Do others agree?