bdbackup 0.7.3__tar.gz → 0.7.5__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.3 → bdbackup-0.7.5}/PKG-INFO +34 -15
- {bdbackup-0.7.3 → bdbackup-0.7.5}/README.md +33 -14
- bdbackup-0.7.5/bdbackup/_ssh_status.sh +12 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/cli.py +78 -13
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/config.py +112 -22
- bdbackup-0.7.5/bdbackup/copy_runner.py +146 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/engines.py +1 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/actions.py +67 -15
- bdbackup-0.7.5/bdbackup/gfs/drift.py +236 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/policy.py +15 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/runner.py +206 -29
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/stages.py +7 -2
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/store.py +20 -6
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/history.py +141 -3
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/collector.py +26 -2
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/data.py +56 -2
- bdbackup-0.7.5/bdbackup/metrics/families.py +224 -0
- bdbackup-0.7.5/bdbackup/metrics/gfs.py +343 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/probe.py +17 -3
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/run.py +13 -7
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/units.py +18 -0
- bdbackup-0.7.5/bdbackup/mongodb/__init__.py +1 -0
- bdbackup-0.7.5/bdbackup/mongodb/export.py +140 -0
- bdbackup-0.7.5/bdbackup/mongodb/pbm.py +233 -0
- bdbackup-0.7.5/bdbackup/mongodb/restore.py +72 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/postgres/pgbackrest.py +9 -89
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/recovery.py +2 -2
- bdbackup-0.7.5/bdbackup/ssh_copy.py +344 -0
- bdbackup-0.7.5/bdbackup/tar_export.py +101 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/validation.py +358 -20
- {bdbackup-0.7.3 → bdbackup-0.7.5}/config.toml.example +57 -6
- bdbackup-0.7.5/docs/README_COPY.md +147 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_ENGINES.md +2 -1
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_FILE.md +12 -0
- bdbackup-0.7.5/docs/README_GFS.md +537 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_METRICS.md +193 -14
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_MYSQLDUMP.md +13 -0
- bdbackup-0.7.5/docs/README_PBM.md +197 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_PGBACKREST.md +33 -10
- {bdbackup-0.7.3 → bdbackup-0.7.5}/pyproject.toml +1 -1
- bdbackup-0.7.5/scripts/docker/pbm.Dockerfile +15 -0
- bdbackup-0.7.5/scripts/docker/ssh-copy.Dockerfile +21 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/integration_nfs_outage.py +185 -7
- bdbackup-0.7.5/scripts/integration_pbm.py +862 -0
- bdbackup-0.7.5/scripts/integration_ssh_copy.py +807 -0
- bdbackup-0.7.5/scripts/smoke_install.py +163 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/AGENTS.md +55 -9
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/conftest.py +14 -0
- bdbackup-0.7.5/tests/pbm_fake.py +17 -0
- bdbackup-0.7.5/tests/ssh_copy_fake.py +58 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_encryption.py +5 -3
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_engines.py +5 -2
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_gfs_config.py +41 -0
- bdbackup-0.7.5/tests/test_gfs_drift.py +438 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_gfs_run.py +956 -15
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_gfs_store.py +2 -2
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_last_runs.py +5 -4
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_ledger.py +1 -1
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_collect.py +13 -3
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_command.py +30 -0
- bdbackup-0.7.5/tests/test_metrics_gfs.py +733 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_probe.py +24 -1
- bdbackup-0.7.5/tests/test_pbm_cli.py +407 -0
- bdbackup-0.7.5/tests/test_pbm_commands.py +185 -0
- bdbackup-0.7.5/tests/test_pbm_config.py +156 -0
- bdbackup-0.7.5/tests/test_pbm_docs.py +43 -0
- bdbackup-0.7.5/tests/test_pbm_export.py +218 -0
- bdbackup-0.7.5/tests/test_pbm_integration.py +291 -0
- bdbackup-0.7.5/tests/test_pbm_validation.py +245 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_pgbackrest_cli.py +195 -2
- bdbackup-0.7.5/tests/test_smoke_install.py +55 -0
- bdbackup-0.7.5/tests/test_ssh_copy_artifact.py +274 -0
- bdbackup-0.7.5/tests/test_ssh_copy_config.py +197 -0
- bdbackup-0.7.5/tests/test_ssh_copy_connection.py +185 -0
- bdbackup-0.7.5/tests/test_ssh_copy_docs.py +38 -0
- bdbackup-0.7.5/tests/test_ssh_copy_history.py +344 -0
- bdbackup-0.7.5/tests/test_ssh_copy_integration.py +72 -0
- bdbackup-0.7.5/tests/test_ssh_copy_probe.py +10 -0
- bdbackup-0.7.5/tests/test_ssh_copy_runner.py +631 -0
- bdbackup-0.7.5/tests/test_ssh_copy_validation.py +243 -0
- bdbackup-0.7.5/tests/test_validate_os_errors.py +188 -0
- bdbackup-0.7.5/tests/test_validate_os_user.py +100 -0
- bdbackup-0.7.5/tests/test_validate_unreachable.py +222 -0
- bdbackup-0.7.3/bdbackup/metrics/families.py +0 -96
- bdbackup-0.7.3/bdbackup/metrics/gfs.py +0 -124
- bdbackup-0.7.3/docs/README_GFS.md +0 -320
- bdbackup-0.7.3/scripts/smoke_install.py +0 -78
- {bdbackup-0.7.3 → bdbackup-0.7.5}/.gitignore +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/LICENSE +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/backends.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/filebackup.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/gfs/structure.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/ledger.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/jobs.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/registry.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/render.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/settings.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics/write.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/metrics_command.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/mysql/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/mysql/helpers.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/mysql/mysqldump.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/mysql/xtrabackup.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/postgres/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/postgres/metrics.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/postgres/repository.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/postgres/restore.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/templates/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/templates/_matching.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/templates/python_dev.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/bdbackup/utils.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/contrib/systemd/bdbackup-incremental@.service +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/contrib/systemd/bdbackup-incremental@.timer +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/contrib/systemd/bdbackup@.service +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/contrib/systemd/bdbackup@.timer +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_SYSTEMD.md +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/docs/README_XTRABACKUP.md +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/check_release.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/docker/nfs-outage.Dockerfile +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/docker/pgbackrest.Dockerfile +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/integration_mysql.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/integration_pgbackrest.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/scripts/integration_physical.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/template.txt +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/__init__.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/pgbackrest_fake.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_architecture.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_broken_pipe.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_cli_reshape.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_config_lexical.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_correctness.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_engine_conditions.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_gfs_init.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_gfs_policy.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_helpers.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_history.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_import.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_config.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_hang.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_phases.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_render.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_metrics_write.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_performance.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_pgbackrest_engine.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_pgbackrest_export.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_pgbackrest_metrics.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_pgbackrest_repository.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_pgbackrest_restore.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_release_fixes.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_run_selector.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_safety_nets.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_security.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_systemd_units.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_templates.py +0 -0
- {bdbackup-0.7.3 → bdbackup-0.7.5}/tests/test_validate_metrics.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.5
|
|
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
|
|
@@ -37,15 +37,17 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
**Backups by design.**
|
|
38
38
|
|
|
39
39
|
bdbackup is a command-line backup tool and Python library for MySQL, MariaDB,
|
|
40
|
-
PostgreSQL
|
|
40
|
+
PostgreSQL, MongoDB and files on Linux and macOS. It takes MySQL and MariaDB
|
|
41
41
|
backups with mysqldump, Percona XtraBackup and MariaDB Backup (full and
|
|
42
42
|
incremental physical backups, compressed and optionally encrypted), exports
|
|
43
|
-
pgBackRest fulls,
|
|
43
|
+
pgBackRest fulls, takes and exports full MongoDB backups with Percona Backup for
|
|
44
|
+
MongoDB (PBM), archives files and directories as tar, tar.gz or tar.zst, and
|
|
44
45
|
rotates the results across storage stages with GFS (grandfather-father-son)
|
|
45
46
|
retention. Every backup is verified before it is
|
|
46
47
|
published and recorded with a SHA-256 checksum in an SQLite backup history, from
|
|
47
|
-
which a guided restore prepares a recovery copy.
|
|
48
|
-
|
|
48
|
+
which a guided restore prepares a recovery copy. File, mysqldump, pgbackrest
|
|
49
|
+
and pbm jobs can send their published archives to an SSH server with rsync or scp.
|
|
50
|
+
Jobs live in one TOML file and run from cron.
|
|
49
51
|
|
|
50
52
|
## Features
|
|
51
53
|
|
|
@@ -56,6 +58,8 @@ run from cron.
|
|
|
56
58
|
gzip-compressed, one database or all.
|
|
57
59
|
- [PostgreSQL pgBackRest backups](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md): the newest
|
|
58
60
|
full of a stanza exported as one tar into a GFS stage, restorable on its own.
|
|
61
|
+
- Take full logical or physical MongoDB backups and export each as one tar.
|
|
62
|
+
[MongoDB backups with PBM](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md)
|
|
59
63
|
- [File and directory backups](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md) as tar archives, with
|
|
60
64
|
gitignore-style exclusion templates.
|
|
61
65
|
- [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md): daily,
|
|
@@ -64,7 +68,8 @@ run from cron.
|
|
|
64
68
|
- [Backup history and guided restore](#backup-history-and-guided-restore) with
|
|
65
69
|
SHA-256 checksums in SQLite.
|
|
66
70
|
- [Configuration validation](#validate-configuration-and-permissions) of
|
|
67
|
-
settings, filesystem permissions
|
|
71
|
+
settings, filesystem permissions, MySQL grants, PBM and SSH copy readiness,
|
|
72
|
+
without running a backup.
|
|
68
73
|
- [Prometheus metrics](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md): a read-only
|
|
69
74
|
`bdbackup metrics` writes a textfile for node_exporter and PMM with the last run of each
|
|
70
75
|
pgbackrest and gfs job, the history, the GFS stages, the destinations and the pgBackRest
|
|
@@ -79,8 +84,10 @@ run from cron.
|
|
|
79
84
|
| [MySQL and MariaDB logical backups with mysqldump](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) | mysqldump jobs, credentials, default options |
|
|
80
85
|
| [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
86
|
| [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 |
|
|
82
|
-
| [
|
|
83
|
-
| [
|
|
87
|
+
| [MongoDB backups with Percona Backup for MongoDB](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md) | pbm jobs, secondary and shared storage, logical and physical backups, GFS and SSH copy, restore and retention |
|
|
88
|
+
| [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 |
|
|
89
|
+
| [Copy published backups to an SSH server](https://github.com/ayder/bdbackup/blob/master/docs/README_COPY.md) | per-job configuration, rsync and scp, server setup, verified publication, retries and failure remedies |
|
|
90
|
+
| [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
91
|
| [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 |
|
|
85
92
|
| [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 |
|
|
86
93
|
| [Annotated configuration](https://github.com/ayder/bdbackup/blob/master/config.toml.example) | every config key with a comment |
|
|
@@ -94,7 +101,8 @@ with Zstandard support. Database binaries are separate system dependencies.
|
|
|
94
101
|
Every built-in backend verifies staging output before publishing it. A missing
|
|
95
102
|
or unreadable file fails the backup and preserves the previous archive. A process
|
|
96
103
|
lock prevents concurrent writers to the same file destination or physical root.
|
|
97
|
-
`--no-verify` skips
|
|
104
|
+
`--no-verify` skips the job's optional verification pass. For pgbackrest and
|
|
105
|
+
pbm jobs this pass reads the temporary tar before publication.
|
|
98
106
|
Verification checks archive readability or physical checkpoints; it does not
|
|
99
107
|
replace testing a restore. File backups are not filesystem snapshots: quiesce
|
|
100
108
|
applications or back up snapshots when files can change during a run.
|
|
@@ -156,9 +164,9 @@ The CLI uses these exit codes:
|
|
|
156
164
|
| Code | Meaning |
|
|
157
165
|
|------|---------|
|
|
158
166
|
| 0 | Success |
|
|
159
|
-
| 1 | Backup
|
|
167
|
+
| 1 | Backup, verification, or SSH copy failure, or failed or incomplete validation. A backend rejecting its settings in a real run also exits 1, except pgbackrest reports a usage error. For `metrics`, the file was written with an error series or could not be written. |
|
|
160
168
|
| 2 | Usage error, an inactive job, or a configuration error found when the config loads or by `--dry-run` |
|
|
161
|
-
| 3 | Lock held
|
|
169
|
+
| 3 | Lock held, including another run holding the job's SSH copy lock. For GFS, another run is in progress or only deferred work remains. For `metrics`, another metrics run holds its lock. |
|
|
162
170
|
|
|
163
171
|
## Config-driven jobs
|
|
164
172
|
|
|
@@ -222,7 +230,8 @@ the read-only `pgbackrest info`. What each job type reports is described with it
|
|
|
222
230
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#dry-run),
|
|
223
231
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#dry-run),
|
|
224
232
|
[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)
|
|
233
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#dry-run-and-validation),
|
|
234
|
+
[pbm jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md#run-and-validate) and
|
|
226
235
|
[GFS jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md#dry-run).
|
|
227
236
|
|
|
228
237
|
A dry run exits 1 where the real run would fail before writing anything (an
|
|
@@ -312,6 +321,13 @@ For a GFS job, every stage path after the first (and the first, when a pgbackres
|
|
|
312
321
|
job writes into it) must exist and be writable, and
|
|
313
322
|
its `.bdbackup-destination` marker must be present and writable; a missing
|
|
314
323
|
marker's line names the `--initialize-structure` command that creates it.
|
|
324
|
+
A path below a directory the OS user cannot search is a FAIL line that names the directory:
|
|
325
|
+
`<label>: <path> is not reachable by OS user <user>: <directory> lacks search (x) permission;
|
|
326
|
+
see namei -l <path>`. Any other error the system returns for a checked path (on NFS,
|
|
327
|
+
`ESTALE`, `EIO` or `ETIMEDOUT`) is `<label>: cannot check <path>: <reason> (<errno name>)`, and
|
|
328
|
+
validation goes on with its other checks. When the account has no entry in the passwd database
|
|
329
|
+
(a container, a directory service that is down), the reports name it `uid <n>`, for example
|
|
330
|
+
`Validation as OS user uid 1000`.
|
|
315
331
|
An unreachable database or missing client is a failed/incomplete check, not a pass.
|
|
316
332
|
Validation does not add SQLite history rows. It exits 0 when its checks pass, 1
|
|
317
333
|
for failed or incomplete checks, and 2 for invalid command or configuration syntax.
|
|
@@ -382,7 +398,8 @@ changed. `--create-checksum` cannot be combined with `--successful`. The checksu
|
|
|
382
398
|
History uses schema version 6, from bdbackup 0.7.3. A database at an older schema upgrades
|
|
383
399
|
on the next write; bdbackup 0.7.2 or earlier refuses a version-6 database. Version 6 adds the
|
|
384
400
|
`last_runs` table: the outcome of the last run of each pgbackrest and gfs job, which
|
|
385
|
-
`bdbackup metrics` reads.
|
|
401
|
+
`bdbackup metrics` reads. For a gfs job it also keeps the facts of its last finished run (reason
|
|
402
|
+
classes, moves by rename and by copy, drift).
|
|
386
403
|
|
|
387
404
|
History is written before work starts, and success only after the backup and its
|
|
388
405
|
requested verification finish. If history cannot be written, the command fails;
|
|
@@ -423,7 +440,8 @@ What a restore produces depends on the job type; see
|
|
|
423
440
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#history-restore),
|
|
424
441
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#history-restore),
|
|
425
442
|
[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)
|
|
443
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#restore),
|
|
444
|
+
[pbm jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md#restore) and
|
|
427
445
|
[custom engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md#history-restore).
|
|
428
446
|
|
|
429
447
|
Deleted artifacts remain in history as unavailable. File identity, size, and
|
|
@@ -460,7 +478,8 @@ python scripts/integration_nfs_outage.py # bdbackup-nfs-outage:test, privileged
|
|
|
460
478
|
|
|
461
479
|
The pgBackRest images have no official source; build them from
|
|
462
480
|
`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
|
|
481
|
+
outage test runs `bdbackup metrics` against a hard NFS mount whose server stops answering, and
|
|
482
|
+
checks that GFS copies a unit onto the share and renames it within it. Its
|
|
464
483
|
image installs bdbackup from a wheel built on the host, and the script refuses an image built
|
|
465
484
|
from other sources:
|
|
466
485
|
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
**Backups by design.**
|
|
4
4
|
|
|
5
5
|
bdbackup is a command-line backup tool and Python library for MySQL, MariaDB,
|
|
6
|
-
PostgreSQL
|
|
6
|
+
PostgreSQL, MongoDB and files on Linux and macOS. It takes MySQL and MariaDB
|
|
7
7
|
backups with mysqldump, Percona XtraBackup and MariaDB Backup (full and
|
|
8
8
|
incremental physical backups, compressed and optionally encrypted), exports
|
|
9
|
-
pgBackRest fulls,
|
|
9
|
+
pgBackRest fulls, takes and exports full MongoDB backups with Percona Backup for
|
|
10
|
+
MongoDB (PBM), archives files and directories as tar, tar.gz or tar.zst, and
|
|
10
11
|
rotates the results across storage stages with GFS (grandfather-father-son)
|
|
11
12
|
retention. Every backup is verified before it is
|
|
12
13
|
published and recorded with a SHA-256 checksum in an SQLite backup history, from
|
|
13
|
-
which a guided restore prepares a recovery copy.
|
|
14
|
-
|
|
14
|
+
which a guided restore prepares a recovery copy. File, mysqldump, pgbackrest
|
|
15
|
+
and pbm jobs can send their published archives to an SSH server with rsync or scp.
|
|
16
|
+
Jobs live in one TOML file and run from cron.
|
|
15
17
|
|
|
16
18
|
## Features
|
|
17
19
|
|
|
@@ -22,6 +24,8 @@ run from cron.
|
|
|
22
24
|
gzip-compressed, one database or all.
|
|
23
25
|
- [PostgreSQL pgBackRest backups](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md): the newest
|
|
24
26
|
full of a stanza exported as one tar into a GFS stage, restorable on its own.
|
|
27
|
+
- Take full logical or physical MongoDB backups and export each as one tar.
|
|
28
|
+
[MongoDB backups with PBM](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md)
|
|
25
29
|
- [File and directory backups](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md) as tar archives, with
|
|
26
30
|
gitignore-style exclusion templates.
|
|
27
31
|
- [GFS (grandfather-father-son) backup rotation](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md): daily,
|
|
@@ -30,7 +34,8 @@ run from cron.
|
|
|
30
34
|
- [Backup history and guided restore](#backup-history-and-guided-restore) with
|
|
31
35
|
SHA-256 checksums in SQLite.
|
|
32
36
|
- [Configuration validation](#validate-configuration-and-permissions) of
|
|
33
|
-
settings, filesystem permissions
|
|
37
|
+
settings, filesystem permissions, MySQL grants, PBM and SSH copy readiness,
|
|
38
|
+
without running a backup.
|
|
34
39
|
- [Prometheus metrics](https://github.com/ayder/bdbackup/blob/master/docs/README_METRICS.md): a read-only
|
|
35
40
|
`bdbackup metrics` writes a textfile for node_exporter and PMM with the last run of each
|
|
36
41
|
pgbackrest and gfs job, the history, the GFS stages, the destinations and the pgBackRest
|
|
@@ -45,8 +50,10 @@ run from cron.
|
|
|
45
50
|
| [MySQL and MariaDB logical backups with mysqldump](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md) | mysqldump jobs, credentials, default options |
|
|
46
51
|
| [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
52
|
| [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 |
|
|
48
|
-
| [
|
|
49
|
-
| [
|
|
53
|
+
| [MongoDB backups with Percona Backup for MongoDB](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md) | pbm jobs, secondary and shared storage, logical and physical backups, GFS and SSH copy, restore and retention |
|
|
54
|
+
| [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 |
|
|
55
|
+
| [Copy published backups to an SSH server](https://github.com/ayder/bdbackup/blob/master/docs/README_COPY.md) | per-job configuration, rsync and scp, server setup, verified publication, retries and failure remedies |
|
|
56
|
+
| [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
57
|
| [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 |
|
|
51
58
|
| [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 |
|
|
52
59
|
| [Annotated configuration](https://github.com/ayder/bdbackup/blob/master/config.toml.example) | every config key with a comment |
|
|
@@ -60,7 +67,8 @@ with Zstandard support. Database binaries are separate system dependencies.
|
|
|
60
67
|
Every built-in backend verifies staging output before publishing it. A missing
|
|
61
68
|
or unreadable file fails the backup and preserves the previous archive. A process
|
|
62
69
|
lock prevents concurrent writers to the same file destination or physical root.
|
|
63
|
-
`--no-verify` skips
|
|
70
|
+
`--no-verify` skips the job's optional verification pass. For pgbackrest and
|
|
71
|
+
pbm jobs this pass reads the temporary tar before publication.
|
|
64
72
|
Verification checks archive readability or physical checkpoints; it does not
|
|
65
73
|
replace testing a restore. File backups are not filesystem snapshots: quiesce
|
|
66
74
|
applications or back up snapshots when files can change during a run.
|
|
@@ -122,9 +130,9 @@ The CLI uses these exit codes:
|
|
|
122
130
|
| Code | Meaning |
|
|
123
131
|
|------|---------|
|
|
124
132
|
| 0 | Success |
|
|
125
|
-
| 1 | Backup
|
|
133
|
+
| 1 | Backup, verification, or SSH copy failure, or failed or incomplete validation. A backend rejecting its settings in a real run also exits 1, except pgbackrest reports a usage error. For `metrics`, the file was written with an error series or could not be written. |
|
|
126
134
|
| 2 | Usage error, an inactive job, or a configuration error found when the config loads or by `--dry-run` |
|
|
127
|
-
| 3 | Lock held
|
|
135
|
+
| 3 | Lock held, including another run holding the job's SSH copy lock. For GFS, another run is in progress or only deferred work remains. For `metrics`, another metrics run holds its lock. |
|
|
128
136
|
|
|
129
137
|
## Config-driven jobs
|
|
130
138
|
|
|
@@ -188,7 +196,8 @@ the read-only `pgbackrest info`. What each job type reports is described with it
|
|
|
188
196
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#dry-run),
|
|
189
197
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#dry-run),
|
|
190
198
|
[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)
|
|
199
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#dry-run-and-validation),
|
|
200
|
+
[pbm jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md#run-and-validate) and
|
|
192
201
|
[GFS jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_GFS.md#dry-run).
|
|
193
202
|
|
|
194
203
|
A dry run exits 1 where the real run would fail before writing anything (an
|
|
@@ -278,6 +287,13 @@ For a GFS job, every stage path after the first (and the first, when a pgbackres
|
|
|
278
287
|
job writes into it) must exist and be writable, and
|
|
279
288
|
its `.bdbackup-destination` marker must be present and writable; a missing
|
|
280
289
|
marker's line names the `--initialize-structure` command that creates it.
|
|
290
|
+
A path below a directory the OS user cannot search is a FAIL line that names the directory:
|
|
291
|
+
`<label>: <path> is not reachable by OS user <user>: <directory> lacks search (x) permission;
|
|
292
|
+
see namei -l <path>`. Any other error the system returns for a checked path (on NFS,
|
|
293
|
+
`ESTALE`, `EIO` or `ETIMEDOUT`) is `<label>: cannot check <path>: <reason> (<errno name>)`, and
|
|
294
|
+
validation goes on with its other checks. When the account has no entry in the passwd database
|
|
295
|
+
(a container, a directory service that is down), the reports name it `uid <n>`, for example
|
|
296
|
+
`Validation as OS user uid 1000`.
|
|
281
297
|
An unreachable database or missing client is a failed/incomplete check, not a pass.
|
|
282
298
|
Validation does not add SQLite history rows. It exits 0 when its checks pass, 1
|
|
283
299
|
for failed or incomplete checks, and 2 for invalid command or configuration syntax.
|
|
@@ -348,7 +364,8 @@ changed. `--create-checksum` cannot be combined with `--successful`. The checksu
|
|
|
348
364
|
History uses schema version 6, from bdbackup 0.7.3. A database at an older schema upgrades
|
|
349
365
|
on the next write; bdbackup 0.7.2 or earlier refuses a version-6 database. Version 6 adds the
|
|
350
366
|
`last_runs` table: the outcome of the last run of each pgbackrest and gfs job, which
|
|
351
|
-
`bdbackup metrics` reads.
|
|
367
|
+
`bdbackup metrics` reads. For a gfs job it also keeps the facts of its last finished run (reason
|
|
368
|
+
classes, moves by rename and by copy, drift).
|
|
352
369
|
|
|
353
370
|
History is written before work starts, and success only after the backup and its
|
|
354
371
|
requested verification finish. If history cannot be written, the command fails;
|
|
@@ -389,7 +406,8 @@ What a restore produces depends on the job type; see
|
|
|
389
406
|
[file jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_FILE.md#history-restore),
|
|
390
407
|
[mysqldump jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_MYSQLDUMP.md#history-restore),
|
|
391
408
|
[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)
|
|
409
|
+
[pgbackrest jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PGBACKREST.md#restore),
|
|
410
|
+
[pbm jobs](https://github.com/ayder/bdbackup/blob/master/docs/README_PBM.md#restore) and
|
|
393
411
|
[custom engines](https://github.com/ayder/bdbackup/blob/master/docs/README_ENGINES.md#history-restore).
|
|
394
412
|
|
|
395
413
|
Deleted artifacts remain in history as unavailable. File identity, size, and
|
|
@@ -426,7 +444,8 @@ python scripts/integration_nfs_outage.py # bdbackup-nfs-outage:test, privileged
|
|
|
426
444
|
|
|
427
445
|
The pgBackRest images have no official source; build them from
|
|
428
446
|
`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
|
|
447
|
+
outage test runs `bdbackup metrics` against a hard NFS mount whose server stops answering, and
|
|
448
|
+
checks that GFS copies a unit onto the share and renames it within it. Its
|
|
430
449
|
image installs bdbackup from a wheel built on the host, and the script refuses an image built
|
|
431
450
|
from other sources:
|
|
432
451
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# The transfer tool owns the SSH streams. Record only the SSH process status.
|
|
3
|
+
status_file=${BDBACKUP_SSH_STATUS:?missing SSH status path}
|
|
4
|
+
if ! command -v ssh >/dev/null 2>&1; then
|
|
5
|
+
printf '%s\n' 'missing' > "$status_file"
|
|
6
|
+
printf '%s\n' 'ssh: executable not found' >&2
|
|
7
|
+
exit 127
|
|
8
|
+
fi
|
|
9
|
+
ssh "$@"
|
|
10
|
+
status=$?
|
|
11
|
+
printf '%s\n' "$status" > "$status_file"
|
|
12
|
+
exit "$status"
|
|
@@ -14,7 +14,7 @@ from pathlib import Path
|
|
|
14
14
|
import click
|
|
15
15
|
from click.core import ParameterSource
|
|
16
16
|
|
|
17
|
-
from bdbackup import __version__
|
|
17
|
+
from bdbackup import __version__, copy_runner
|
|
18
18
|
from bdbackup.backends import BackupError, setup_logging
|
|
19
19
|
from bdbackup.config import Config, ConfigError, Job, build_backend
|
|
20
20
|
from bdbackup.filebackup import FileBackup
|
|
@@ -24,10 +24,14 @@ from bdbackup.gfs import structure as gfs_structure
|
|
|
24
24
|
from bdbackup.gfs.stages import fed_first_stages
|
|
25
25
|
from bdbackup.history import History, HistoryError
|
|
26
26
|
from bdbackup.metrics_command import run_metrics
|
|
27
|
+
from bdbackup.mongodb.pbm import PBM
|
|
28
|
+
from bdbackup.mongodb.restore import describe_unit as describe_pbm_unit
|
|
29
|
+
from bdbackup.mongodb.restore import restore_lines as pbm_restore_lines
|
|
27
30
|
from bdbackup.mysql import MySQLBackup, XtraBackup
|
|
28
31
|
from bdbackup.postgres.pgbackrest import ExportProgress
|
|
29
32
|
from bdbackup.postgres.restore import describe_unit, restore_lines
|
|
30
33
|
from bdbackup.recovery import backup_restore_info, restore_record, suggested_destination
|
|
34
|
+
from bdbackup.ssh_copy import CopySettings
|
|
31
35
|
from bdbackup.templates import TemplateError
|
|
32
36
|
from bdbackup.utils import process_lock
|
|
33
37
|
from bdbackup.validation import validate_config
|
|
@@ -58,7 +62,8 @@ def config_option(**kwargs):
|
|
|
58
62
|
def main(log_level: str) -> None:
|
|
59
63
|
"""Backups by design.
|
|
60
64
|
|
|
61
|
-
File
|
|
65
|
+
File, MySQL, MariaDB, PostgreSQL and MongoDB backups with verification,
|
|
66
|
+
retention, and guided recovery.
|
|
62
67
|
"""
|
|
63
68
|
setup_logging(getattr(logging, log_level.upper(), logging.INFO))
|
|
64
69
|
|
|
@@ -105,14 +110,23 @@ def _history_config(path: Path | None) -> Config:
|
|
|
105
110
|
return config
|
|
106
111
|
|
|
107
112
|
|
|
108
|
-
def _tracked_backup(
|
|
113
|
+
def _tracked_backup(
|
|
114
|
+
config, name, backup_type, action, restore_info=None, *,
|
|
115
|
+
encrypted=False, copy: CopySettings | None = None,
|
|
116
|
+
):
|
|
109
117
|
if config.history:
|
|
110
118
|
return History(config.history).run(
|
|
111
|
-
name, backup_type, action, restore_info, encrypted=encrypted,
|
|
119
|
+
name, backup_type, action, restore_info, encrypted=encrypted, copy=copy,
|
|
112
120
|
)
|
|
113
121
|
return action()
|
|
114
122
|
|
|
115
123
|
|
|
124
|
+
def _run_copy(config: Config, job: Job) -> int:
|
|
125
|
+
if job.copy is None:
|
|
126
|
+
return EXIT_OK
|
|
127
|
+
return copy_runner.run_job(History(config.history), job.name, job.copy, _echo)
|
|
128
|
+
|
|
129
|
+
|
|
116
130
|
def _protect_history(backend, config):
|
|
117
131
|
if config.history and isinstance(backend, FileBackup):
|
|
118
132
|
database = config.history.database
|
|
@@ -153,6 +167,11 @@ def _handle_errors(func, *args, **kwargs) -> int:
|
|
|
153
167
|
return code if isinstance(code, int) else EXIT_OK
|
|
154
168
|
|
|
155
169
|
|
|
170
|
+
def _dry_copy(job: Job) -> None:
|
|
171
|
+
if job.copy is not None:
|
|
172
|
+
_echo(f"Dry run; configured copy: {job.copy.destination} ({job.copy.method})")
|
|
173
|
+
|
|
174
|
+
|
|
156
175
|
def _dry_run(config: Config, job: Job, incremental: bool) -> None:
|
|
157
176
|
"""Report what a run of ``job`` would do; run no tool and write nothing."""
|
|
158
177
|
backend = build_backend(job)
|
|
@@ -162,6 +181,9 @@ def _dry_run(config: Config, job: Job, incremental: bool) -> None:
|
|
|
162
181
|
_echo(f"Dry run; would create: {backend.tar_filename}")
|
|
163
182
|
elif isinstance(backend, MySQLBackup):
|
|
164
183
|
_echo(f"Dry run; would dump {backend.selection()} into {backend.out_dir}")
|
|
184
|
+
elif isinstance(backend, PBM):
|
|
185
|
+
_echo(f"Dry run; would take a {backend.backup_type} PBM backup and export it into "
|
|
186
|
+
f"{backend.out_dir}")
|
|
165
187
|
elif isinstance(backend, XtraBackup) and incremental:
|
|
166
188
|
_echo(f"Dry run; would take an incremental of {backend.incremental_parent()} "
|
|
167
189
|
f"under {backend.backup_root}")
|
|
@@ -169,6 +191,7 @@ def _dry_run(config: Config, job: Job, incremental: bool) -> None:
|
|
|
169
191
|
_echo(f"Dry run; would take a full backup under {backend.backup_root}")
|
|
170
192
|
else:
|
|
171
193
|
raise click.UsageError(f"--dry-run is not supported for job type {job.type!r}")
|
|
194
|
+
_dry_copy(job)
|
|
172
195
|
|
|
173
196
|
|
|
174
197
|
@dataclass
|
|
@@ -307,13 +330,34 @@ def _run_pgbackrest(
|
|
|
307
330
|
began.append(_now())
|
|
308
331
|
return engine.export(full, verify=verify, progress=outcome.progress)
|
|
309
332
|
|
|
310
|
-
result = _tracked_backup(config, job.name, "pgbackrest-full", export, info)
|
|
333
|
+
result = _tracked_backup(config, job.name, "pgbackrest-full", export, info, copy=job.copy)
|
|
311
334
|
outcome.result = "exported"
|
|
312
335
|
outcome.facts = _export_facts(full, result, outcome.progress, began[0])
|
|
313
336
|
_echo(f"Job {job.name}: {result.path}")
|
|
314
337
|
return EXIT_OK
|
|
315
338
|
|
|
316
339
|
|
|
340
|
+
def _run_pgbackrest_job(
|
|
341
|
+
config: Config, job: Job, *, verify: bool, dry_run: bool, outcome: _Outcome
|
|
342
|
+
) -> int:
|
|
343
|
+
code = _run_pgbackrest(config, job, verify=verify, dry_run=dry_run, outcome=outcome)
|
|
344
|
+
if dry_run:
|
|
345
|
+
_dry_copy(job)
|
|
346
|
+
return code
|
|
347
|
+
if code != EXIT_OK or job.copy is None:
|
|
348
|
+
return code
|
|
349
|
+
|
|
350
|
+
# The export lock is released. Keep its facts and report any copy-phase failure.
|
|
351
|
+
export_result = outcome.result
|
|
352
|
+
outcome.result = "copy_failed"
|
|
353
|
+
code = _run_copy(config, job)
|
|
354
|
+
if code == EXIT_OK:
|
|
355
|
+
outcome.result = export_result
|
|
356
|
+
elif code == EXIT_LOCKED:
|
|
357
|
+
outcome.result = "copy_deferred"
|
|
358
|
+
return code
|
|
359
|
+
|
|
360
|
+
|
|
317
361
|
@main.command(name="run")
|
|
318
362
|
@config_option(required=True)
|
|
319
363
|
@click.option("-j", "--job", "job_name", help="Run this configured job.")
|
|
@@ -398,12 +442,13 @@ def run(
|
|
|
398
442
|
code = gfs_runner.run_job(
|
|
399
443
|
config, job, out=_echo, dry_run=dry_run, outcome=outcome.gfs
|
|
400
444
|
)
|
|
445
|
+
outcome.facts = outcome.gfs.facts # none for a busy lock, and a raise never gets here
|
|
401
446
|
ctx.exit(code if code in (EXIT_OK, EXIT_LOCKED) else EXIT_BACKUP_FAILED)
|
|
402
447
|
if job.type == "pgbackrest":
|
|
403
448
|
outcome = _Outcome()
|
|
404
449
|
with nullcontext() if dry_run else _last_run(config, job, outcome):
|
|
405
450
|
ctx.exit(_handle_errors(
|
|
406
|
-
|
|
451
|
+
_run_pgbackrest_job, config, job, verify=verify, dry_run=dry_run, outcome=outcome
|
|
407
452
|
))
|
|
408
453
|
if dry_run:
|
|
409
454
|
return _handle_errors(_dry_run, config, job, incremental)
|
|
@@ -411,6 +456,9 @@ def run(
|
|
|
411
456
|
|
|
412
457
|
def _create():
|
|
413
458
|
backend = build_backend(job)
|
|
459
|
+
if isinstance(backend, PBM):
|
|
460
|
+
# PBM verifies its temporary tar before publication.
|
|
461
|
+
return backend.backup(job.name, verify=verify, restore_info=info)
|
|
414
462
|
_protect_history(backend, config)
|
|
415
463
|
info.update(backup_restore_info(backend))
|
|
416
464
|
result = (
|
|
@@ -424,13 +472,18 @@ def run(
|
|
|
424
472
|
return result
|
|
425
473
|
|
|
426
474
|
backup_type = job.type
|
|
475
|
+
guard = nullcontext()
|
|
427
476
|
if job.type == "xtrabackup":
|
|
428
477
|
backup_type = "xtrabackup-incremental" if incremental else "xtrabackup-full"
|
|
478
|
+
elif job.type == "pbm":
|
|
479
|
+
backup_type = f"pbm-{job.params.get('backup_type', 'logical')}"
|
|
480
|
+
guard = process_lock(Path(f"{config.history.database}.pbm-{job.name}.lock"))
|
|
429
481
|
try:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
482
|
+
with guard:
|
|
483
|
+
result = _tracked_backup(
|
|
484
|
+
config, job.name, backup_type, _create, info,
|
|
485
|
+
encrypted=job.params.get("encrypt") is True, copy=job.copy,
|
|
486
|
+
)
|
|
434
487
|
except BlockingIOError as exc:
|
|
435
488
|
logger.error("Job %r locked: %s", job.name, exc)
|
|
436
489
|
ctx.exit(EXIT_LOCKED)
|
|
@@ -438,7 +491,7 @@ def run(
|
|
|
438
491
|
logger.error("Job %r failed: %s", job.name, exc)
|
|
439
492
|
ctx.exit(EXIT_BACKUP_FAILED)
|
|
440
493
|
_echo(f"Job {job.name}: {result.path}")
|
|
441
|
-
|
|
494
|
+
ctx.exit(_handle_errors(_run_copy, config, job))
|
|
442
495
|
|
|
443
496
|
|
|
444
497
|
def _restore_mode(config_path, backup_id, job, yes, dst, archive, backup, root, binary,
|
|
@@ -468,11 +521,14 @@ def _restore_mode(config_path, backup_id, job, yes, dst, archive, backup, root,
|
|
|
468
521
|
|
|
469
522
|
|
|
470
523
|
def _echo_restore_command(directory: Path) -> None:
|
|
471
|
-
"""Print the
|
|
524
|
+
"""Print the operator steps for an extracted pgBackRest or PBM unit."""
|
|
472
525
|
facts = describe_unit(directory)
|
|
473
526
|
if facts is not None:
|
|
474
527
|
for line in restore_lines(facts, directory.expanduser().absolute()):
|
|
475
528
|
_echo(line)
|
|
529
|
+
elif (pbm_facts := describe_pbm_unit(directory)) is not None:
|
|
530
|
+
for line in pbm_restore_lines(pbm_facts):
|
|
531
|
+
_echo(line)
|
|
476
532
|
|
|
477
533
|
|
|
478
534
|
@main.command()
|
|
@@ -588,7 +644,7 @@ def restore(
|
|
|
588
644
|
_echo(f"Prepared recovery directory: {restored}")
|
|
589
645
|
else:
|
|
590
646
|
_echo(f"Restored to: {restored}")
|
|
591
|
-
if record.backup_type
|
|
647
|
+
if record.backup_type in {"pgbackrest-full", "pbm-logical", "pbm-physical"}:
|
|
592
648
|
_echo_restore_command(restored)
|
|
593
649
|
|
|
594
650
|
return _handle_errors(_run)
|
|
@@ -620,16 +676,25 @@ def history_cmd(config_path: Path, job: str | None, successful: bool,
|
|
|
620
676
|
records = history.records(job=job, successful=successful)
|
|
621
677
|
suffixes = gfs_store.listing_suffixes(history)
|
|
622
678
|
known = gfs_store.places(history)
|
|
679
|
+
deliveries = {delivery.record_id: delivery for delivery in history.deliveries(job=job)}
|
|
623
680
|
if not records:
|
|
624
681
|
_echo("No backup history found.")
|
|
625
682
|
for record in records:
|
|
626
683
|
available = "available" if gfs_store.available(record, known) else "unavailable"
|
|
684
|
+
# A backup can finish between the records and deliveries reads.
|
|
685
|
+
delivery = deliveries.get(record.id) if record.status == "success" else None
|
|
686
|
+
copy_suffix = ""
|
|
687
|
+
if delivery is not None:
|
|
688
|
+
copy_suffix = f" | copy {delivery.status}"
|
|
689
|
+
if delivery.failure_class is not None:
|
|
690
|
+
copy_suffix += f" ({delivery.failure_class})"
|
|
627
691
|
_echo(
|
|
628
692
|
f"{record.id}: {record.job_name} | {record.backup_type} | {record.started_at} | "
|
|
629
693
|
f"{record.status} | {available} | "
|
|
630
694
|
f"{'encrypted' if record.encrypted else 'unencrypted'} | {record.path or '-'}"
|
|
631
695
|
f" | unit {record.unit or '-'}"
|
|
632
696
|
f"{suffixes.get(record.unit, '') if record.unit else ''}"
|
|
697
|
+
f"{copy_suffix}"
|
|
633
698
|
)
|
|
634
699
|
|
|
635
700
|
_handle_errors(_checksums if create_checksum else _listing)
|