Skip to content

Commit 0ed283d

Browse files
authored
v5.0.1 (fix #645) (#646)
* Implement deprecation error for DBBACKUP_STORAGE and DBBACKUP_STORAGE_OPTIONS fix #645 * fix #642 * Add breaking changes notice to changelog (fix #643) * fix #641
1 parent c1ae4a9 commit 0ed283d

File tree

12 files changed

+237
-170
lines changed

12 files changed

+237
-170
lines changed

CHANGELOG.md

Lines changed: 129 additions & 114 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!--docs-top-start-->
2+
13
# Django DBBackup
24

35
<p>
@@ -17,7 +19,7 @@
1719

1820
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-supported storage.
1921

20-
## Features
22+
The main features include:
2123

2224
- Secure your backup with GPG signature and encryption.
2325
- Archive with compression.
@@ -26,14 +28,18 @@ This Django application provides management commands to help backup and restore
2628
- Set up automated backups with Crontab or Celery.
2729
- Manually backup and restore via Django management commands.
2830

29-
## Documentation
31+
<!--docs-top-end-->
3032

3133
For more details, see the [official documentation](https://archmonger.github.io/django-dbbackup/).
3234

35+
<!--docs-bottom-start-->
36+
3337
## Why use DBBackup?
3438

3539
DBBackup gives you a simple yet robust interface to backup, encrypt, transmit, and restore your database and media.
3640

3741
In a few words, it is a pipe between your Django project and your backups. It is written to be far more efficient than Django's [backup](https://docs.djangoproject.com/en/stable/ref/django-admin/#dumpdata)/[restore](https://docs.djangoproject.com/en/stable/ref/django-admin/#loaddata) commands by using your database's native/standard/best procedure(s) or tool(s) to perform backups.
3842

3943
Ultimately, this helps simplify the task of "creating a backup" by removing the need for writing relational query commands, using complex tools, or creating scripts. Optionally, DBBackup can apply compression and/or encryption before transferring the data to nearly any storage system.
44+
45+
<!--docs-bottom-end-->

dbbackup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Management commands to help backup and restore a project database and media"""
22

3-
__version__ = "5.0.0"
3+
__version__ = "5.0.1"

dbbackup/settings.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
1-
# DO NOT IMPORT THIS BEFORE django.configure() has been run!
2-
31
import socket
42
import tempfile
53

64
from django.conf import settings
75

8-
DATABASES = getattr(settings, "DBBACKUP_DATABASES", list(settings.DATABASES.keys()))
6+
# Raise an exception if DBBACKUP_STORAGE or DBBACKUP_STORAGE_OPTIONS is used
7+
if hasattr(settings, "DBBACKUP_STORAGE") or hasattr(settings, "DBBACKUP_STORAGE_OPTIONS"):
8+
raise RuntimeError(
9+
"The settings DBBACKUP_STORAGE and DBBACKUP_STORAGE_OPTIONS have been "
10+
"deprecated in favor of using Django Storages configuration. "
11+
"Please refer to the documentation for more details."
12+
)
913

10-
# Fake host
14+
DATABASES = getattr(settings, "DBBACKUP_DATABASES", list(settings.DATABASES.keys()))
1115
HOSTNAME = getattr(settings, "DBBACKUP_HOSTNAME", socket.gethostname())
12-
13-
# Directory to use for temporary files
1416
TMP_DIR = getattr(settings, "DBBACKUP_TMP_DIR", tempfile.gettempdir())
1517
TMP_FILE_MAX_SIZE = getattr(settings, "DBBACKUP_TMP_FILE_MAX_SIZE", 10 * 1024 * 1024)
1618
TMP_FILE_READ_SIZE = getattr(settings, "DBBACKUP_TMP_FILE_READ_SIZE", 1024 * 1000)
17-
18-
# Number of old backup files to keep
1919
CLEANUP_KEEP = getattr(settings, "DBBACKUP_CLEANUP_KEEP", 10)
2020
CLEANUP_KEEP_MEDIA = getattr(settings, "DBBACKUP_CLEANUP_KEEP_MEDIA", CLEANUP_KEEP)
2121
CLEANUP_KEEP_FILTER = getattr(settings, "DBBACKUP_CLEANUP_KEEP_FILTER", lambda x: False)
22-
2322
MEDIA_PATH = getattr(settings, "DBBACKUP_MEDIA_PATH", settings.MEDIA_ROOT)
24-
2523
DATE_FORMAT = getattr(settings, "DBBACKUP_DATE_FORMAT", "%Y-%m-%d-%H%M%S")
2624
FILENAME_TEMPLATE = getattr(
2725
settings,
2826
"DBBACKUP_FILENAME_TEMPLATE",
2927
"{databasename}-{servername}-{datetime}.{extension}",
3028
)
3129
MEDIA_FILENAME_TEMPLATE = getattr(settings, "DBBACKUP_MEDIA_FILENAME_TEMPLATE", "{servername}-{datetime}.{extension}")
32-
3330
GPG_ALWAYS_TRUST = getattr(settings, "DBBACKUP_GPG_ALWAYS_TRUST", False)
3431
GPG_RECIPIENT = GPG_ALWAYS_TRUST = getattr(settings, "DBBACKUP_GPG_RECIPIENT", None)
35-
3632
STORAGES_DBBACKUP_ALIAS = "dbbackup"
3733
DJANGO_STORAGES = getattr(settings, "STORAGES", {})
3834
storage: dict = DJANGO_STORAGES.get(STORAGES_DBBACKUP_ALIAS, {})
3935
STORAGE = storage.get("BACKEND", "django.core.files.storage.FileSystemStorage")
4036
STORAGE_OPTIONS = storage.get("OPTIONS", {})
41-
4237
CONNECTORS = getattr(settings, "DBBACKUP_CONNECTORS", {})
4338
CUSTOM_CONNECTOR_MAPPING = getattr(settings, "DBBACKUP_CONNECTOR_MAPPING", {})
44-
4539
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
46-
47-
# Mail
4840
SEND_EMAIL = getattr(settings, "DBBACKUP_SEND_EMAIL", True)
4941
SERVER_EMAIL = getattr(settings, "DBBACKUP_SERVER_EMAIL", settings.SERVER_EMAIL)
5042
ADMINS = getattr(settings, "DBBACKUP_ADMIN", settings.ADMINS)

docs/mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ extra:
7575
generator: false
7676
version:
7777
provider: mike
78+
analytics:
79+
provider: google
80+
property: G-BFHSW4Q4YW
7881

7982
extra_css:
8083
- assets/css/main.css

docs/src/configuration.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ Use a custom function if you need hierarchical prefixes (e.g. `year/month/`),
7979
or naming compatible with automatic life cycle / expiration rules of your
8080
object storage provider. `{datetime}` is rendered using `DBBACKUP_DATE_FORMAT`.
8181

82+
Note on cleanup (--clean): the cleanup logic matches backup files to a
83+
database using the `{databasename}` value (the database alias/key from
84+
`settings.DATABASES` or `DBBACKUP_CONNECTORS`). If you rely on the
85+
`--clean` option to remove older database backups, ensure your
86+
`DBBACKUP_FILENAME_TEMPLATE` includes `{databasename}` so files can be
87+
correctly identified and filtered for deletion. When backing up a single
88+
database using the default `databasename` (often `default`) this may not be
89+
necessary, but it is required when you manage more than one database or use
90+
custom connector keys.
91+
8292
### DBBACKUP_MEDIA_FILENAME_TEMPLATE
8393

8494
Same as `DBBACKUP_FILENAME_TEMPLATE`, but used for media backups.
@@ -113,9 +123,9 @@ python manage.py dbrestore --decrypt
113123

114124
Requirements:
115125

116-
- Install the python package python-gnupg: `pip install python-gnupg>=0.5.0`.
117-
- You need a GPG key. ([GPG manual](https://www.gnupg.org/gph/en/manual/c14.html))
118-
- Set the setting `DBBACKUP_GPG_RECIPIENT` to the name of the GPG key.
126+
- Install the python package python-gnupg: `pip install python-gnupg>=0.5.0`.
127+
- You need a GPG key. ([GPG manual](https://www.gnupg.org/gph/en/manual/c14.html))
128+
- Set the setting `DBBACKUP_GPG_RECIPIENT` to the name of the GPG key.
119129

120130
Note (Windows): The `gpg` executable must be installed and on your PATH for encryption/decryption. If it is absent, django-dbbackup still works; only encryption-related features are unavailable. The test suite will automatically skip encryption tests when `gpg` is not found.
121131

docs/src/contributing.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ welcome. This guide explains how to develop, test, and propose changes.
77

88
If you plan to make code changes to this repository, you will need to install the following dependencies first:
99

10-
- [Git](https://git-scm.com/downloads)
11-
- [Python 3.9+](https://www.python.org/downloads/)
12-
- [Hatch](https://hatch.pypa.io/latest/)
10+
- [Git](https://git-scm.com/downloads)
11+
- [Python 3.9+](https://www.python.org/downloads/)
12+
- [Hatch](https://hatch.pypa.io/latest/)
1313

1414
Once you finish installing these dependencies, you can clone this repository:
1515

@@ -83,10 +83,10 @@ Track bugs, feature proposals, and questions via
8383
[GitHub Issues](https://github.com/Archmonger/django-dbbackup/issues). Open an
8484
issue if:
8585

86-
- You have an improvement idea
87-
- You found a bug
88-
- You've got a question
89-
- More generally something seems wrong for you
86+
- You have an improvement idea
87+
- You found a bug
88+
- You've got a question
89+
- More generally something seems wrong for you
9090

9191
## Make a patch
9292

docs/src/databases.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
The following databases are supported by this application:
44

5-
- SQLite
6-
- MySQL
7-
- PostgreSQL
8-
- MongoDB
9-
- ... and any other Django-supported database (via `DjangoConnector`)
5+
- SQLite
6+
- MySQL
7+
- PostgreSQL
8+
- MongoDB
9+
- ... and any other Django-supported database (via `DjangoConnector`)
1010

1111
By default DBBackup reuses connection details from `settings.DATABASES`.
1212
Sometimes you want different credentials or a different host (e.g. read-only
@@ -40,8 +40,6 @@ All connectors have the following parameters:
4040
| EXCLUDE | List of table names to exclude from dump (may be unsupported for raw file copy snapshot approaches). Example below. | None |
4141
| EXTENSION | File extension used for the generated dump archive. | `dump` |
4242

43-
All supported built-in connectors are described in more detail below. Following database wrappers from `django-prometheus` are supported: `django_prometheus.db.backends.postgresql` (-> `PgDumpBinaryConnector`), `django_prometheus.db.backends.sqlite3` (-> `SqliteBackupConnector`), `django_prometheus.db.backends.mysql` (-> `MysqlDumpConnector`), `django_prometheus.db.backends.postgis` (-> `PgDumpGisConnector`).
44-
4543
Example for `EXCLUDE` usage:
4644

4745
```python
@@ -174,6 +172,15 @@ DATABASES = {
174172
| OBJECT_CHECK | Validate documents before inserting (`--objcheck`). | `True` |
175173
| DROP | Replace existing objects during restore (`--drop`). | `True` |
176174

175+
### Django-Prometheus
176+
177+
All supported built-in connectors are described in more detail below. Following database wrappers from `django-prometheus` are supported:
178+
179+
- `django_prometheus.db.backends.postgresql`
180+
- `django_prometheus.db.backends.sqlite3`
181+
- `django_prometheus.db.backends.mysql`
182+
- `django_prometheus.db.backends.postgis`
183+
177184
## Django Connector
178185

179186
The Django connector (`dbbackup.db.django.DjangoConnector`) provides database-agnostic backup and restore functionality using Django's built-in `dumpdata` and `loaddata` management commands. This connector works with any Django-supported database backend.
@@ -190,24 +197,24 @@ DBBACKUP_CONNECTORS = {
190197

191198
### Key Features
192199

193-
- **Universal compatibility**: Works with any database backend supported by Django
194-
- **No external dependencies**: Uses Django's serialization system
195-
- **Model-level backups**: Preserves foreign key relationships and data integrity
196-
- **JSON format**: Creates human-readable backups in JSON format
200+
- **Universal compatibility**: Works with any database backend supported by Django
201+
- **No external dependencies**: Uses Django's serialization system
202+
- **Model-level backups**: Preserves foreign key relationships and data integrity
203+
- **JSON format**: Creates human-readable backups in JSON format
197204

198205
### When to Use
199206

200207
The Django connector is ideal for:
201208

202-
- Oracle databases (used by default)
203-
- Custom or third-party database backends not explicitly supported
204-
- Development environments where simplicity is preferred
205-
- Cases where external database tools are not available
209+
- Oracle databases (used by default)
210+
- Custom or third-party database backends not explicitly supported
211+
- Development environments where simplicity is preferred
212+
- Cases where external database tools are not available
206213

207214
### Limitations
208215

209-
- **Performance**: Slower than native database tools for large datasets
210-
- **Database structure**: Only backs up data, not database schema, indices, or procedures
216+
- **Performance**: Slower than native database tools for large datasets
217+
- **Database structure**: Only backs up data, not database schema, indices, or procedures
211218

212219
### File Extension
213220

docs/src/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ hide:
33
- navigation
44
---
55

6-
{% include-markdown "../../README.md" %}
6+
{% include-markdown "../../README.md" start="<!--docs-top-start-->" end="<!--docs-top-end-->" %}
7+
{% include-markdown "../../README.md" start="<!--docs-bottom-start-->" end="<!--docs-bottom-end-->" %}
78

89
## Other Resources
910

10-
* [GitHub repository](https://github.com/Archmonger/django-dbbackup)
11-
* [PyPI project](https://pypi.org/pypi/django-dbbackup/)
12-
* [Documentation](https://archmonger.github.io/django-dbbackup/)
13-
* [GitHub issues](https://github.com/Archmonger/django-dbbackup/issues)
14-
* [GitHub discussions](https://github.com/Archmonger/django-dbbackup/discussions)
15-
* [GitHub pull requests](https://github.com/Archmonger/django-dbbackup/pulls)
11+
- [GitHub repository](https://github.com/Archmonger/django-dbbackup)
12+
- [PyPI project](https://pypi.org/pypi/django-dbbackup/)
13+
- [Documentation](https://archmonger.github.io/django-dbbackup/)
14+
- [GitHub issues](https://github.com/Archmonger/django-dbbackup/issues)
15+
- [GitHub discussions](https://github.com/Archmonger/django-dbbackup/discussions)
16+
- [GitHub pull requests](https://github.com/Archmonger/django-dbbackup/pulls)

docs/src/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
hide:
3-
- navigation
3+
- navigation
44
---
55

66
## Installing on your system

0 commit comments

Comments
 (0)