Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Django sync env

django-sync-env is a Django app for backing up and restoring Django databases and media assets. It also supports secondary backup destinations and optional BagIt artifact backups.

Detailed documentation is in the "docs" directory (it's a work in progress).

Requirements:

  • configurable backups and restore which can be run on demand, celery cron or in dev.
  • support s3 bucket and file storage options first, add azure blob storage later
  • interactive prompts for local dev
  • command-line options with --noinput for CI/CD and automation
  • restore latest option for media and backups for X env
  • backup before restore option

Setup

  1. Add "django_sync_env" to your INSTALLED_APPS setting like this:
   INSTALLED_APPS = [
   ...,
   "django_sync_env",
   ]
  1. Configure the app via a settings file .typically ./settings/partial/sync_env.py for base configuration, don't forget to import this file via your base.py settings file And override any required settings per environment via ./settings/partials/[env].py see example_partials

There is a basic S3 Terraform example for provisioning a private backup bucket and granting a workload principal access to it. Use IAM or equivalent workload authentication where the runtime and storage provider support it; otherwise supply S3 access keys through environment variables or a secrets manager. Apply your organisation's encryption, retention, versioning, and recovery requirements before using it in production.

Feature guides

See the management command reference for command syntax and flags.

  • ./manage.py sync_env_backup_db
  • ./manage.py sync_env_backup_media
  • ./manage.py sync_env_restore_db
  • ./manage.py sync_env_restore_media
  • ./manage.py sync_env_list_db_backups
  • ./manage.py sync_env_prepare_artifact_bag
  • ./manage.py sync_env_validate_artifact_bag
  • ./manage.py sync_env_backup_artifact_bag
  • ./manage.py sync_env_list_artifact_bags
  • ./manage.py sync_env_download_artifact_bag

Artifact bag commands require the optional BagIt dependency:

pip install "django-sync-env[artifacts]"

Supported versions

django-sync-env 1.1.0 supports Python 3.10 through 3.14 and Django 4.2 through 6.1. Release gates cover these representative pairs:

Python Django
3.10 4.2
3.11 5.0
3.12 5.1
3.12 5.2
3.12 6.0
3.13 6.1
3.14 6.1

See Tasks for more details for each of the tasks available.

Development and Publishing

See documentation.

Existing project migration

  • To create a one-off database backup without storing anything on the local server, use the AWS CLI with its normal credential chain. Prefer a workload role or other short-lived credentials where available; otherwise provide the access key and secret key through the process environment.
export AWS_ACCESS_KEY_ID="<backup-user-key>"
export AWS_SECRET_ACCESS_KEY="<backup-user-secret>"

pg_dump --dbname="postgresql://<db-user>:<db-password>@<db-host>:5432/<db-name>" --format=custom | gzip --stdout | aws s3 cp - "s3://<project-name>-<env>-backups/<sensible-name-here>-<db-name>-$(date +'%d-%m-%Y-%H%M%S').psql.bin.gz"
  • After that you can restore this database backup using ./manage.py sync_env_restore_db

TODO:

  • remove command options which we wont use
  • make sure all management commands work with good error logging and handling
  • Update the sync-env-backup command to enable the option to specify particular databases
  • Update the sync-env-backup command to exclude particular tables in particular databases

Release files for django-sync-env 1.1.0rc1

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-sync-env 1.1.0rc1
File Size Uploaded
django_sync_env-1.1.0rc1.tar.gz 36.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-sync-env 1.1.0rc1
File Interpreter ABI Platform
django_sync_env-1.1.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 87.6 kB

Release files / django_sync_env-1.1.0rc1.tar.gz

Download URL django_sync_env-1.1.0rc1.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d76403daef99eb4769460a6a6d5be39454833337f958c4175dc1e1c5d7c699b4
BLAKE2b-256 checksum
How to use checksums
58e19719722915af7380f629091d3a479921e0333e15af9a5bc80cb6f6ade2a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/7.0.14-orbstack-00374-gbbca68e8d741

Release files / django_sync_env-1.1.0rc1-py3-none-any.whl

Download URL django_sync_env-1.1.0rc1-py3-none-any.whl
Size 51.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd4ac785af1b9852b27897cf38ac33f21d12d611a655abcc435d3b9d58021bf9
BLAKE2b-256 checksum
How to use checksums
68162846cbe2011ee88cfb8bb0b7db20e1f548c5b62a20cc254bf6e00261776b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/7.0.14-orbstack-00374-gbbca68e8d741

Release history Release notifications | RSS feed

1.1.0

2 release files

This release

1.1.0rc1 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

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