Skip to main content

django-offsite-backup

CI PyPI Python

Off-site backups of a Django project's databases, media and deployment configuration: compressed, encrypted to a public key the server holds (so the server can write a backup and cannot read one), uploaded to S3 with Object Lock COMPLIANCE read back on every object, and rotated by whole nights — never by age alone, never by object count.

  • PostgreSQL (one database, a list, or a list computed at run time), plain or custom format; MySQL and MariaDB (one transaction); SQLite (the online backup API)
  • media from a directory, a Docker volume (mounted or not), an S3 bucket or any Django storage, in volumes of whole files, each with a manifest of what it holds
  • the deployment directory plus the environment rebuilt from a list of variable names
  • age encryption to one or more recipients (the binary, or pyrage without it); zstd compression before it
  • several stores at once — a local copy and S3 — each read back, locked and rotated on its own
  • a pass before every deploy without media (fast, and never mistaken for a night)
  • a once-per-night guard, and a morning check that notices the night that never ran
  • every outcome said in Telegram (or through django-aiogram, a webhook, or a log), in one glanceable format
  • restore that downloads, decrypts, verifies — and, on request, loads a database; one database, or one media file or folder without downloading the rest
  • a monthly restore drill: the newest backup restored into a throwaway database, every table counted, reported
  • each kind's age for a monitor: an exit code for cron and healthchecks, a Prometheus textfile
  • system checks that refuse a half-configured machine by name and a bucket without a lock
  • the same passes on a server with no Django project, from the offsite-backup command and a TOML file

Every backend is a dotted path in settings and imported only when named; each driver is an extra. A base install pulls nothing — Django included, which a Django project brings itself.

30-second setup

pip install "django-offsite-backup[s3,telegram]"
import os

INSTALLED_APPS = [..., 'offsite_backup']

OFFSITE_BACKUP = {
    'PREFIX': 'acme/prod',
    'ENV': 'prod',
    'STORE': {
        'BACKEND': 'offsite_backup.stores.s3.S3Store',
        'ENDPOINT_URL': os.environ.get('BACKUP_S3_ENDPOINT_URL', ''),
        'BUCKET': os.environ.get('BACKUP_S3_BUCKET', ''),
        'ACCESS_KEY': os.environ.get('BACKUP_S3_ACCESS_KEY', ''),
        'SECRET_KEY': os.environ.get('BACKUP_S3_SECRET_KEY', ''),
        'LOCK_DAYS': 13,
    },
    'ENCRYPTION': {
        'BACKEND': 'offsite_backup.encryption.age_cli.AgeCli',
        'RECIPIENTS': [os.environ.get('BACKUP_AGE_RECIPIENT', '')],
    },
    'DATABASES': {'BACKEND': 'offsite_backup.databases.postgres.PostgresSource'},
    'MEDIA': [{'BACKEND': 'offsite_backup.media.filesystem.DirectorySource'}],
    'CONFIG': {'BACKEND': 'offsite_backup.config.paths.PathsSource', 'PATHS': ['/app/deploy']},
    'RETENTION': {'KEEP_NIGHTS': 14},
    'NOTIFY': [
        {
            'BACKEND': 'offsite_backup.notifiers.telegram.TelegramNotifier',
            'TOKEN': os.environ.get('BACKUP_TG_TOKEN', ''),
            'CHAT_ID': os.environ.get('BACKUP_TG_CHAT_ID', ''),
        }
    ],
}

With every credential empty (a development machine) backups are off and the commands say "nothing to do". With some set and some missing, manage.py check names each one.

python manage.py check --deploy                                  # bucket lock, pg_dump version, mounts
python manage.py backup_offsite                                  # a pass now
python manage.py backup_offsite --without-media --reason deploy  # before a migration
python manage.py backup_check                                    # the morning check
python manage.py backup_status                                  # each kind's age; exit 1 when stale
python manage.py backup_list
python manage.py backup_restore --stamp latest --identity key.txt --into ./restore
python manage.py backup_drill                                    # restore into DRILL['DATABASE'], count, report

On a server without Django: pipx install 'django-offsite-backup[cli,s3,telegram]', the same keys in a TOML file, and offsite-backup --config backup.toml run --reason nightly.

The image needs pg_dump (at least the server's major), zstd and age. The bucket must be created with Object Lock and a default COMPLIANCE rule of LOCK_DAYS days.

Documentation

https://corneizer.github.io/django-offsite-backup/ — installation, every setting, S3 providers, retention and locks, restore drills, monitoring, running without Django, the security model, troubleshooting by check code, and a page for AI assistants wiring the package into a project.

License

MIT

Metadata

Release files for django-offsite-backup 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-offsite-backup 0.4.1
File Size Uploaded Provenance Actions
django_offsite_backup-0.4.1.tar.gz 239.2 kB With provenance Details for django_offsite_backup-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-offsite-backup 0.4.1
File Interpreter ABI Platform Actions
django_offsite_backup-0.4.1-py3-none-any.whl Python 3 none any Details for django_offsite_backup-0.4.1-py3-none-any.whl

Total release size: 363.5 kB

Release files / django_offsite_backup-0.4.1.tar.gz

Download URL django_offsite_backup-0.4.1.tar.gz
Size 239.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eaff6cebcdcef89729f4f38576ac71056b3a6a3e7f116e384766a5f7a7acf2e0
BLAKE2b-256 checksum
How to use checksums
49d0adfbadefbca544b8c46635a234ad7980a05319c69355e1b7205067c9b5fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / django_offsite_backup-0.4.1-py3-none-any.whl

Download URL django_offsite_backup-0.4.1-py3-none-any.whl
Size 124.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c550dc02473a1cb39db99527ea9c94ece96ec0748f4ed6840f5331ccac1149f
BLAKE2b-256 checksum
How to use checksums
807b04c56abf50879e1ac24448916761df6cb7002ed11a4582555fbe1f95d980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for django-offsite-backup 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_offsite_backup-0.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page