General settings


List of key entries for settings.DATABASES which shall be used to connect and create database backups.

Default: list(settings.DATABASES.keys()) (keys of all entries listed)


Directory to be used for temporary files.

Default: tempfile.gettempdir()


Maximum size in bytes for file handling in memory before write a temporary file on DBBACKUP_TMP_DIR.

Default: 10*1024*1024


When issueing dbbackup and mediabackup, old backup files are looked for and removed.

Default: 10 (backups)


Date format to use for naming files. It must contain only alphanumerical characters, '_', '-' or '%'.

Default: '%Y-%m-%d-%H%M%S'


The template to use when generating the backup filename. By default this is '{databasename}-{servername}-{datetime}.{extension}'. This setting can also be made a function which takes the following keyword arguments:

def backup_filename(databasename, servername, datetime, extension):


This allows you to modify the entire format of the filename, for example, if you want to take advantage of Amazon S3’s automatic expiry feature, you need to prefix your backups differently based on when you want them to expire.

{datetime} is rendered with DBBACKUP_DATE_FORMAT.


Same as DBBACKUP_FILENAME_TEMPLATE but for media files backups.


Controls whether or not django-dbbackup sends an error email when an uncaught exception is received.

Default: True


Hostname needed by django-dbbackup’s uncaught exception email sender for well described error reporting. If you are using ALLOWED_HOSTS you should set DBBACKUP_HOSTNAME to any host from ALLOWED_HOSTS setting. Otherwise django-dbbackup can not send email to the SERVER_EMAIL.

Default: socket.gethostname()

Encrypting your backups

Considering that you might be putting secured data on external servers and perhaps untrusted servers where it gets forgotten over time, it’s always a good idea to encrypt backups.

Just remember to keep the encryption keys safe, too!


You can encrypt a backup with the --encrypt option. The backup is done using GPG.

python dbbackup --encrypt

...or when restoring from an encrypted backup:

python dbrestore --decrypt


  • Install the python package python-gnupg: pip install python-gnupg.
  • You need GPG key. (GPG manual)
  • Set the setting DBBACKUP_GPG_RECIPIENT to the name of the GPG key.


The encryption of the backup file fails if GPG does not trust the public encryption key. The solution is to set the option ‘trust-model’ to ‘always’. By default this value is False. Set this to True to enable this option.


The name of the key that is used for encryption. This setting is only used when making a backup with the --encrypt or --decrypt option.

Database configuration

By default, DBBackup uses parameters from settings.DATABASES but you can make an independant configuration, see Database settings

Storage configuration

You have to use a storage for your backups, see Storage settings for more.