bdbackup 0.7.2__tar.gz → 0.7.4__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.2 → bdbackup-0.7.4}/PKG-INFO +52 -10
- {bdbackup-0.7.2 → bdbackup-0.7.4}/README.md +51 -9
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/cli.py +188 -37
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/config.py +34 -10
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/engines.py +10 -1
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/actions.py +67 -15
- bdbackup-0.7.4/bdbackup/gfs/drift.py +236 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/policy.py +15 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/runner.py +221 -30
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/stages.py +34 -14
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/store.py +20 -6
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/history.py +92 -5
- bdbackup-0.7.4/bdbackup/metrics/__init__.py +5 -0
- bdbackup-0.7.4/bdbackup/metrics/collector.py +176 -0
- bdbackup-0.7.4/bdbackup/metrics/data.py +151 -0
- bdbackup-0.7.4/bdbackup/metrics/families.py +224 -0
- bdbackup-0.7.4/bdbackup/metrics/gfs.py +343 -0
- bdbackup-0.7.4/bdbackup/metrics/jobs.py +103 -0
- bdbackup-0.7.4/bdbackup/metrics/probe.py +193 -0
- bdbackup-0.7.4/bdbackup/metrics/registry.py +55 -0
- bdbackup-0.7.4/bdbackup/metrics/render.py +82 -0
- bdbackup-0.7.4/bdbackup/metrics/run.py +252 -0
- bdbackup-0.7.4/bdbackup/metrics/settings.py +35 -0
- bdbackup-0.7.4/bdbackup/metrics/units.py +93 -0
- bdbackup-0.7.4/bdbackup/metrics/write.py +31 -0
- bdbackup-0.7.4/bdbackup/metrics_command.py +220 -0
- bdbackup-0.7.4/bdbackup/postgres/metrics.py +263 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/postgres/pgbackrest.py +96 -13
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/utils.py +14 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/validation.py +159 -18
- {bdbackup-0.7.2 → bdbackup-0.7.4}/config.toml.example +22 -2
- bdbackup-0.7.4/docs/README_ENGINES.md +115 -0
- bdbackup-0.7.4/docs/README_GFS.md +527 -0
- bdbackup-0.7.4/docs/README_METRICS.md +537 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/docs/README_PGBACKREST.md +54 -7
- {bdbackup-0.7.2 → bdbackup-0.7.4}/pyproject.toml +1 -1
- bdbackup-0.7.4/scripts/docker/nfs-outage.Dockerfile +26 -0
- bdbackup-0.7.4/scripts/integration_nfs_outage.py +559 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/scripts/integration_pgbackrest.py +169 -1
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/AGENTS.md +21 -8
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/conftest.py +14 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/pgbackrest_fake.py +53 -8
- bdbackup-0.7.4/tests/test_broken_pipe.py +149 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_cli_reshape.py +3 -2
- bdbackup-0.7.4/tests/test_config_lexical.py +159 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_encryption.py +4 -3
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_gfs_config.py +41 -0
- bdbackup-0.7.4/tests/test_gfs_drift.py +438 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_gfs_run.py +1102 -16
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_gfs_store.py +3 -3
- bdbackup-0.7.4/tests/test_last_runs.py +175 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_ledger.py +1 -1
- bdbackup-0.7.4/tests/test_metrics_collect.py +802 -0
- bdbackup-0.7.4/tests/test_metrics_command.py +366 -0
- bdbackup-0.7.4/tests/test_metrics_config.py +126 -0
- bdbackup-0.7.4/tests/test_metrics_gfs.py +733 -0
- bdbackup-0.7.4/tests/test_metrics_hang.py +161 -0
- bdbackup-0.7.4/tests/test_metrics_phases.py +170 -0
- bdbackup-0.7.4/tests/test_metrics_probe.py +450 -0
- bdbackup-0.7.4/tests/test_metrics_render.py +217 -0
- bdbackup-0.7.4/tests/test_metrics_write.py +209 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_pgbackrest_cli.py +317 -1
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_pgbackrest_engine.py +131 -1
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_pgbackrest_export.py +169 -1
- bdbackup-0.7.4/tests/test_pgbackrest_metrics.py +708 -0
- bdbackup-0.7.4/tests/test_validate_metrics.py +129 -0
- bdbackup-0.7.4/tests/test_validate_os_errors.py +188 -0
- bdbackup-0.7.4/tests/test_validate_os_user.py +100 -0
- bdbackup-0.7.4/tests/test_validate_unreachable.py +222 -0
- bdbackup-0.7.2/docs/README_ENGINES.md +0 -64
- bdbackup-0.7.2/docs/README_GFS.md +0 -305
- {bdbackup-0.7.2 → bdbackup-0.7.4}/.gitignore +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/LICENSE +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/__init__.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/backends.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/filebackup.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/__init__.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/gfs/structure.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/ledger.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/mysql/__init__.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/mysql/helpers.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/mysql/mysqldump.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/mysql/xtrabackup.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/postgres/__init__.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/postgres/repository.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/postgres/restore.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/recovery.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/templates/__init__.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/templates/_matching.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/bdbackup/templates/python_dev.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/contrib/systemd/bdbackup-incremental@.service +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/contrib/systemd/bdbackup-incremental@.timer +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/contrib/systemd/bdbackup@.service +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/contrib/systemd/bdbackup@.timer +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/docs/README_FILE.md +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/docs/README_MYSQLDUMP.md +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/docs/README_SYSTEMD.md +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/docs/README_XTRABACKUP.md +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/scripts/check_release.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/scripts/docker/pgbackrest.Dockerfile +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/scripts/integration_mysql.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/scripts/integration_physical.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/scripts/smoke_install.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/template.txt +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/__init__.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_architecture.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_correctness.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_engine_conditions.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_engines.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_gfs_init.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_gfs_policy.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_helpers.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_history.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_import.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_performance.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_pgbackrest_repository.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_pgbackrest_restore.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_release_fixes.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_run_selector.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_safety_nets.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_security.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/tests/test_systemd_units.py +0 -0
- {bdbackup-0.7.2 → bdbackup-0.7.4}/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.4
|
|
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
|
|
@@ -65,6 +65,10 @@ run from cron.
|
|
|
65
65
|
SHA-256 checksums in SQLite.
|
|
66
66
|
- [Configuration validation](#validate-configuration-and-permissions) of
|
|
67
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.
|
|
68
72
|
- [Custom backup engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md) as plugins.
|
|
69
73
|
|
|
70
74
|
## Documentation
|
|
@@ -75,8 +79,9 @@ run from cron.
|
|
|
75
79
|
| [MySQL and MariaDB logical backups with mysqldump](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) | mysqldump jobs, credentials, default options |
|
|
76
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 |
|
|
77
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 |
|
|
78
|
-
| [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 |
|
|
79
|
-
| [
|
|
82
|
+
| [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md) | stages, the `verify` key, preparing stage directories, safety rules and renames, final name exists, drift, run and step logs, ledger copies, known limits |
|
|
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 (coverage and drift of the GFS stages included), 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 |
|
|
80
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 |
|
|
81
86
|
| [Annotated configuration](https://github.com/ayder/bdbackup/blob/master/config.toml.example) | every config key with a comment |
|
|
82
87
|
|
|
@@ -124,7 +129,7 @@ pip install -e ".[dev]"
|
|
|
124
129
|
|
|
125
130
|
## Commands
|
|
126
131
|
|
|
127
|
-
`bdbackup` has
|
|
132
|
+
`bdbackup` has four commands; everything else is an option:
|
|
128
133
|
|
|
129
134
|
```bash
|
|
130
135
|
bdbackup run -c CONFIG -j JOB [--full | --incremental] [--no-verify] [--dry-run]
|
|
@@ -134,6 +139,7 @@ bdbackup restore -c CONFIG [--backup-id N] [--job JOB] [-y] [-d DIR] [--encrypt
|
|
|
134
139
|
bdbackup restore --archive ARCHIVE -d DIR
|
|
135
140
|
bdbackup restore --backup BACKUP --root ROOT -d DIR [--binary BINARY] [--encrypt-key-file KEY]
|
|
136
141
|
bdbackup history -c CONFIG [--job JOB] [--successful | --create-checksum]
|
|
142
|
+
bdbackup metrics -c CONFIG
|
|
137
143
|
```
|
|
138
144
|
|
|
139
145
|
`-c` is `--config` on every command; `-j` is the short form of `--job` on `run`
|
|
@@ -142,14 +148,17 @@ only (`restore` and `history` take `--job`). `bdbackup` itself takes only
|
|
|
142
148
|
`bdbackup --logging DEBUG run -c config.toml -j files-daily`. Levels: `DEBUG`,
|
|
143
149
|
`INFO`, `WARNING`, `ERROR`.
|
|
144
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
|
+
|
|
145
154
|
The CLI uses these exit codes:
|
|
146
155
|
|
|
147
156
|
| Code | Meaning |
|
|
148
157
|
|------|---------|
|
|
149
158
|
| 0 | Success |
|
|
150
|
-
| 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 |
|
|
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 |
|
|
151
160
|
| 2 | Usage error, an inactive job, or a configuration error found when the config loads or by `--dry-run` |
|
|
152
|
-
| 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 |
|
|
153
162
|
|
|
154
163
|
## Config-driven jobs
|
|
155
164
|
|
|
@@ -189,7 +198,7 @@ config file's directory. Template entries and `exclude` entries resolve against
|
|
|
189
198
|
mysqldump job, set `database = "mydatabase"`; for all databases include
|
|
190
199
|
`--all-databases` in `options`.
|
|
191
200
|
|
|
192
|
-
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;
|
|
193
202
|
its keys (except `type`, `active` and `restore_root`) are passed
|
|
194
203
|
to the backend constructor, so they use Python-style underscores
|
|
195
204
|
(`exclude_templates`). See [config.toml.example](https://github.com/ayder/bdbackup/blob/master/config.toml.example)
|
|
@@ -246,6 +255,14 @@ Times use the cron daemon's timezone, and separate lines do not wait for each
|
|
|
246
255
|
other: leave enough time for backups before GFS. Add `--dry-run` to the GFS line
|
|
247
256
|
until its report looks right.
|
|
248
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
|
+
|
|
249
266
|
xtrabackup jobs can run from systemd timers instead, which also stop the backup
|
|
250
267
|
tool if bdbackup dies and add per-job limits: see
|
|
251
268
|
[Running xtrabackup jobs with systemd timers](https://github.com/ayder/bdbackup/blob/master/docs/README_SYSTEMD.md).
|
|
@@ -295,6 +312,13 @@ For a GFS job, every stage path after the first (and the first, when a pgbackres
|
|
|
295
312
|
job writes into it) must exist and be writable, and
|
|
296
313
|
its `.bdbackup-destination` marker must be present and writable; a missing
|
|
297
314
|
marker's line names the `--initialize-structure` command that creates it.
|
|
315
|
+
A path below a directory the OS user cannot search is a FAIL line that names the directory:
|
|
316
|
+
`<label>: <path> is not reachable by OS user <user>: <directory> lacks search (x) permission;
|
|
317
|
+
see namei -l <path>`. Any other error the system returns for a checked path (on NFS,
|
|
318
|
+
`ESTALE`, `EIO` or `ETIMEDOUT`) is `<label>: cannot check <path>: <reason> (<errno name>)`, and
|
|
319
|
+
validation goes on with its other checks. When the account has no entry in the passwd database
|
|
320
|
+
(a container, a directory service that is down), the reports name it `uid <n>`, for example
|
|
321
|
+
`Validation as OS user uid 1000`.
|
|
298
322
|
An unreachable database or missing client is a failed/incomplete check, not a pass.
|
|
299
323
|
Validation does not add SQLite history rows. It exits 0 when its checks pass, 1
|
|
300
324
|
for failed or incomplete checks, and 2 for invalid command or configuration syntax.
|
|
@@ -362,8 +386,11 @@ missing or was replaced, or `<id>: skipped: unexpected unit` for a physical back
|
|
|
362
386
|
outside its dated layout, and then exits 1. A checksum already recorded is never
|
|
363
387
|
changed. `--create-checksum` cannot be combined with `--successful`. The checksum lives in the `checksum` column of the `backup_runs` table.
|
|
364
388
|
|
|
365
|
-
History uses schema version
|
|
366
|
-
write; bdbackup 0.
|
|
389
|
+
History uses schema version 6, from bdbackup 0.7.3. A database at an older schema upgrades
|
|
390
|
+
on the next write; bdbackup 0.7.2 or earlier refuses a version-6 database. Version 6 adds the
|
|
391
|
+
`last_runs` table: the outcome of the last run of each pgbackrest and gfs job, which
|
|
392
|
+
`bdbackup metrics` reads. For a gfs job it also keeps the facts of its last finished run (reason
|
|
393
|
+
classes, moves by rename and by copy, drift).
|
|
367
394
|
|
|
368
395
|
History is written before work starts, and success only after the backup and its
|
|
369
396
|
requested verification finish. If history cannot be written, the command fails;
|
|
@@ -436,10 +463,25 @@ python scripts/integration_physical.py percona-encrypted # AES256 + zstd recover
|
|
|
436
463
|
python scripts/integration_physical.py mariadb # mariadb:11.4
|
|
437
464
|
python scripts/integration_pgbackrest.py pg16-2.58 # bdbackup-pgbackrest:16-2.58.0
|
|
438
465
|
python scripts/integration_pgbackrest.py pg18-2.60 # bdbackup-pgbackrest:18-2.60.0
|
|
466
|
+
python scripts/integration_nfs_outage.py # bdbackup-nfs-outage:test, privileged
|
|
439
467
|
```
|
|
440
468
|
|
|
441
469
|
The pgBackRest images have no official source; build them from
|
|
442
|
-
`scripts/docker/pgbackrest.Dockerfile` with the commands in `tests/AGENTS.md`.
|
|
470
|
+
`scripts/docker/pgbackrest.Dockerfile` with the commands in `tests/AGENTS.md`. The NFS
|
|
471
|
+
outage test runs `bdbackup metrics` against a hard NFS mount whose server stops answering, and
|
|
472
|
+
checks that GFS copies a unit onto the share and renames it within it. Its
|
|
473
|
+
image installs bdbackup from a wheel built on the host, and the script refuses an image built
|
|
474
|
+
from other sources:
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
rm -rf dist && python -m build -q
|
|
478
|
+
docker build -f scripts/docker/nfs-outage.Dockerfile \
|
|
479
|
+
--build-arg SOURCE_HASH="$(python scripts/integration_nfs_outage.py --source-hash)" \
|
|
480
|
+
-t bdbackup-nfs-outage:test dist
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
It runs a container with `--privileged --network none`, so it needs a Linux kernel with an NFS
|
|
484
|
+
server and iptables.
|
|
443
485
|
|
|
444
486
|
Physical recovery returns a prepared data directory; copying it into a server's
|
|
445
487
|
data directory, assigning ownership to the server user, and starting that server
|
|
@@ -31,6 +31,10 @@ run from cron.
|
|
|
31
31
|
SHA-256 checksums in SQLite.
|
|
32
32
|
- [Configuration validation](#validate-configuration-and-permissions) of
|
|
33
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.
|
|
34
38
|
- [Custom backup engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md) as plugins.
|
|
35
39
|
|
|
36
40
|
## Documentation
|
|
@@ -41,8 +45,9 @@ run from cron.
|
|
|
41
45
|
| [MySQL and MariaDB logical backups with mysqldump](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) | mysqldump jobs, credentials, default options |
|
|
42
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 |
|
|
43
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 |
|
|
44
|
-
| [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 |
|
|
45
|
-
| [
|
|
48
|
+
| [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md) | stages, the `verify` key, preparing stage directories, safety rules and renames, final name exists, drift, run and step logs, ledger copies, known limits |
|
|
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 (coverage and drift of the GFS stages included), 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 |
|
|
46
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 |
|
|
47
52
|
| [Annotated configuration](https://github.com/ayder/bdbackup/blob/master/config.toml.example) | every config key with a comment |
|
|
48
53
|
|
|
@@ -90,7 +95,7 @@ pip install -e ".[dev]"
|
|
|
90
95
|
|
|
91
96
|
## Commands
|
|
92
97
|
|
|
93
|
-
`bdbackup` has
|
|
98
|
+
`bdbackup` has four commands; everything else is an option:
|
|
94
99
|
|
|
95
100
|
```bash
|
|
96
101
|
bdbackup run -c CONFIG -j JOB [--full | --incremental] [--no-verify] [--dry-run]
|
|
@@ -100,6 +105,7 @@ bdbackup restore -c CONFIG [--backup-id N] [--job JOB] [-y] [-d DIR] [--encrypt
|
|
|
100
105
|
bdbackup restore --archive ARCHIVE -d DIR
|
|
101
106
|
bdbackup restore --backup BACKUP --root ROOT -d DIR [--binary BINARY] [--encrypt-key-file KEY]
|
|
102
107
|
bdbackup history -c CONFIG [--job JOB] [--successful | --create-checksum]
|
|
108
|
+
bdbackup metrics -c CONFIG
|
|
103
109
|
```
|
|
104
110
|
|
|
105
111
|
`-c` is `--config` on every command; `-j` is the short form of `--job` on `run`
|
|
@@ -108,14 +114,17 @@ only (`restore` and `history` take `--job`). `bdbackup` itself takes only
|
|
|
108
114
|
`bdbackup --logging DEBUG run -c config.toml -j files-daily`. Levels: `DEBUG`,
|
|
109
115
|
`INFO`, `WARNING`, `ERROR`.
|
|
110
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
|
+
|
|
111
120
|
The CLI uses these exit codes:
|
|
112
121
|
|
|
113
122
|
| Code | Meaning |
|
|
114
123
|
|------|---------|
|
|
115
124
|
| 0 | Success |
|
|
116
|
-
| 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 |
|
|
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 |
|
|
117
126
|
| 2 | Usage error, an inactive job, or a configuration error found when the config loads or by `--dry-run` |
|
|
118
|
-
| 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 |
|
|
119
128
|
|
|
120
129
|
## Config-driven jobs
|
|
121
130
|
|
|
@@ -155,7 +164,7 @@ config file's directory. Template entries and `exclude` entries resolve against
|
|
|
155
164
|
mysqldump job, set `database = "mydatabase"`; for all databases include
|
|
156
165
|
`--all-databases` in `options`.
|
|
157
166
|
|
|
158
|
-
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;
|
|
159
168
|
its keys (except `type`, `active` and `restore_root`) are passed
|
|
160
169
|
to the backend constructor, so they use Python-style underscores
|
|
161
170
|
(`exclude_templates`). See [config.toml.example](https://github.com/ayder/bdbackup/blob/master/config.toml.example)
|
|
@@ -212,6 +221,14 @@ Times use the cron daemon's timezone, and separate lines do not wait for each
|
|
|
212
221
|
other: leave enough time for backups before GFS. Add `--dry-run` to the GFS line
|
|
213
222
|
until its report looks right.
|
|
214
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
|
+
|
|
215
232
|
xtrabackup jobs can run from systemd timers instead, which also stop the backup
|
|
216
233
|
tool if bdbackup dies and add per-job limits: see
|
|
217
234
|
[Running xtrabackup jobs with systemd timers](https://github.com/ayder/bdbackup/blob/master/docs/README_SYSTEMD.md).
|
|
@@ -261,6 +278,13 @@ For a GFS job, every stage path after the first (and the first, when a pgbackres
|
|
|
261
278
|
job writes into it) must exist and be writable, and
|
|
262
279
|
its `.bdbackup-destination` marker must be present and writable; a missing
|
|
263
280
|
marker's line names the `--initialize-structure` command that creates it.
|
|
281
|
+
A path below a directory the OS user cannot search is a FAIL line that names the directory:
|
|
282
|
+
`<label>: <path> is not reachable by OS user <user>: <directory> lacks search (x) permission;
|
|
283
|
+
see namei -l <path>`. Any other error the system returns for a checked path (on NFS,
|
|
284
|
+
`ESTALE`, `EIO` or `ETIMEDOUT`) is `<label>: cannot check <path>: <reason> (<errno name>)`, and
|
|
285
|
+
validation goes on with its other checks. When the account has no entry in the passwd database
|
|
286
|
+
(a container, a directory service that is down), the reports name it `uid <n>`, for example
|
|
287
|
+
`Validation as OS user uid 1000`.
|
|
264
288
|
An unreachable database or missing client is a failed/incomplete check, not a pass.
|
|
265
289
|
Validation does not add SQLite history rows. It exits 0 when its checks pass, 1
|
|
266
290
|
for failed or incomplete checks, and 2 for invalid command or configuration syntax.
|
|
@@ -328,8 +352,11 @@ missing or was replaced, or `<id>: skipped: unexpected unit` for a physical back
|
|
|
328
352
|
outside its dated layout, and then exits 1. A checksum already recorded is never
|
|
329
353
|
changed. `--create-checksum` cannot be combined with `--successful`. The checksum lives in the `checksum` column of the `backup_runs` table.
|
|
330
354
|
|
|
331
|
-
History uses schema version
|
|
332
|
-
write; bdbackup 0.
|
|
355
|
+
History uses schema version 6, from bdbackup 0.7.3. A database at an older schema upgrades
|
|
356
|
+
on the next write; bdbackup 0.7.2 or earlier refuses a version-6 database. Version 6 adds the
|
|
357
|
+
`last_runs` table: the outcome of the last run of each pgbackrest and gfs job, which
|
|
358
|
+
`bdbackup metrics` reads. For a gfs job it also keeps the facts of its last finished run (reason
|
|
359
|
+
classes, moves by rename and by copy, drift).
|
|
333
360
|
|
|
334
361
|
History is written before work starts, and success only after the backup and its
|
|
335
362
|
requested verification finish. If history cannot be written, the command fails;
|
|
@@ -402,10 +429,25 @@ python scripts/integration_physical.py percona-encrypted # AES256 + zstd recover
|
|
|
402
429
|
python scripts/integration_physical.py mariadb # mariadb:11.4
|
|
403
430
|
python scripts/integration_pgbackrest.py pg16-2.58 # bdbackup-pgbackrest:16-2.58.0
|
|
404
431
|
python scripts/integration_pgbackrest.py pg18-2.60 # bdbackup-pgbackrest:18-2.60.0
|
|
432
|
+
python scripts/integration_nfs_outage.py # bdbackup-nfs-outage:test, privileged
|
|
405
433
|
```
|
|
406
434
|
|
|
407
435
|
The pgBackRest images have no official source; build them from
|
|
408
|
-
`scripts/docker/pgbackrest.Dockerfile` with the commands in `tests/AGENTS.md`.
|
|
436
|
+
`scripts/docker/pgbackrest.Dockerfile` with the commands in `tests/AGENTS.md`. The NFS
|
|
437
|
+
outage test runs `bdbackup metrics` against a hard NFS mount whose server stops answering, and
|
|
438
|
+
checks that GFS copies a unit onto the share and renames it within it. Its
|
|
439
|
+
image installs bdbackup from a wheel built on the host, and the script refuses an image built
|
|
440
|
+
from other sources:
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
rm -rf dist && python -m build -q
|
|
444
|
+
docker build -f scripts/docker/nfs-outage.Dockerfile \
|
|
445
|
+
--build-arg SOURCE_HASH="$(python scripts/integration_nfs_outage.py --source-hash)" \
|
|
446
|
+
-t bdbackup-nfs-outage:test dist
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
It runs a container with `--privileged --network none`, so it needs a Linux kernel with an NFS
|
|
450
|
+
server and iptables.
|
|
409
451
|
|
|
410
452
|
Physical recovery returns a prepared data directory; copying it into a server's
|
|
411
453
|
data directory, assigning ownership to the server user, and starting that server
|