Database settings

The following databases are supported by this application:

  • SQLite
  • MySQL
  • PostgreSQL
  • MongoDB
  • …and any other that you might implement

By default, DBBackup will try to use your database settings in DATABASES to handle the database, but some databases require custom options so you might want to use different parameters for backups. That’s why we included a DBBACKUP_CONNECTORS setting; it follows the form of the django DATABASES setting:

    'default': {
        'USER': 'backupuser',
        'PASSWORD': 'backuppassword',
        'HOST': 'replica-for-backup'

This configuration will allow you to use a replica with a different host and user, which is a great practice if you don’t want to overload your main database.

DBBackup uses Connectors for creating and restoring backups; below you’ll see specific parameters for the built-in ones.


All connectors have the following parameters:


Absolute path to a connector class by default is:

  • dbbackup.db.sqlite.SqliteConnector for 'django.db.backends.sqlite3'
  • dbbackup.db.mysql.MysqlDumpConnector for django.db.backends.mysql
  • dbbackup.db.postgresql.PgDumpConnector for django.db.backends.postgresql
  • dbbackup.db.postgresql.PgDumpGisConnector for django.contrib.gis.db.backends.postgis
  • dbbackup.db.mongodb.MongoDumpConnector for django_mongodb_engine

All supported built-in connectors are described in more detail below.

Following database wrappers from django-prometheus module are supported:

  • django_prometheus.db.backends.postgresql for dbbackup.db.postgresql.PgDumpBinaryConnector
  • django_prometheus.db.backends.sqlite3 for dbbackup.db.sqlite.SqliteConnector
  • django_prometheus.db.backends.mysql for dbbackup.db.mysql.MysqlDumpConnector
  • django_prometheus.db.backends.postgis for dbbackup.db.postgresql.PgDumpGisConnector


Tables to exclude from backup as list. This option may be unavailable for connectors when making snapshots.


Extension of backup file name, default 'dump'.

Command connectors

Some connectors use a command line tool as a dump engine, mysqldump for example. These kinds of tools have common attributes:


Path to the command used to create a backup; default is the appropriate command supposed to be in your PATH, for example: 'mysqldump' for MySQL.

This setting is useful only for connectors using command line tools (children of dbbackup.db.base.BaseCommandDBConnector)


Same as DUMP_CMD but used when restoring.


String to include as prefix of dump or restore command. It will be added with a space between the launched command and its prefix.


String to include as suffix of dump or restore command. It will be added with a space between the launched command and its suffix.


Environment variables used during command running, default are {}. ENV is used for every command, DUMP_ENV and RESTORE_ENV override the values defined in ENV during the dedicated commands.


Specify if the connector will use its parent’s environment variables. By default it is True to keep PATH.


SQLite uses by default dbbackup.db.sqlite.SqliteConnector.


It is in pure Python and copies the behavior of .dump command for creating a SQL dump.


You can also use dbbackup.db.sqlite.SqliteCPConnector for making a simple raw copy of your database file, like a snapshot.

In-memory database aren’t dumpable with it.


MySQL uses by default dbbackup.db.mysql.MysqlDumpConnector. It uses mysqldump and mysql for its job.


Postgres uses by default dbbackup.db.postgresql.PgDumpConnector, but we advise you to use dbbackup.db.postgresql.PgDumpBinaryConnector. The first one uses pg_dump and pqsl for its job, creating RAW SQL files.

The second uses pg_restore with binary dump files.

They can also use psql for launching administration command.


When doing a restore, wrap everything in a single transaction, so errors cause a rollback.

This corresponds to --single-transaction argument of psql and pg_restore.

Default: True


With PgDumpConnector, it includes tables dropping statements in dump file. PgDumpBinaryConnector drops at restoring.

This corresponds to --clean argument of pg_dump and pg_restore.

Default: True


Set in dbbackup.db.postgresql.PgDumpGisConnector, it does the same as PostgreSQL but launches CREATE EXTENSION IF NOT EXISTS postgis; before restore database.


Path to psql command used for administration tasks like enable PostGIS for example, default is psql.


If you fill this settings PGPASSWORD environment variable will be used with every commands. For security reason, we advise to use .pgpass file.


Username used for launch action with privileges, extension creation for example.


Password used for launch action with privileges, extension creation for example.


MongoDB uses by default dbbackup.db.mongodb.MongoDumpConnector. it uses mongodump and mongorestore for its job.

For AuthEnabled MongoDB Connection, you need to add one custom option AUTH_SOURCE in your DBBACKUP_CONNECTORS.

    'default': {
        'AUTH_SOURCE': 'admin',

Or in DATABASES one:

    'default': {
        'AUTH_SOURCE': 'admin',


Validate documents before inserting in database (option --objcheck in command line), default is True.


Replace objects that are already in database, (option --drop in command line), default is True.

Custom connector

Creating your connector is easy; create a children class from dbbackup.db.base.BaseDBConnector and create _create_dump and _restore_dump. If your connector uses a command line tool, inherit it from dbbackup.db.base.BaseCommandDBConnector

Connecting a Custom connector

Here is an example, on how to easily connect a custom connector that you have created or even that you simply want to reuse:

    'transaction_hooks.backends.postgis': 'dbbackup.db.postgresql.PgDumpGisConnector',

Obviously instead of dbbackup.db.postgresql.PgDumpGisConnector you can use the custom connector you have created yourself and transaction_hooks.backends.postgis is simply the database engine name you are using.