bdbackup 0.6.1__tar.gz → 0.6.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.6.1 → bdbackup-0.6.3}/PKG-INFO +291 -8
- {bdbackup-0.6.1 → bdbackup-0.6.3}/README.md +290 -7
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/cli.py +113 -21
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/config.py +35 -3
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/filebackup.py +15 -3
- bdbackup-0.6.3/bdbackup/gfs/__init__.py +0 -0
- bdbackup-0.6.3/bdbackup/gfs/actions.py +196 -0
- bdbackup-0.6.3/bdbackup/gfs/policy.py +134 -0
- bdbackup-0.6.3/bdbackup/gfs/runner.py +398 -0
- bdbackup-0.6.3/bdbackup/gfs/stages.py +174 -0
- bdbackup-0.6.3/bdbackup/gfs/store.py +346 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/history.py +118 -3
- bdbackup-0.6.3/bdbackup/ledger.py +74 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/mysql/xtrabackup.py +16 -3
- bdbackup-0.6.3/bdbackup/recovery.py +155 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/scheduling.py +3 -1
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/validation.py +26 -2
- {bdbackup-0.6.1 → bdbackup-0.6.3}/config.toml.example +76 -1
- {bdbackup-0.6.1 → bdbackup-0.6.3}/pyproject.toml +1 -1
- {bdbackup-0.6.1 → bdbackup-0.6.3}/scripts/integration_mysql.py +57 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/scripts/integration_physical.py +97 -5
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_encryption.py +5 -2
- bdbackup-0.6.3/tests/test_engine_conditions.py +132 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_engines.py +1 -1
- bdbackup-0.6.3/tests/test_gfs_config.py +165 -0
- bdbackup-0.6.3/tests/test_gfs_policy.py +143 -0
- bdbackup-0.6.3/tests/test_gfs_run.py +941 -0
- bdbackup-0.6.3/tests/test_gfs_store.py +103 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_helpers.py +33 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_history.py +56 -0
- bdbackup-0.6.3/tests/test_ledger.py +244 -0
- bdbackup-0.6.3/tests/test_run_selector.py +155 -0
- bdbackup-0.6.1/bdbackup/recovery.py +0 -80
- {bdbackup-0.6.1 → bdbackup-0.6.3}/.gitignore +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/LICENSE +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/__init__.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/backends.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/dboperations.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/engines.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/mysql/__init__.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/mysql/helpers.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/mysql/mysqldump.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/retention.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/templates/__init__.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/templates/_matching.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/templates/python_dev.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/bdbackup/utils.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/scripts/check_release.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/scripts/smoke_install.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/template.txt +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/__init__.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/conftest.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_architecture.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_cli.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_correctness.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_import.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_performance.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_release_fixes.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_retention.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_safety_nets.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_security.py +0 -0
- {bdbackup-0.6.1 → bdbackup-0.6.3}/tests/test_templates.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bdbackup
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: File and MySQL/MariaDB backups with verification, retention, and guided recovery
|
|
5
5
|
Project-URL: Homepage, https://github.com/ayder/bdbackup
|
|
6
6
|
Project-URL: Repository, https://github.com/ayder/bdbackup
|
|
@@ -145,10 +145,16 @@ Options:
|
|
|
145
145
|
| `--exclude-pattern` | Glob pattern to exclude (repeatable) |
|
|
146
146
|
| `--exclude-template` | Named exclusion template, e.g. `python-dev` (repeatable, comma-separated allowed) |
|
|
147
147
|
| `--follow-symlinks` | Follow symbolic links when archiving |
|
|
148
|
+
| `--timestamp / --no-timestamp` | Write `<dst>-<UTC YYYY-MM-DD-HHMMSS><ext>` instead of replacing one archive; an existing name is never overwritten (default: off) |
|
|
148
149
|
| `--dry-run` | List what would be archived without writing anything |
|
|
149
150
|
| `--verify / --no-verify` | Verify the archive after creation (default: on) |
|
|
150
151
|
| `--logging` | Log level: `DEBUG`, `INFO`, `WARNING`, `ERROR` |
|
|
151
152
|
|
|
153
|
+
Without `--timestamp`, every run replaces the same archive, so only the newest
|
|
154
|
+
run stays restorable. With it, each run writes a new archive such as
|
|
155
|
+
`daily-2026-09-29-020000.tar.gz`, and a run that would reuse an existing name
|
|
156
|
+
fails instead. Config jobs set `timestamp = true`.
|
|
157
|
+
|
|
152
158
|
Restore a file archive:
|
|
153
159
|
|
|
154
160
|
```bash
|
|
@@ -193,6 +199,9 @@ TEMPLATE = ExclusionTemplate(
|
|
|
193
199
|
|
|
194
200
|
## Database engines
|
|
195
201
|
|
|
202
|
+
`schedule` and `restore_root` are job metadata and are not passed to an engine backend.
|
|
203
|
+
Custom engines accepting arbitrary keyword arguments no longer receive `restore_root`.
|
|
204
|
+
|
|
196
205
|
Database engines are pluggable and live in per-database family packages
|
|
197
206
|
(`bdbackup/mysql/` today; `bdbackup/postgres/` is planned). Each engine maps a
|
|
198
207
|
config `type` name to a backend class; adding one never requires editing
|
|
@@ -346,7 +355,7 @@ Options:
|
|
|
346
355
|
| `--encrypt-key-file` | Required 32-byte key file when encrypting; also used by `prepare` |
|
|
347
356
|
| `--parallel` | Number of copy threads (default: 1) |
|
|
348
357
|
| `--throttle` | Limit I/O to this many IOPS |
|
|
349
|
-
| `--retention` | Days of backups to keep (default: 5) |
|
|
358
|
+
| `--retention` | Days of backups to keep (default: 5); `0` disables engine deletion |
|
|
350
359
|
| `--verify / --no-verify` | Verify the backup after creation (default: on) |
|
|
351
360
|
|
|
352
361
|
A process lock prevents two backup runs from corrupting the same backup root.
|
|
@@ -412,7 +421,11 @@ it. Original backups remain encrypted; the recovery directory contains plaintext
|
|
|
412
421
|
For manual `xtrabackup prepare`, supply `--encrypt-key-file` as well.
|
|
413
422
|
See [Percona's encryption documentation](https://docs.percona.com/percona-xtrabackup/8.4/encrypt-backups.html).
|
|
414
423
|
|
|
415
|
-
## Retention
|
|
424
|
+
## Retention of flat files (`type = "retention"`)
|
|
425
|
+
|
|
426
|
+
This section handles flat backup files written by other tools. For bdbackup's
|
|
427
|
+
own backups, use `type = "gfs"` (see [Ledger and GFS](#ledger-and-gfs)), which
|
|
428
|
+
moves backups between storage tiers using the history ledger.
|
|
416
429
|
|
|
417
430
|
The `bdbackup retention` command applies a grandfather-father-son policy to
|
|
418
431
|
a backup tree: keep **every** backup for the last N days, then **one per ISO
|
|
@@ -514,7 +527,7 @@ mysqldump job, set `database = "mydatabase"`; for all databases include
|
|
|
514
527
|
`--all-databases` in `options`.
|
|
515
528
|
|
|
516
529
|
Except for the optional `[history]` settings, each top-level table is one job;
|
|
517
|
-
its keys (except `type` and
|
|
530
|
+
its keys (except `type`, `schedule`, and `restore_root`) are passed
|
|
518
531
|
to the backend constructor, so they use Python-style underscores
|
|
519
532
|
(`exclude_templates`), not CLI dashes. See [config.toml.example](https://github.com/ayder/bdbackup/blob/main/config.toml.example)
|
|
520
533
|
for a fully annotated config with every option explained.
|
|
@@ -531,6 +544,34 @@ Run every job:
|
|
|
531
544
|
bdbackup run --config ~/.config/bdbackup/config.toml --all
|
|
532
545
|
```
|
|
533
546
|
|
|
547
|
+
For an xtrabackup job, take an incremental using its own `backup_root`, credentials,
|
|
548
|
+
binary, and encryption settings:
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
bdbackup run --config ~/.config/bdbackup/config.toml mysql-prod --incremental
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
`--full` is the default; an incremental requires a successful full in that job's
|
|
555
|
+
root and chains to the latest successful incremental, if present. `--full` and
|
|
556
|
+
`--incremental` together exit 2. Selecting any non-xtrabackup job with
|
|
557
|
+
`--incremental` also exits 2 before any job runs. `--verify/--no-verify` applies to
|
|
558
|
+
both backup kinds. Validation and cron recommendations ignore the selector.
|
|
559
|
+
|
|
560
|
+
For example, schedule a weekly full on Sunday and incrementals on the other days:
|
|
561
|
+
|
|
562
|
+
```cron
|
|
563
|
+
0 2 * * 0 bdbackup --config /opt/dbs/config.toml run mysql-prod
|
|
564
|
+
0 2 * * 1-6 bdbackup --config /opt/dbs/config.toml run mysql-prod --incremental
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
Pruning after each full deletes whole dated chains older than `retention_days`.
|
|
568
|
+
Set `retention_days` longer than the interval between fulls to preserve the previous
|
|
569
|
+
full's incrementals. `retention_days = 0` disables engine deletion for the job,
|
|
570
|
+
both the automatic pruning after a full and `bdbackup xtrabackup prune`; use it
|
|
571
|
+
when another tool rotates the backups. History now records configured physical backups as
|
|
572
|
+
`xtrabackup-full` / `xtrabackup-incremental` (previously `xtrabackup`); update filters
|
|
573
|
+
that use the old type. Existing history rows are unchanged.
|
|
574
|
+
|
|
534
575
|
### Validate configuration and permissions
|
|
535
576
|
|
|
536
577
|
Check all configured jobs without creating a backup or running retention:
|
|
@@ -617,6 +658,14 @@ are not inspected; review those separately. If crontab cannot be read, suggested
|
|
|
617
658
|
entries are still shown but the helper exits with status 1.
|
|
618
659
|
|
|
619
660
|
XtraBackup job entries run full backups, including their built-in pruning.
|
|
661
|
+
The helper recommends fulls only; add an incremental cron entry yourself, for example:
|
|
662
|
+
|
|
663
|
+
```cron
|
|
664
|
+
0 2 * * 1-6 bdbackup --config /opt/dbs/config.toml run mysql-prod --incremental
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
Adjust the recommended full entry to your intended full-backup schedule.
|
|
668
|
+
|
|
620
669
|
Separate retention jobs remain for flat backup files; `apply = false` stays a dry
|
|
621
670
|
run in cron too. Validation/cron helpers exit 0 when their checks pass, 1 for failed
|
|
622
671
|
or incomplete checks, and 2 for invalid command/configuration syntax.
|
|
@@ -659,6 +708,38 @@ exception class. Retention, restore operations, and file dry runs are not backup
|
|
|
659
708
|
attempts and do not create rows. Direct Python backend calls are not automatically
|
|
660
709
|
recorded; applications can wrap them with `History.run`.
|
|
661
710
|
|
|
711
|
+
Every successful backup also records its unit and a SHA-256 checksum taken right
|
|
712
|
+
after the backup, which costs one extra read of the backup. A file's checksum is
|
|
713
|
+
the SHA-256 of its content. A directory's checksum is the SHA-256 of a manifest
|
|
714
|
+
with one line per regular file, `<sha256> <relative path>`, sorted by path; a
|
|
715
|
+
symlink or special file inside a physical backup fails the backup. The unit is
|
|
716
|
+
what a rotation tool moves as one piece: the archive or dump file itself, or for
|
|
717
|
+
xtrabackup the dated directory that holds the full and all of its incrementals.
|
|
718
|
+
`bdbackup history` shows it as `unit <path>`, or `unit -` for records without one.
|
|
719
|
+
For units that GFS manages, the line continues with `| stage <stage path> |
|
|
720
|
+
locations <path>, …`, or `| deleted <time>` once GFS has removed the unit.
|
|
721
|
+
Reproduce a directory checksum on Linux (use `shasum -a 256` on macOS):
|
|
722
|
+
|
|
723
|
+
```bash
|
|
724
|
+
cd /backup/mysql/production/2026-09-29/Full_<id> && find . -type f -print0 \
|
|
725
|
+
| LC_ALL=C sort -z | xargs -0 sha256sum | sed 's| \./| |' | sha256sum
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Records taken before this release have no checksum. Record them explicitly:
|
|
729
|
+
|
|
730
|
+
```bash
|
|
731
|
+
bdbackup history checksum --config config.toml
|
|
732
|
+
bdbackup history checksum --config config.toml --job mysql-prod
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
It prints `<id>: recorded`, `<id>: skipped: unavailable` for an artifact that is
|
|
736
|
+
missing or was replaced, or `<id>: skipped: unexpected unit` for a physical backup
|
|
737
|
+
outside its dated layout, and then exits 1. A checksum already recorded is never
|
|
738
|
+
changed. The checksum lives in the `checksum` column of the `backup_runs` table.
|
|
739
|
+
|
|
740
|
+
History uses schema version 5. An existing database upgrades on the next write;
|
|
741
|
+
older bdbackup versions refuse a version-5 database.
|
|
742
|
+
|
|
662
743
|
History is written before work starts, and success only after the backup and its
|
|
663
744
|
requested verification finish. If history cannot be written, the command fails;
|
|
664
745
|
an artifact already created is preserved. A forcibly killed process may leave a
|
|
@@ -672,6 +753,18 @@ bdbackup restore --config config.toml
|
|
|
672
753
|
bdbackup restore --config config.toml --job files-daily
|
|
673
754
|
```
|
|
674
755
|
|
|
756
|
+
Each backup job may set `restore_root = "/restore/mysql-prod"` to override
|
|
757
|
+
`[history] restore_root` for its guided-restore suggestions. It must be a nonempty
|
|
758
|
+
path string; `~` expands and relative paths resolve against the config file.
|
|
759
|
+
Job-level `restore_root` requires `[history]` and is not allowed on retention jobs.
|
|
760
|
+
Validation checks that each job's root is writable or can be created.
|
|
761
|
+
Physical jobs usually need a separate root with room for the full and its
|
|
762
|
+
incrementals, staged near the database datadir.
|
|
763
|
+
|
|
764
|
+
The current config's job is matched by the history record's job name. If that job
|
|
765
|
+
has no `restore_root`, or is no longer configured, the history root is used.
|
|
766
|
+
An explicit `--dst` always wins.
|
|
767
|
+
|
|
675
768
|
Restore lists successful, available artifacts, asks for the backup ID, suggests
|
|
676
769
|
`<restore_root>/<job>-<id>`, and asks for confirmation. You can edit the suggested
|
|
677
770
|
path. Repeated restores suggest a numbered alternative; history-based restore
|
|
@@ -694,10 +787,200 @@ bdbackup restore --config config.toml --backup-id 12 --dst /restore/job-12 --yes
|
|
|
694
787
|
|
|
695
788
|
Deleted artifacts remain in history as unavailable. File identity, size, and
|
|
696
789
|
modification time detect replaced archives, so older rows for a reused filename
|
|
697
|
-
are not offered as older recovery points.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
790
|
+
are not offered as older recovery points. Availability uses these file checks.
|
|
791
|
+
Restore checks the recorded checksum of every file it uses for backups that GFS
|
|
792
|
+
manages (see [Ledger and GFS](#ledger-and-gfs)); for other backups it
|
|
793
|
+
validates the actual archive or physical dependency chain. History stores
|
|
794
|
+
references to artifacts and does not preserve an archive that a later backup
|
|
795
|
+
replaces.
|
|
796
|
+
|
|
797
|
+
## Ledger and GFS
|
|
798
|
+
|
|
799
|
+
GFS moves bdbackup's own backups through a chain of storage tiers, called stages,
|
|
800
|
+
using only the history ledger: it never guesses from what lies on disk. A typical
|
|
801
|
+
chain keeps everything for 5 days on a fast local disk, everything for 15 more
|
|
802
|
+
days on cheap NFS storage (point-in-time recovery from incrementals), then one
|
|
803
|
+
backup per week, per month and per year.
|
|
804
|
+
|
|
805
|
+
```toml
|
|
806
|
+
[gfs-main]
|
|
807
|
+
type = "gfs"
|
|
808
|
+
apply = false # dry run unless true
|
|
809
|
+
# schedule = "0 4 * * *"
|
|
810
|
+
|
|
811
|
+
[[gfs-main.stage]]
|
|
812
|
+
paths = ["/BACKUP"] # engines write here
|
|
813
|
+
period = "daily"
|
|
814
|
+
keep = "5d"
|
|
815
|
+
|
|
816
|
+
[[gfs-main.stage]]
|
|
817
|
+
paths = ["/NFS/daily"]
|
|
818
|
+
period = "daily"
|
|
819
|
+
keep = "20d" # 5 days hot + 15 days on NFS
|
|
820
|
+
|
|
821
|
+
[[gfs-main.stage]]
|
|
822
|
+
paths = ["/NFS/weekly"]
|
|
823
|
+
period = "weekly"
|
|
824
|
+
keep = "8w"
|
|
825
|
+
|
|
826
|
+
[[gfs-main.stage]]
|
|
827
|
+
paths = ["/NFS/monthly"]
|
|
828
|
+
period = "monthly"
|
|
829
|
+
keep = "12m"
|
|
830
|
+
|
|
831
|
+
[[gfs-main.stage]]
|
|
832
|
+
paths = ["/NFS/yearly", "/DD/yearly"] # every path receives a copy
|
|
833
|
+
period = "yearly"
|
|
834
|
+
keep = "7y"
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
Run it with `bdbackup run --config config.toml gfs-main`. `--cron` schedules GFS
|
|
838
|
+
jobs with retention at 04:00, after backups.
|
|
839
|
+
|
|
840
|
+
**Stages and ages.** `keep` is an age counted from the backup day: `Nd` days,
|
|
841
|
+
`Nw` weeks, `Nm` calendar months, `Ny` years. A backup belongs to the first stage
|
|
842
|
+
whose `keep` it is still within; past the last stage it is deleted. Each `keep`
|
|
843
|
+
must be longer than the previous one on every calendar (a month counts as 28–31
|
|
844
|
+
days), and periods never go backwards along the chain. The first stage has
|
|
845
|
+
exactly one path and is where backup jobs write.
|
|
846
|
+
|
|
847
|
+
**Periods.** A daily stage keeps every backup. A weekly stage keeps the newest
|
|
848
|
+
backup of each ISO week; a monthly stage, of those, the newest dated in each
|
|
849
|
+
month; a yearly stage, of those, the newest dated in each year. Selection is per
|
|
850
|
+
job, so a tar job and a MySQL job never compete for one slot. A week is decided
|
|
851
|
+
only once it has ended, and a month or year only once the ISO week holding its
|
|
852
|
+
last day has ended, so a choice never changes later; until then the backup is
|
|
853
|
+
reported `held: <bucket> not complete` and stays where it is.
|
|
854
|
+
|
|
855
|
+
With the configuration above on Tuesday 2026-09-29 and one backup per day:
|
|
856
|
+
|
|
857
|
+
| Backup | Result | Why |
|
|
858
|
+
|---|---|---|
|
|
859
|
+
| 2026-09-24 | `/NFS/daily` | within 20d |
|
|
860
|
+
| 2026-09-09 | deleted | its week's newest backup is 09-13 |
|
|
861
|
+
| 2026-09-06 (Sun) | `/NFS/weekly` | newest of ISO week 36 |
|
|
862
|
+
| 2026-08-30 (Sun) | `/NFS/weekly` | newest of week 35; also August's monthly backup |
|
|
863
|
+
| 2026-08-02 (Sun) | deleted | newest of its week, not of August |
|
|
864
|
+
| 2026-07-26 (Sun) | `/NFS/monthly` | July's newest weekly backup |
|
|
865
|
+
| 2025-12-28 (Sun) | `/NFS/monthly` | also 2025's yearly backup |
|
|
866
|
+
| 2024-12-29 (Sun) | `/NFS/yearly` | 2024's yearly backup |
|
|
867
|
+
|
|
868
|
+
**Units and paths.** GFS moves a unit as one piece: an archive or dump file, or
|
|
869
|
+
an xtrabackup dated directory with its full and every incremental (and its
|
|
870
|
+
`Full_Latest` and `.full_success` markers). A unit keeps its path relative to
|
|
871
|
+
the first stage, so `/BACKUP/mysql/prod/2026-09-29` becomes
|
|
872
|
+
`/NFS/daily/mysql/prod/2026-09-29`. The newest unit of each job always stays in
|
|
873
|
+
the first stage, so the next incremental finds its full.
|
|
874
|
+
|
|
875
|
+
**Safety.** Each later stage path must contain an empty file named
|
|
876
|
+
`.bdbackup-destination`; an unmounted mount point is an empty local directory
|
|
877
|
+
without it, and GFS writes nothing there (`--validate` reports it). GFS copies to
|
|
878
|
+
a temporary name, checks every checksum while reading the source, and removes
|
|
879
|
+
the original only after every copy is in place and recorded; a failed copy
|
|
880
|
+
removes its temporary copies and the next run retries. Before a move,
|
|
881
|
+
every copy of the unit is checked, not only the one copied, and
|
|
882
|
+
copies keep the permission bits of every file and directory. If the
|
|
883
|
+
ledger lists a unit in two stages (left by an earlier version or a hand edit),
|
|
884
|
+
the next run removes the earlier copy only after the later copies verify.
|
|
885
|
+
Copies hold no backup lock,
|
|
886
|
+
so a slow NFS copy never blocks a backup; if an xtrabackup root is locked when
|
|
887
|
+
GFS commits, the unit is reported `deferred: locked` and retried next run. GFS
|
|
888
|
+
only touches backups recorded in the ledger. It refuses, and reports:
|
|
889
|
+
|
|
890
|
+
- `refused: checksum mismatch`: the backup changed since it was recorded. To
|
|
891
|
+
accept the change, set the `checksum` column of its `backup_runs` rows to the
|
|
892
|
+
new value with `sqlite3`; the next run acts on it. A backup that changed
|
|
893
|
+
before GFS first saw it is never managed.
|
|
894
|
+
- `refused: unexpected entry …`: a unit holds something that is not one of its
|
|
895
|
+
recorded backups or engine markers, such as a leftover `.tmp` directory, or a
|
|
896
|
+
symlink or special file inside a backup.
|
|
897
|
+
- `refused: stage not configured`: the unit lives under a stage no longer in the
|
|
898
|
+
configuration. Removing a stage never deletes its backups; restore the stage
|
|
899
|
+
or remove them yourself. Changing the first stage's path keeps managing units
|
|
900
|
+
already moved to later stages; units left under the
|
|
901
|
+
old first-stage path are no longer managed.
|
|
902
|
+
- `refused: destination not ready …`: a stage path lacks its marker.
|
|
903
|
+
|
|
904
|
+
Backup jobs writing into the first stage must not delete or overwrite on their
|
|
905
|
+
own: xtrabackup jobs set `retention_days = 0` and file jobs set
|
|
906
|
+
`timestamp = true`. Configuration validation enforces both, rejects stage paths
|
|
907
|
+
that overlap, and keeps the live history database out of stage paths.
|
|
908
|
+
|
|
909
|
+
`apply = false` (the default) prints what would move or be deleted and changes
|
|
910
|
+
nothing. Exit codes: 0 done, 1 a refusal or failure, 2 configuration error, 3
|
|
911
|
+
another run of the same job is in progress, or the only unfinished units were
|
|
912
|
+
deferred.
|
|
913
|
+
|
|
914
|
+
**Unmanaged backups.** A backup that was unavailable when GFS first saw it (for
|
|
915
|
+
example an older run of a file job without `timestamp`, whose archive a later
|
|
916
|
+
run replaced) stays unmanaged on every later run: GFS never moves or deletes it,
|
|
917
|
+
and the report counts it in `unmanaged`.
|
|
918
|
+
|
|
919
|
+
**Report.** Each run lists every unit it acted on, held, deferred or refused,
|
|
920
|
+
then a `Summary:` line with counts and bytes per action. One line per stage
|
|
921
|
+
follows, such as `Stage /NFS/daily: 15 units (3200000000 bytes)`, counting where
|
|
922
|
+
the units are when the run ends (where they would be, in a dry run), and then
|
|
923
|
+
the ledger copies written.
|
|
924
|
+
|
|
925
|
+
**Step log.** Every step is also recorded in the `gfs_steps` table of the history
|
|
926
|
+
database, one row per path, with its source, destination, outcome
|
|
927
|
+
and reason. A failed step keeps the error message.
|
|
928
|
+
|
|
929
|
+
**Run log.** Every applying run records one row in the `gfs_runs` table:
|
|
930
|
+
the GFS job, start and finish time, status, exit code and the Summary counts.
|
|
931
|
+
The status is `running` while the run works, `completed` once it reaches its report
|
|
932
|
+
(whatever the exit code), and `failed` if the run itself crashed. A row left
|
|
933
|
+
`running` shows a run that was cut off; check that run's steps for leftovers
|
|
934
|
+
(Known limits below). Each `gfs_steps` row names its run in `run_id`. A dry run
|
|
935
|
+
records nothing.
|
|
936
|
+
|
|
937
|
+
**Running backups.** While a job has a backup in state `running` in the
|
|
938
|
+
ledger, GFS leaves every backup of that job where it is, whatever its age, and
|
|
939
|
+
reports each one as
|
|
940
|
+
`deferred: backup running (record <id>, started <time>)`.
|
|
941
|
+
Other jobs proceed as usual, and a run whose only unfinished work is these
|
|
942
|
+
deferrals exits 3. A backup killed before it finished (`kill -9`, a power loss)
|
|
943
|
+
leaves its row `running`, and that job stays deferred until you fix the row. After
|
|
944
|
+
checking that no backup of that job is running, mark it failed:
|
|
945
|
+
`sqlite3 <history database> "UPDATE backup_runs SET status = 'failed' WHERE id = <id>"`.
|
|
946
|
+
|
|
947
|
+
**Restoring moved backups.** `bdbackup restore` and `bdbackup history` find a
|
|
948
|
+
backup where GFS put it. `history` shows a copy that was removed or replaced as
|
|
949
|
+
`unavailable`. Before restoring, every backup file used is checked against its
|
|
950
|
+
ledger checksum; with several paths in a stage, the first path that verifies is
|
|
951
|
+
used, and the `Backup:` line names it. An xtrabackup chain is prepared from the
|
|
952
|
+
stage directory holding it, which keeps the layout of the first stage.
|
|
953
|
+
|
|
954
|
+
**Ledger copies.** After every applying run, each path of every stage after the
|
|
955
|
+
first holds `<gfs job>.ledger.sqlite3`, a consistent copy of the whole history
|
|
956
|
+
database, written under a temporary name and renamed into place. A path without
|
|
957
|
+
its marker gets none, and the run exits 1. To restore with only a stage left,
|
|
958
|
+
copy that file somewhere outside the stages, point `[history] database` at the
|
|
959
|
+
copy, and run `bdbackup restore`. Paths in the ledger are absolute, so the
|
|
960
|
+
stages must be mounted at the same paths as when the copy was written.
|
|
961
|
+
|
|
962
|
+
**Known limits.** GFS does not yet keep a journal of a move or delete while it
|
|
963
|
+
runs, so a few failures leave work for the operator. The report and the step log
|
|
964
|
+
name the paths involved, and each leftover is
|
|
965
|
+
removed by hand:
|
|
966
|
+
|
|
967
|
+
- A move was recorded, but removing the old copy failed. The old copy stays on
|
|
968
|
+
disk, no longer in the ledger, and GFS never touches it again. Delete it.
|
|
969
|
+
- A move failed, or the process stopped, after some new copies were renamed into
|
|
970
|
+
place but before the move was recorded. The next run reports
|
|
971
|
+
`refused: final name exists: <path>`. Delete that copy; the next run moves the
|
|
972
|
+
unit again.
|
|
973
|
+
- A delete failed part way. The next run reports `refused: missing location …`
|
|
974
|
+
for a copy already removed. Delete its row with
|
|
975
|
+
`sqlite3 <history database> "DELETE FROM gfs_locations WHERE path = '<path>'"`.
|
|
976
|
+
If that was the unit's last row, also mark the unit deleted, or later runs
|
|
977
|
+
report `refused: stage not configured`:
|
|
978
|
+
`sqlite3 <history database> "UPDATE gfs_units SET deleted_at = datetime('now') WHERE id = <unit_id>"`
|
|
979
|
+
(the `unit_id` of the row you deleted).
|
|
980
|
+
- A restore stops when the xtrabackup copy at the first path of a stage has
|
|
981
|
+
damaged checkpoints or chain metadata; it does not move on to the next path.
|
|
982
|
+
Prepare the copy at another path of that stage with
|
|
983
|
+
`bdbackup xtrabackup prepare -r <directory holding the copy> -d <new dir> <backup>`.
|
|
701
984
|
|
|
702
985
|
## Development
|
|
703
986
|
|