Skip to main content

Management commands to help backup and restore a project database and media

Project description

Django Database Backup

https://github.com/django-dbbackup/django-dbbackup/actions/workflows/build.yml/badge.svg Documentation Status https://coveralls.io/repos/django-dbbackup/django-dbbackup/badge.svg?branch=master&service=github

This Django application provides management commands to help backup and restore your project database and media files with various storages such as Amazon S3, Dropbox, local file storage or any Django storage.

It is made for:

  • Ensure your backup with GPG signature and encryption

  • Archive with compression

  • Deal easily with remote archiving

  • Great to keep your development database up to date.

  • Use Crontab or Celery to setup automated backups.

Docs

See our official documentation at Read The Docs.

Why use DBBackup

This software doesn’t reinvent the wheel, in few words it is a pipe between your Django project and your backup storage. It tries to use the traditional dump & restore mechanisms, apply compression and/or encryption and use the storage system you desire.

It gives a simple interface to backup and restore your database or media files.

Management Commands

dbbackup

Backup your database to the specified storage. By default this will backup all databases specified in your settings.py file and will not delete any old backups. You can optionally specify a server name to be included in the backup filename.

Usage: ./manage.py dbbackup [options]

Options:
  --noinput             Tells Django to NOT prompt the user for input of any
                        kind.
  -q, --quiet           Tells Django to NOT output other text than errors.
  -c, --clean           Clean up old backup files
  -d DATABASE, --database=DATABASE
                        Database to backup (default: everything)
  -s SERVERNAME, --servername=SERVERNAME
                        Specify server name to include in backup filename
  -z, --compress        Compress the backup files
  -e, --encrypt         Encrypt the backup files
  -o OUTPUT_FILENAME, --output-filename=OUTPUT_FILENAME
                        Specify filename on storage
  -O OUTPUT_PATH, --output-path=OUTPUT_PATH
                        Specify where to store on local filesystem
  -x EXCLUDE_TABLES, --exclude-tables=EXCLUDE_TABLES
                        Exclude tables data from backup (-x 'public.table1, public.table2')

dbrestore

Restore your database from the specified storage. By default this will lookup the latest backup and restore from that. You may optionally specify a servername if you you want to backup a database image that was created from a different server. You may also specify an explicit local file to backup from.

Usage: ./manage.py dbrestore [options]

Options:
  --noinput             Tells Django to NOT prompt the user for input of any
                        kind.
  -d DATABASE, --database=DATABASE
                        Database to restore
  -i INPUT_FILENAME, --input-filename=INPUT_FILENAME
                        Specify filename to backup from
  -I INPUT_PATH, --input-path=INPUT_PATH
                        Specify path on local filesystem to backup from
  -s SERVERNAME, --servername=SERVERNAME
                        Use a different servername backup
  -c, --decrypt         Decrypt data before restoring
  -p PASSPHRASE, --passphrase=PASSPHRASE
                        Passphrase for decrypt file
  -z, --uncompress      Uncompress gzip data before restoring

mediabackup

Backup media files by get them one by one, include in a TAR file.

Usage: ./manage.py mediabackup [options]

Options:
  --noinput             Tells Django to NOT prompt the user for input of any
                        kind.
  -q, --quiet           Tells Django to NOT output other text than errors.
  -c, --clean           Clean up old backup files
  -s SERVERNAME, --servername=SERVERNAME
                        Specify server name to include in backup filename
  -z, --compress        Compress the archive
  -e, --encrypt         Encrypt the backup files
  -o OUTPUT_FILENAME, --output-filename=OUTPUT_FILENAME
                        Specify filename on storage
  -O OUTPUT_PATH, --output-path=OUTPUT_PATH
                        Specify where to store on local filesystem

mediarestore

Restore media files from storage backup to your media storage.

Usage: ./manage.py mediarestore [options]

Options:
  --noinput             Tells Django to NOT prompt the user for input of any
                        kind.
  -q, --quiet           Tells Django to NOT output other text than errors.
  -i INPUT_FILENAME, --input-filename=INPUT_FILENAME
                        Specify filename to backup from
  -I INPUT_PATH, --input-path=INPUT_PATH
                        Specify path on local filesystem to backup from
  -e, --decrypt         Decrypt data before restoring
  -p PASSPHRASE, --passphrase=PASSPHRASE
                        Passphrase for decrypt file
  -z, --uncompress      Uncompress gzip data before restoring
  -r, --replace         Replace existing files

Contributing

All contribution are very welcomed, propositions, problems, bugs and enhancement are tracked with GitHub issues system and patches are submitted via pull requests.

We use GitHub Actions as continuous integration tools.

Tests

Tests are stored in dbbackup.tests and for run them you must launch:

python runtests.py

In fact, runtests.py acts as a manage.py file and all Django command are available. So you could launch:

python runtests.py shell

For get a Python shell configured with the test project. Also all test command options are available and usable for run only some chosen tests. See Django test command documentation for more information about it.

There are even functional tests:

./functional.sh

See documentation for details about

To run the tests across all supported versions of Django and Python, you can use Tox. Firstly install Tox:

pip install tox

To run the tests just use the command tox in the command line. If you want to run the tests against just one specific test environment you can run tox -e <testenv>. For example, to run the tests with Python3.9 and Django3.2 you would run:

tox -e py3.9-django3.2

The available test environments can be found in tox.ini.

Publishing

To build a source distribution and wheel:

tox -e build

To publish to PyPI:

tox -e upload

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dbbackup-4.0.0b0.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

django_dbbackup-4.0.0b0-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file django-dbbackup-4.0.0b0.tar.gz.

File metadata

  • Download URL: django-dbbackup-4.0.0b0.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for django-dbbackup-4.0.0b0.tar.gz
Algorithm Hash digest
SHA256 aca81265dab91b3a73c3a730cf168d946621c28002f1321d4c33910ba7c63634
MD5 9b630fc6ff23e545c717d090222db0cb
BLAKE2b-256 5fbb5d45fbaf8f95676b83df5a67bbff54b4e786c032002f9e08ede9376f2eaf

See more details on using hashes here.

Provenance

File details

Details for the file django_dbbackup-4.0.0b0-py3-none-any.whl.

File metadata

  • Download URL: django_dbbackup-4.0.0b0-py3-none-any.whl
  • Upload date:
  • Size: 52.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for django_dbbackup-4.0.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 66a74679bfea3385a52110a7c7f14de63adf25a01be8e2de401d145988bd0abf
MD5 044545f7f42e15601942f55bce4b724f
BLAKE2b-256 9cdfe03bb3316b84e49aca8cd720b8a5751960aec2be4f58dd0f149393315f4a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page