{% extends "admin/dbs/wiki/_layout.html" %} {% block wiki %}
pip install "django-dbs[guard]"
The guard extra installs scikit-learn for the session guard. A project that
does not run the guard needs only pip install django-dbs.
INSTALLED_APPS = [..., "django.contrib.admin", "dbs"]
MIDDLEWARE = [..., "dbs.security.middleware.DBSSecurityMiddleware"]
DBS_BACKUP_DIR = "/var/backups/myproject"
python manage.py migrate
django.contrib.admin mounts this panel; the middleware runs the session
guard and goes below AuthenticationMiddleware. DBS_BACKUP_DIR is
where this server keeps its backups, at most five. Upgrading from 0.2.x needs that
migrate — 0.3.0 added tables.
The backup passphrase is derived from SECRET_KEY and
must never change: older backups would no longer open. See
Passphrases.
DBS backs up every model it finds, except models with managed = False. To
configure a model, register it in a dbs.py inside an app; once anything is
registered, only registered models are backed up:
from dbs import backup_registry, FieldType, ModelBackup
from myapp.models import Invoice
@backup_registry.register(Invoice)
class InvoiceBackup(ModelBackup):
overrides = {"render_cache": FieldType.EXCLUDE}
From this panel, use Take a backup: it writes the backup to
DBS_BACKUP_DIR in the background and offers it for download once it is done.
From a shell:
python manage.py dbs backup /var/backups/app.dbs
It refuses a path that already exists, and stops when a source file is missing or
unreadable, naming it; --allow-missing-files backs up without it.
python manage.py dbs schedule --interval 6h --output-dir /var/backups --keep 5
Run one scheduler per output directory. Two loops sharing a directory race on retention.
{% endblock %}