Skip to main content

Database Backup/Restore

This holds the necessary code to use existing database dump tools with gpg to create a full backup of a disk in an encrypted format that can sit on disk more safely than just a text dump of that database.

This library was originally created for RatticWeb which made the decision to not handle encryption within the application itself (encryption is difficult).

https://travis-ci.org/delfick/db_backup.png?branch=master

Usage

There are two commands of importance in this library.

db_backup.commands.backup(database_settings, recipients, backup_dir, gpg_home=None)

This will dump the database as specified by database_settings and create a gpg encrypted file inside the specified backup_dir (using the gpg_home if specified, otherwise whatever the gpg binary on your system wants to use) that can only be decrypted by the specified recipients.

database_settings is a dictionary of {name, engine, port, host, user, password} where all values except name and engine are optional.

engine is one of sqlite3, psql or mysql or the names of the equivalent backends in django.db.backends (i.e. django database dictionary is fine)

recipients is a list of strings where each string is the uid for a key in your gpg homedir.

db_backup.commands.restore(database_settings, restore_from, gpg_home=None)

This will take the gpg encrypted file at restore_from, decrypt it and feed the specified database with it.

database_settings and gpg_home behave like they do for the backup command.

restore_from is just the filepath to the encrypted backup file.

Installation

Use pip!:

pip install db_backup

Or if you’re developing it:

pip install -e .
pip install -e ".[tests]"

Tests

Run the helpful script:

./test.sh

Or if you’re outside a virtualenv and want to test with old pythons as well:

tox

Metadata

Release files for db_backup 0.1.3

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

Source distribution (sdist)

Source distribution for db_backup 0.1.3
File Size Uploaded Provenance Actions
db_backup-0.1.3.tar.gz 7.4 kB Without provenance Details for db_backup-0.1.3.tar.gz

Release files / db_backup-0.1.3.tar.gz

Download URL db_backup-0.1.3.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f423c734d5e7b00cc875c36f3233b9ef01da6caea966dd8086776c7ff19a1253
BLAKE2b-256 checksum
How to use checksums
99b55d7ff6e66244e292d73f8c89a1d011931930f37ca4b32539eca3f2329f9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for db_backup 0.1.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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