bdbackup 0.7.1__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bdbackup-0.7.1 → bdbackup-0.7.3}/PKG-INFO +66 -20
- {bdbackup-0.7.1 → bdbackup-0.7.3}/README.md +65 -19
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/backends.py +1 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/cli.py +247 -29
- bdbackup-0.7.3/bdbackup/config.py +243 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/engines.py +11 -1
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/actions.py +24 -4
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/runner.py +25 -4
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/stages.py +54 -11
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/structure.py +3 -2
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/history.py +93 -6
- bdbackup-0.7.3/bdbackup/metrics/__init__.py +5 -0
- bdbackup-0.7.3/bdbackup/metrics/collector.py +152 -0
- bdbackup-0.7.3/bdbackup/metrics/data.py +97 -0
- bdbackup-0.7.3/bdbackup/metrics/families.py +96 -0
- bdbackup-0.7.3/bdbackup/metrics/gfs.py +124 -0
- bdbackup-0.7.3/bdbackup/metrics/jobs.py +103 -0
- bdbackup-0.7.3/bdbackup/metrics/probe.py +179 -0
- bdbackup-0.7.3/bdbackup/metrics/registry.py +55 -0
- bdbackup-0.7.3/bdbackup/metrics/render.py +82 -0
- bdbackup-0.7.3/bdbackup/metrics/run.py +246 -0
- bdbackup-0.7.3/bdbackup/metrics/settings.py +35 -0
- bdbackup-0.7.3/bdbackup/metrics/units.py +75 -0
- bdbackup-0.7.3/bdbackup/metrics/write.py +31 -0
- bdbackup-0.7.3/bdbackup/metrics_command.py +220 -0
- bdbackup-0.7.3/bdbackup/postgres/__init__.py +22 -0
- bdbackup-0.7.3/bdbackup/postgres/metrics.py +263 -0
- bdbackup-0.7.3/bdbackup/postgres/pgbackrest.py +619 -0
- bdbackup-0.7.3/bdbackup/postgres/repository.py +238 -0
- bdbackup-0.7.3/bdbackup/postgres/restore.py +160 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/recovery.py +2 -2
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/utils.py +14 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/validation.py +28 -4
- {bdbackup-0.7.1 → bdbackup-0.7.3}/config.toml.example +96 -8
- bdbackup-0.7.3/docs/README_ENGINES.md +115 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/docs/README_FILE.md +4 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/docs/README_GFS.md +69 -4
- bdbackup-0.7.3/docs/README_METRICS.md +358 -0
- bdbackup-0.7.3/docs/README_PGBACKREST.md +509 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/pyproject.toml +1 -1
- bdbackup-0.7.3/scripts/docker/nfs-outage.Dockerfile +26 -0
- bdbackup-0.7.3/scripts/docker/pgbackrest.Dockerfile +28 -0
- bdbackup-0.7.3/scripts/integration_nfs_outage.py +381 -0
- bdbackup-0.7.3/scripts/integration_pgbackrest.py +915 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/AGENTS.md +34 -10
- bdbackup-0.7.3/tests/pgbackrest_fake.py +243 -0
- bdbackup-0.7.3/tests/test_broken_pipe.py +149 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_cli_reshape.py +29 -2
- bdbackup-0.7.3/tests/test_config_lexical.py +159 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_encryption.py +4 -3
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_engines.py +5 -2
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_gfs_init.py +36 -2
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_gfs_run.py +248 -3
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_gfs_store.py +3 -3
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_history.py +26 -0
- bdbackup-0.7.3/tests/test_last_runs.py +175 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_ledger.py +1 -1
- bdbackup-0.7.3/tests/test_metrics_collect.py +792 -0
- bdbackup-0.7.3/tests/test_metrics_command.py +336 -0
- bdbackup-0.7.3/tests/test_metrics_config.py +126 -0
- bdbackup-0.7.3/tests/test_metrics_hang.py +161 -0
- bdbackup-0.7.3/tests/test_metrics_phases.py +170 -0
- bdbackup-0.7.3/tests/test_metrics_probe.py +427 -0
- bdbackup-0.7.3/tests/test_metrics_render.py +217 -0
- bdbackup-0.7.3/tests/test_metrics_write.py +209 -0
- bdbackup-0.7.3/tests/test_pgbackrest_cli.py +760 -0
- bdbackup-0.7.3/tests/test_pgbackrest_engine.py +1259 -0
- bdbackup-0.7.3/tests/test_pgbackrest_export.py +687 -0
- bdbackup-0.7.3/tests/test_pgbackrest_metrics.py +708 -0
- bdbackup-0.7.3/tests/test_pgbackrest_repository.py +488 -0
- bdbackup-0.7.3/tests/test_pgbackrest_restore.py +487 -0
- bdbackup-0.7.3/tests/test_validate_metrics.py +129 -0
- bdbackup-0.7.1/bdbackup/config.py +0 -141
- bdbackup-0.7.1/docs/README_ENGINES.md +0 -63
- {bdbackup-0.7.1 → bdbackup-0.7.3}/.gitignore +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/LICENSE +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/__init__.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/filebackup.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/__init__.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/policy.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/gfs/store.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/ledger.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/mysql/__init__.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/mysql/helpers.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/mysql/mysqldump.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/mysql/xtrabackup.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/templates/__init__.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/templates/_matching.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/bdbackup/templates/python_dev.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/contrib/systemd/bdbackup-incremental@.service +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/contrib/systemd/bdbackup-incremental@.timer +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/contrib/systemd/bdbackup@.service +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/contrib/systemd/bdbackup@.timer +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/docs/README_MYSQLDUMP.md +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/docs/README_SYSTEMD.md +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/docs/README_XTRABACKUP.md +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/scripts/check_release.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/scripts/integration_mysql.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/scripts/integration_physical.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/scripts/smoke_install.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/template.txt +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/__init__.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/conftest.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_architecture.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_correctness.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_engine_conditions.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_gfs_config.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_gfs_policy.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_helpers.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_import.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_performance.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_release_fixes.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_run_selector.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_safety_nets.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_security.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_systemd_units.py +0 -0
- {bdbackup-0.7.1 → bdbackup-0.7.3}/tests/test_templates.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bdbackup
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: MySQL, MariaDB and file backups with mysqldump, Percona XtraBackup, MariaDB Backup and tar: verification, GFS rotation and guided restore
|
|
5
5
|
Project-URL: Homepage, https://github.com/ayder/bdbackup
|
|
6
6
|
Project-URL: Repository, https://github.com/ayder/bdbackup
|
|
@@ -36,12 +36,13 @@ Description-Content-Type: text/markdown
|
|
|
36
36
|
|
|
37
37
|
**Backups by design.**
|
|
38
38
|
|
|
39
|
-
bdbackup is a command-line backup tool and Python library for MySQL, MariaDB
|
|
40
|
-
files on Linux and macOS. It takes MySQL and MariaDB
|
|
41
|
-
Percona XtraBackup and MariaDB Backup (full and
|
|
42
|
-
compressed and optionally encrypted),
|
|
43
|
-
tar.gz or tar.zst, and
|
|
44
|
-
|
|
39
|
+
bdbackup is a command-line backup tool and Python library for MySQL, MariaDB,
|
|
40
|
+
PostgreSQL (pgBackRest) and files on Linux and macOS. It takes MySQL and MariaDB
|
|
41
|
+
backups with mysqldump, Percona XtraBackup and MariaDB Backup (full and
|
|
42
|
+
incremental physical backups, compressed and optionally encrypted), exports
|
|
43
|
+
pgBackRest fulls, archives files and directories as tar, tar.gz or tar.zst, and
|
|
44
|
+
rotates the results across storage stages with GFS (grandfather-father-son)
|
|
45
|
+
retention. Every backup is verified before it is
|
|
45
46
|
published and recorded with a SHA-256 checksum in an SQLite backup history, from
|
|
46
47
|
which a guided restore prepares a recovery copy. Jobs live in one TOML file and
|
|
47
48
|
run from cron.
|
|
@@ -53,6 +54,8 @@ run from cron.
|
|
|
53
54
|
encrypted with Percona, prepared for recovery with `restore --backup`.
|
|
54
55
|
- [MySQL and MariaDB logical backups](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) with mysqldump,
|
|
55
56
|
gzip-compressed, one database or all.
|
|
57
|
+
- [PostgreSQL pgBackRest backups](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md): the newest
|
|
58
|
+
full of a stanza exported as one tar into a GFS stage, restorable on its own.
|
|
56
59
|
- [File and directory backups](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md) as tar archives, with
|
|
57
60
|
gitignore-style exclusion templates.
|
|
58
61
|
- [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md): daily,
|
|
@@ -62,6 +65,10 @@ run from cron.
|
|
|
62
65
|
SHA-256 checksums in SQLite.
|
|
63
66
|
- [Configuration validation](#validate-configuration-and-permissions) of
|
|
64
67
|
settings, filesystem permissions and MySQL grants, without running a backup.
|
|
68
|
+
- [Prometheus metrics](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md): a read-only
|
|
69
|
+
`bdbackup metrics` writes a textfile for node_exporter and PMM with the last run of each
|
|
70
|
+
pgbackrest and gfs job, the history, the GFS stages, the destinations and the pgBackRest
|
|
71
|
+
repository.
|
|
65
72
|
- [Custom backup engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md) as plugins.
|
|
66
73
|
|
|
67
74
|
## Documentation
|
|
@@ -71,8 +78,10 @@ run from cron.
|
|
|
71
78
|
| [File and directory backups with tar](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md) | file jobs, template files, exclusion templates, restoring an archive |
|
|
72
79
|
| [MySQL and MariaDB logical backups with mysqldump](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) | mysqldump jobs, credentials, default options |
|
|
73
80
|
| [MySQL and MariaDB physical backups with Percona XtraBackup and MariaDB Backup](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md) | xtrabackup jobs, full and incremental backups, encryption, preparing a recovery copy, engine pruning |
|
|
81
|
+
| [PostgreSQL pgBackRest backups: nightly fulls exported to a GFS stage](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md) | pgbackrest jobs, taking fulls with archive-copy, the first stage, no new full and `max_full_age_hours`, restore and the printed pgBackRest command, the repository host lost, known limits |
|
|
74
82
|
| [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md) | stages, preparing stage directories, safety rules, run and step logs, ledger copies |
|
|
75
|
-
| [
|
|
83
|
+
| [Prometheus metrics: `bdbackup metrics`](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md) | the metrics command and `[metrics]`, the textfile for node_exporter and PMM, every metric, alerting, hangs and outages, known limits |
|
|
84
|
+
| [Custom backup engines (plugins)](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md) | the engine registry, writing your own engine and its metrics collector |
|
|
76
85
|
| [Running xtrabackup jobs with systemd timers](https://github.com/ayder/bdbackup/blob/master/docs/README_SYSTEMD.md) | service and timer templates, the mysql account, schedules, CPU, I/O and memory limits |
|
|
77
86
|
| [Annotated configuration](https://github.com/ayder/bdbackup/blob/master/config.toml.example) | every config key with a comment |
|
|
78
87
|
|
|
@@ -120,7 +129,7 @@ pip install -e ".[dev]"
|
|
|
120
129
|
|
|
121
130
|
## Commands
|
|
122
131
|
|
|
123
|
-
`bdbackup` has
|
|
132
|
+
`bdbackup` has four commands; everything else is an option:
|
|
124
133
|
|
|
125
134
|
```bash
|
|
126
135
|
bdbackup run -c CONFIG -j JOB [--full | --incremental] [--no-verify] [--dry-run]
|
|
@@ -130,6 +139,7 @@ bdbackup restore -c CONFIG [--backup-id N] [--job JOB] [-y] [-d DIR] [--encrypt
|
|
|
130
139
|
bdbackup restore --archive ARCHIVE -d DIR
|
|
131
140
|
bdbackup restore --backup BACKUP --root ROOT -d DIR [--binary BINARY] [--encrypt-key-file KEY]
|
|
132
141
|
bdbackup history -c CONFIG [--job JOB] [--successful | --create-checksum]
|
|
142
|
+
bdbackup metrics -c CONFIG
|
|
133
143
|
```
|
|
134
144
|
|
|
135
145
|
`-c` is `--config` on every command; `-j` is the short form of `--job` on `run`
|
|
@@ -138,14 +148,17 @@ only (`restore` and `history` take `--job`). `bdbackup` itself takes only
|
|
|
138
148
|
`bdbackup --logging DEBUG run -c config.toml -j files-daily`. Levels: `DEBUG`,
|
|
139
149
|
`INFO`, `WARNING`, `ERROR`.
|
|
140
150
|
|
|
151
|
+
When the program reading a command's output exits early (`bdbackup history -c config.toml | head`),
|
|
152
|
+
the rest of the output is dropped and the command ends quietly with the exit code it would have had.
|
|
153
|
+
|
|
141
154
|
The CLI uses these exit codes:
|
|
142
155
|
|
|
143
156
|
| Code | Meaning |
|
|
144
157
|
|------|---------|
|
|
145
158
|
| 0 | Success |
|
|
146
|
-
| 1 | Backup/verify failure (including a job whose backend rejects its settings in a real run), or validation checks failed/incomplete |
|
|
159
|
+
| 1 | Backup/verify failure (including a job whose backend rejects its settings in a real run, except a pgbackrest job: exit 2), or validation checks failed/incomplete; for `metrics`, the file was written with an error series or could not be written |
|
|
147
160
|
| 2 | Usage error, an inactive job, or a configuration error found when the config loads or by `--dry-run` |
|
|
148
|
-
| 3 | Lock held; for GFS, another run of the job is in progress or only deferred work remains |
|
|
161
|
+
| 3 | Lock held; for GFS, another run of the job is in progress or only deferred work remains; for `metrics`, another metrics run holds its lock |
|
|
149
162
|
|
|
150
163
|
## Config-driven jobs
|
|
151
164
|
|
|
@@ -185,7 +198,7 @@ config file's directory. Template entries and `exclude` entries resolve against
|
|
|
185
198
|
mysqldump job, set `database = "mydatabase"`; for all databases include
|
|
186
199
|
`--all-databases` in `options`.
|
|
187
200
|
|
|
188
|
-
Except for the optional `[history]` settings, each top-level table is one job;
|
|
201
|
+
Except for the optional `[history]` and `[metrics]` settings, each top-level table is one job;
|
|
189
202
|
its keys (except `type`, `active` and `restore_root`) are passed
|
|
190
203
|
to the backend constructor, so they use Python-style underscores
|
|
191
204
|
(`exclude_templates`). See [config.toml.example](https://github.com/ayder/bdbackup/blob/master/config.toml.example)
|
|
@@ -204,10 +217,12 @@ An xtrabackup job also takes `--incremental`; see
|
|
|
204
217
|
|
|
205
218
|
`--dry-run` reports what a job would do: it runs no backup tool, writes no
|
|
206
219
|
backup and records no history; a GFS dry run creates only its job's lock file
|
|
207
|
-
beside the history database.
|
|
220
|
+
beside the history database. The one exception is a pgbackrest job, which runs
|
|
221
|
+
the read-only `pgbackrest info`. What each job type reports is described with it:
|
|
208
222
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#dry-run),
|
|
209
223
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#dry-run),
|
|
210
|
-
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#dry-run)
|
|
224
|
+
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#dry-run),
|
|
225
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#dry-run-and-validation) and
|
|
211
226
|
[GFS jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md#dry-run).
|
|
212
227
|
|
|
213
228
|
A dry run exits 1 where the real run would fail before writing anything (an
|
|
@@ -240,6 +255,14 @@ Times use the cron daemon's timezone, and separate lines do not wait for each
|
|
|
240
255
|
other: leave enough time for backups before GFS. Add `--dry-run` to the GFS line
|
|
241
256
|
until its report looks right.
|
|
242
257
|
|
|
258
|
+
`bdbackup metrics` writes the Prometheus textfile and runs every 10 to 15 minutes, as the
|
|
259
|
+
OS account that owns the history database; see
|
|
260
|
+
[Prometheus metrics](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md):
|
|
261
|
+
|
|
262
|
+
```cron
|
|
263
|
+
*/10 * * * * bdbackup metrics -c /opt/dbs/config.toml
|
|
264
|
+
```
|
|
265
|
+
|
|
243
266
|
xtrabackup jobs can run from systemd timers instead, which also stop the backup
|
|
244
267
|
tool if bdbackup dies and add per-job limits: see
|
|
245
268
|
[Running xtrabackup jobs with systemd timers](https://github.com/ayder/bdbackup/blob/master/docs/README_SYSTEMD.md).
|
|
@@ -285,7 +308,8 @@ Checks cover direct grants; role-derived privileges and partial revokes may need
|
|
|
285
308
|
manual review. Physical datadir checks cover root-directory access, not every data
|
|
286
309
|
file or external tablespace. Custom mysqldump options, routine visibility, GTID
|
|
287
310
|
settings and exact server/binary version compatibility still need review.
|
|
288
|
-
For a GFS job, every stage path after the first
|
|
311
|
+
For a GFS job, every stage path after the first (and the first, when a pgbackrest
|
|
312
|
+
job writes into it) must exist and be writable, and
|
|
289
313
|
its `.bdbackup-destination` marker must be present and writable; a missing
|
|
290
314
|
marker's line names the `--initialize-structure` command that creates it.
|
|
291
315
|
An unreachable database or missing client is a failed/incomplete check, not a pass.
|
|
@@ -355,8 +379,10 @@ missing or was replaced, or `<id>: skipped: unexpected unit` for a physical back
|
|
|
355
379
|
outside its dated layout, and then exits 1. A checksum already recorded is never
|
|
356
380
|
changed. `--create-checksum` cannot be combined with `--successful`. The checksum lives in the `checksum` column of the `backup_runs` table.
|
|
357
381
|
|
|
358
|
-
History uses schema version
|
|
359
|
-
write; bdbackup 0.
|
|
382
|
+
History uses schema version 6, from bdbackup 0.7.3. A database at an older schema upgrades
|
|
383
|
+
on the next write; bdbackup 0.7.2 or earlier refuses a version-6 database. Version 6 adds the
|
|
384
|
+
`last_runs` table: the outcome of the last run of each pgbackrest and gfs job, which
|
|
385
|
+
`bdbackup metrics` reads.
|
|
360
386
|
|
|
361
387
|
History is written before work starts, and success only after the backup and its
|
|
362
388
|
requested verification finish. If history cannot be written, the command fails;
|
|
@@ -396,7 +422,8 @@ bdbackup restore -c config.toml --backup-id 12 --dst /restore/job-12 --yes
|
|
|
396
422
|
What a restore produces depends on the job type; see
|
|
397
423
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#history-restore),
|
|
398
424
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#history-restore),
|
|
399
|
-
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#history-restore)
|
|
425
|
+
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#history-restore),
|
|
426
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#restore) and
|
|
400
427
|
[custom engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md#history-restore).
|
|
401
428
|
|
|
402
429
|
Deleted artifacts remain in history as unavailable. File identity, size, and
|
|
@@ -418,16 +445,35 @@ ruff check bdbackup tests scripts
|
|
|
418
445
|
```
|
|
419
446
|
|
|
420
447
|
Optional database integration tests use disposable, network-isolated Docker
|
|
421
|
-
containers with synthetic data. They remove only the containers and
|
|
422
|
-
created for that run. Pull the matching images before running:
|
|
448
|
+
containers with synthetic data. They remove only the containers, volumes and
|
|
449
|
+
networks created for that run. Pull the matching images before running:
|
|
423
450
|
|
|
424
451
|
```bash
|
|
425
452
|
python scripts/integration_mysql.py # mysql:8.4
|
|
426
453
|
python scripts/integration_physical.py percona # percona-server/xtrabackup:8.4
|
|
427
454
|
python scripts/integration_physical.py percona-encrypted # AES256 + zstd recovery
|
|
428
455
|
python scripts/integration_physical.py mariadb # mariadb:11.4
|
|
456
|
+
python scripts/integration_pgbackrest.py pg16-2.58 # bdbackup-pgbackrest:16-2.58.0
|
|
457
|
+
python scripts/integration_pgbackrest.py pg18-2.60 # bdbackup-pgbackrest:18-2.60.0
|
|
458
|
+
python scripts/integration_nfs_outage.py # bdbackup-nfs-outage:test, privileged
|
|
429
459
|
```
|
|
430
460
|
|
|
461
|
+
The pgBackRest images have no official source; build them from
|
|
462
|
+
`scripts/docker/pgbackrest.Dockerfile` with the commands in `tests/AGENTS.md`. The NFS
|
|
463
|
+
outage test runs `bdbackup metrics` against a hard NFS mount whose server stops answering. Its
|
|
464
|
+
image installs bdbackup from a wheel built on the host, and the script refuses an image built
|
|
465
|
+
from other sources:
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
rm -rf dist && python -m build -q
|
|
469
|
+
docker build -f scripts/docker/nfs-outage.Dockerfile \
|
|
470
|
+
--build-arg SOURCE_HASH="$(python scripts/integration_nfs_outage.py --source-hash)" \
|
|
471
|
+
-t bdbackup-nfs-outage:test dist
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
It runs a container with `--privileged --network none`, so it needs a Linux kernel with an NFS
|
|
475
|
+
server and iptables.
|
|
476
|
+
|
|
431
477
|
Physical recovery returns a prepared data directory; copying it into a server's
|
|
432
478
|
data directory, assigning ownership to the server user, and starting that server
|
|
433
479
|
are separate administrator actions. Use the same database version and
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
**Backups by design.**
|
|
4
4
|
|
|
5
|
-
bdbackup is a command-line backup tool and Python library for MySQL, MariaDB
|
|
6
|
-
files on Linux and macOS. It takes MySQL and MariaDB
|
|
7
|
-
Percona XtraBackup and MariaDB Backup (full and
|
|
8
|
-
compressed and optionally encrypted),
|
|
9
|
-
tar.gz or tar.zst, and
|
|
10
|
-
|
|
5
|
+
bdbackup is a command-line backup tool and Python library for MySQL, MariaDB,
|
|
6
|
+
PostgreSQL (pgBackRest) and files on Linux and macOS. It takes MySQL and MariaDB
|
|
7
|
+
backups with mysqldump, Percona XtraBackup and MariaDB Backup (full and
|
|
8
|
+
incremental physical backups, compressed and optionally encrypted), exports
|
|
9
|
+
pgBackRest fulls, archives files and directories as tar, tar.gz or tar.zst, and
|
|
10
|
+
rotates the results across storage stages with GFS (grandfather-father-son)
|
|
11
|
+
retention. Every backup is verified before it is
|
|
11
12
|
published and recorded with a SHA-256 checksum in an SQLite backup history, from
|
|
12
13
|
which a guided restore prepares a recovery copy. Jobs live in one TOML file and
|
|
13
14
|
run from cron.
|
|
@@ -19,6 +20,8 @@ run from cron.
|
|
|
19
20
|
encrypted with Percona, prepared for recovery with `restore --backup`.
|
|
20
21
|
- [MySQL and MariaDB logical backups](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) with mysqldump,
|
|
21
22
|
gzip-compressed, one database or all.
|
|
23
|
+
- [PostgreSQL pgBackRest backups](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md): the newest
|
|
24
|
+
full of a stanza exported as one tar into a GFS stage, restorable on its own.
|
|
22
25
|
- [File and directory backups](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md) as tar archives, with
|
|
23
26
|
gitignore-style exclusion templates.
|
|
24
27
|
- [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md): daily,
|
|
@@ -28,6 +31,10 @@ run from cron.
|
|
|
28
31
|
SHA-256 checksums in SQLite.
|
|
29
32
|
- [Configuration validation](#validate-configuration-and-permissions) of
|
|
30
33
|
settings, filesystem permissions and MySQL grants, without running a backup.
|
|
34
|
+
- [Prometheus metrics](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md): a read-only
|
|
35
|
+
`bdbackup metrics` writes a textfile for node_exporter and PMM with the last run of each
|
|
36
|
+
pgbackrest and gfs job, the history, the GFS stages, the destinations and the pgBackRest
|
|
37
|
+
repository.
|
|
31
38
|
- [Custom backup engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md) as plugins.
|
|
32
39
|
|
|
33
40
|
## Documentation
|
|
@@ -37,8 +44,10 @@ run from cron.
|
|
|
37
44
|
| [File and directory backups with tar](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md) | file jobs, template files, exclusion templates, restoring an archive |
|
|
38
45
|
| [MySQL and MariaDB logical backups with mysqldump](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) | mysqldump jobs, credentials, default options |
|
|
39
46
|
| [MySQL and MariaDB physical backups with Percona XtraBackup and MariaDB Backup](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md) | xtrabackup jobs, full and incremental backups, encryption, preparing a recovery copy, engine pruning |
|
|
47
|
+
| [PostgreSQL pgBackRest backups: nightly fulls exported to a GFS stage](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md) | pgbackrest jobs, taking fulls with archive-copy, the first stage, no new full and `max_full_age_hours`, restore and the printed pgBackRest command, the repository host lost, known limits |
|
|
40
48
|
| [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md) | stages, preparing stage directories, safety rules, run and step logs, ledger copies |
|
|
41
|
-
| [
|
|
49
|
+
| [Prometheus metrics: `bdbackup metrics`](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md) | the metrics command and `[metrics]`, the textfile for node_exporter and PMM, every metric, alerting, hangs and outages, known limits |
|
|
50
|
+
| [Custom backup engines (plugins)](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md) | the engine registry, writing your own engine and its metrics collector |
|
|
42
51
|
| [Running xtrabackup jobs with systemd timers](https://github.com/ayder/bdbackup/blob/master/docs/README_SYSTEMD.md) | service and timer templates, the mysql account, schedules, CPU, I/O and memory limits |
|
|
43
52
|
| [Annotated configuration](https://github.com/ayder/bdbackup/blob/master/config.toml.example) | every config key with a comment |
|
|
44
53
|
|
|
@@ -86,7 +95,7 @@ pip install -e ".[dev]"
|
|
|
86
95
|
|
|
87
96
|
## Commands
|
|
88
97
|
|
|
89
|
-
`bdbackup` has
|
|
98
|
+
`bdbackup` has four commands; everything else is an option:
|
|
90
99
|
|
|
91
100
|
```bash
|
|
92
101
|
bdbackup run -c CONFIG -j JOB [--full | --incremental] [--no-verify] [--dry-run]
|
|
@@ -96,6 +105,7 @@ bdbackup restore -c CONFIG [--backup-id N] [--job JOB] [-y] [-d DIR] [--encrypt
|
|
|
96
105
|
bdbackup restore --archive ARCHIVE -d DIR
|
|
97
106
|
bdbackup restore --backup BACKUP --root ROOT -d DIR [--binary BINARY] [--encrypt-key-file KEY]
|
|
98
107
|
bdbackup history -c CONFIG [--job JOB] [--successful | --create-checksum]
|
|
108
|
+
bdbackup metrics -c CONFIG
|
|
99
109
|
```
|
|
100
110
|
|
|
101
111
|
`-c` is `--config` on every command; `-j` is the short form of `--job` on `run`
|
|
@@ -104,14 +114,17 @@ only (`restore` and `history` take `--job`). `bdbackup` itself takes only
|
|
|
104
114
|
`bdbackup --logging DEBUG run -c config.toml -j files-daily`. Levels: `DEBUG`,
|
|
105
115
|
`INFO`, `WARNING`, `ERROR`.
|
|
106
116
|
|
|
117
|
+
When the program reading a command's output exits early (`bdbackup history -c config.toml | head`),
|
|
118
|
+
the rest of the output is dropped and the command ends quietly with the exit code it would have had.
|
|
119
|
+
|
|
107
120
|
The CLI uses these exit codes:
|
|
108
121
|
|
|
109
122
|
| Code | Meaning |
|
|
110
123
|
|------|---------|
|
|
111
124
|
| 0 | Success |
|
|
112
|
-
| 1 | Backup/verify failure (including a job whose backend rejects its settings in a real run), or validation checks failed/incomplete |
|
|
125
|
+
| 1 | Backup/verify failure (including a job whose backend rejects its settings in a real run, except a pgbackrest job: exit 2), or validation checks failed/incomplete; for `metrics`, the file was written with an error series or could not be written |
|
|
113
126
|
| 2 | Usage error, an inactive job, or a configuration error found when the config loads or by `--dry-run` |
|
|
114
|
-
| 3 | Lock held; for GFS, another run of the job is in progress or only deferred work remains |
|
|
127
|
+
| 3 | Lock held; for GFS, another run of the job is in progress or only deferred work remains; for `metrics`, another metrics run holds its lock |
|
|
115
128
|
|
|
116
129
|
## Config-driven jobs
|
|
117
130
|
|
|
@@ -151,7 +164,7 @@ config file's directory. Template entries and `exclude` entries resolve against
|
|
|
151
164
|
mysqldump job, set `database = "mydatabase"`; for all databases include
|
|
152
165
|
`--all-databases` in `options`.
|
|
153
166
|
|
|
154
|
-
Except for the optional `[history]` settings, each top-level table is one job;
|
|
167
|
+
Except for the optional `[history]` and `[metrics]` settings, each top-level table is one job;
|
|
155
168
|
its keys (except `type`, `active` and `restore_root`) are passed
|
|
156
169
|
to the backend constructor, so they use Python-style underscores
|
|
157
170
|
(`exclude_templates`). See [config.toml.example](https://github.com/ayder/bdbackup/blob/master/config.toml.example)
|
|
@@ -170,10 +183,12 @@ An xtrabackup job also takes `--incremental`; see
|
|
|
170
183
|
|
|
171
184
|
`--dry-run` reports what a job would do: it runs no backup tool, writes no
|
|
172
185
|
backup and records no history; a GFS dry run creates only its job's lock file
|
|
173
|
-
beside the history database.
|
|
186
|
+
beside the history database. The one exception is a pgbackrest job, which runs
|
|
187
|
+
the read-only `pgbackrest info`. What each job type reports is described with it:
|
|
174
188
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#dry-run),
|
|
175
189
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#dry-run),
|
|
176
|
-
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#dry-run)
|
|
190
|
+
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#dry-run),
|
|
191
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#dry-run-and-validation) and
|
|
177
192
|
[GFS jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md#dry-run).
|
|
178
193
|
|
|
179
194
|
A dry run exits 1 where the real run would fail before writing anything (an
|
|
@@ -206,6 +221,14 @@ Times use the cron daemon's timezone, and separate lines do not wait for each
|
|
|
206
221
|
other: leave enough time for backups before GFS. Add `--dry-run` to the GFS line
|
|
207
222
|
until its report looks right.
|
|
208
223
|
|
|
224
|
+
`bdbackup metrics` writes the Prometheus textfile and runs every 10 to 15 minutes, as the
|
|
225
|
+
OS account that owns the history database; see
|
|
226
|
+
[Prometheus metrics](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md):
|
|
227
|
+
|
|
228
|
+
```cron
|
|
229
|
+
*/10 * * * * bdbackup metrics -c /opt/dbs/config.toml
|
|
230
|
+
```
|
|
231
|
+
|
|
209
232
|
xtrabackup jobs can run from systemd timers instead, which also stop the backup
|
|
210
233
|
tool if bdbackup dies and add per-job limits: see
|
|
211
234
|
[Running xtrabackup jobs with systemd timers](https://github.com/ayder/bdbackup/blob/master/docs/README_SYSTEMD.md).
|
|
@@ -251,7 +274,8 @@ Checks cover direct grants; role-derived privileges and partial revokes may need
|
|
|
251
274
|
manual review. Physical datadir checks cover root-directory access, not every data
|
|
252
275
|
file or external tablespace. Custom mysqldump options, routine visibility, GTID
|
|
253
276
|
settings and exact server/binary version compatibility still need review.
|
|
254
|
-
For a GFS job, every stage path after the first
|
|
277
|
+
For a GFS job, every stage path after the first (and the first, when a pgbackrest
|
|
278
|
+
job writes into it) must exist and be writable, and
|
|
255
279
|
its `.bdbackup-destination` marker must be present and writable; a missing
|
|
256
280
|
marker's line names the `--initialize-structure` command that creates it.
|
|
257
281
|
An unreachable database or missing client is a failed/incomplete check, not a pass.
|
|
@@ -321,8 +345,10 @@ missing or was replaced, or `<id>: skipped: unexpected unit` for a physical back
|
|
|
321
345
|
outside its dated layout, and then exits 1. A checksum already recorded is never
|
|
322
346
|
changed. `--create-checksum` cannot be combined with `--successful`. The checksum lives in the `checksum` column of the `backup_runs` table.
|
|
323
347
|
|
|
324
|
-
History uses schema version
|
|
325
|
-
write; bdbackup 0.
|
|
348
|
+
History uses schema version 6, from bdbackup 0.7.3. A database at an older schema upgrades
|
|
349
|
+
on the next write; bdbackup 0.7.2 or earlier refuses a version-6 database. Version 6 adds the
|
|
350
|
+
`last_runs` table: the outcome of the last run of each pgbackrest and gfs job, which
|
|
351
|
+
`bdbackup metrics` reads.
|
|
326
352
|
|
|
327
353
|
History is written before work starts, and success only after the backup and its
|
|
328
354
|
requested verification finish. If history cannot be written, the command fails;
|
|
@@ -362,7 +388,8 @@ bdbackup restore -c config.toml --backup-id 12 --dst /restore/job-12 --yes
|
|
|
362
388
|
What a restore produces depends on the job type; see
|
|
363
389
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#history-restore),
|
|
364
390
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#history-restore),
|
|
365
|
-
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#history-restore)
|
|
391
|
+
[xtrabackup jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_XTRABACKUP.md#history-restore),
|
|
392
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#restore) and
|
|
366
393
|
[custom engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md#history-restore).
|
|
367
394
|
|
|
368
395
|
Deleted artifacts remain in history as unavailable. File identity, size, and
|
|
@@ -384,16 +411,35 @@ ruff check bdbackup tests scripts
|
|
|
384
411
|
```
|
|
385
412
|
|
|
386
413
|
Optional database integration tests use disposable, network-isolated Docker
|
|
387
|
-
containers with synthetic data. They remove only the containers and
|
|
388
|
-
created for that run. Pull the matching images before running:
|
|
414
|
+
containers with synthetic data. They remove only the containers, volumes and
|
|
415
|
+
networks created for that run. Pull the matching images before running:
|
|
389
416
|
|
|
390
417
|
```bash
|
|
391
418
|
python scripts/integration_mysql.py # mysql:8.4
|
|
392
419
|
python scripts/integration_physical.py percona # percona-server/xtrabackup:8.4
|
|
393
420
|
python scripts/integration_physical.py percona-encrypted # AES256 + zstd recovery
|
|
394
421
|
python scripts/integration_physical.py mariadb # mariadb:11.4
|
|
422
|
+
python scripts/integration_pgbackrest.py pg16-2.58 # bdbackup-pgbackrest:16-2.58.0
|
|
423
|
+
python scripts/integration_pgbackrest.py pg18-2.60 # bdbackup-pgbackrest:18-2.60.0
|
|
424
|
+
python scripts/integration_nfs_outage.py # bdbackup-nfs-outage:test, privileged
|
|
395
425
|
```
|
|
396
426
|
|
|
427
|
+
The pgBackRest images have no official source; build them from
|
|
428
|
+
`scripts/docker/pgbackrest.Dockerfile` with the commands in `tests/AGENTS.md`. The NFS
|
|
429
|
+
outage test runs `bdbackup metrics` against a hard NFS mount whose server stops answering. Its
|
|
430
|
+
image installs bdbackup from a wheel built on the host, and the script refuses an image built
|
|
431
|
+
from other sources:
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
rm -rf dist && python -m build -q
|
|
435
|
+
docker build -f scripts/docker/nfs-outage.Dockerfile \
|
|
436
|
+
--build-arg SOURCE_HASH="$(python scripts/integration_nfs_outage.py --source-hash)" \
|
|
437
|
+
-t bdbackup-nfs-outage:test dist
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
It runs a container with `--privileged --network none`, so it needs a Linux kernel with an NFS
|
|
441
|
+
server and iptables.
|
|
442
|
+
|
|
397
443
|
Physical recovery returns a prepared data directory; copying it into a server's
|
|
398
444
|
data directory, assigning ownership to the server user, and starting that server
|
|
399
445
|
are separate administrator actions. Use the same database version and
|