Django DBBackup is an active and frequently updated (multiple minor releases per quarter) Django application that provides management commands to simplify backing up and restoring project databases and media files. It supports various storage backends like local filesystem, Amazon S3, Dropbox, and any Django-supported storage, offering features such as GPG encryption, compression, remote archiving, and the ability to set up automated backups via Crontab or Celery.
pip install django-dbbackupVerified import paths — ran on the pinned version, not inferred.
1. Add 'dbbackup' to your `INSTALLED_APPS` in `settings.py`. 2. Configure a `STORAGES['dbbackup']` entry to define where your backups will be stored. It's recommended to use a dedicated directory, not your `MEDIA_ROOT`, to avoid accidental public exposure. 3. Run `python manage.py dbbackup` to create a database backup and `python manage.py mediabackup` for media files. Use `dbrestore` and `mediarestore` to restore.
Migrate your storage configuration to use Django's standard `STORAGES` setting under the 'dbbackup' key. Refer to the official documentation's 'Storage' section for examples.
Always restore backups to a database using the same engine they were created from. If you need to migrate between database types, use Django's `dumpdata` and `loaddata` commands.
Ensure the necessary database client tools (e.g., `postgresql-client` for `pg_dump`) are installed and their executables are accessible in the PATH of the environment running `manage.py dbbackup`. In Docker, this often means installing them in the same container as your Django app or executing the backup from the database container itself.
Always configure `STORAGES['dbbackup']` with a dedicated and distinct storage location, preferably with restricted permissions, separate from your `MEDIA_ROOT`.