pbkfs is a Rust FUSE filesystem that mounts pg_probackup backups as a PostgreSQL-ready data directory with copy-on-write diffs. Backups in pbk_store stay immutable; all writes flow to a writable pbk_diff, enabling fast analysis or recovery drills without restoring full copies.
- CLI commands implemented:
mount,unmount,cleanup,stat. - Supports FULL and incremental backup chains (including mixed compression) with binding metadata stored in
pbk_diffto enforce single-use semantics. - Target platform: Linux with libfuse3-compatible tooling.
- Rust 1.80 (pinned via
rust-toolchain.toml). - libfuse3 / FUSE userspace tools installed.
- pg_probackup ≥ 2.5 with a populated
pbk_store. - PostgreSQL 14–17 available for validation.
cargo fmt
cargo clippy --all-targets --all-features
cargo test
cargo auditpbkfs supports two mount modes:
- Background (default):
pbkfs mountforks a worker and returns after it starts. Use--wait/--timeoutto wait for mount completion. - Console: add
--consoleto keep the mount in the foreground (useful for interactive debugging).
Initial mount (requires instance and backup id when pbk_diff has no binding yet):
pbkfs mount \
-B /pgbackups \
--mnt-path /mnt/pbkfs-main \
--instance main \
-i SBOL94 \
--diff-dir /var/lib/pbkfs/diff-main \
--console- Validates the FULL→incremental chain, writes binding metadata to
pbk_diff, and mounts FUSE atmnt-path. - Use
--forceonly to mount a chain marked corrupt, or to override an existing.pbkfs-dirtymarker from a previous--perf-unsaferun.
Background mount (wait for completion):
pbkfs mount \
-B /pgbackups \
--mnt-path /mnt/pbkfs-main \
--instance main \
-i SBOL94 \
--diff-dir /var/lib/pbkfs/diff-main \
--waitRemount using existing diff binding (instance/backup flags are optional but must match if provided):
pbkfs mount \
-B /pgbackups \
--mnt-path /mnt/pbkfs-main \
--diff-dir /var/lib/pbkfs/diff-mainUnmount:
pbkfs unmount --mnt-path /mnt/pbkfs-mainDump mount statistics:
pbkfs stat --mnt-path /mnt/pbkfs-main
pbkfs stat --mnt-path /mnt/pbkfs-main --format json
pbkfs stat --mnt-path /mnt/pbkfs-main --counters-resetCleanup diff directory:
pbkfs cleanup --diff-dir /var/lib/pbkfs/diff-main # safe cleanup
pbkfs cleanup --diff-dir /var/lib/pbkfs/diff-main --force # force wipe even if the diff looks in-use (dangerous)mount:- Required in all cases:
-B/--pbk-store,-D/--mnt-path,-d/--diff-dir. - Required for a fresh diff dir:
-I/--instance,-i/--backup-id. - Mode:
--console(foreground) vs default background; in background you can add--waitor--timeout <sec>. - Durability/perf:
--perf-unsafe(skips fsync; leaves.pbkfs-dirtyuntil unmount),--no-wal(WAL writes are virtual; diff dir becomes non-reusable). - Logging (background):
--log-file,--log-format text|json,--log-sink file|journald,--debug. - Files created under the mount root (stored in diff layer and visible via FUSE):
.pbkfs/worker.pid,.pbkfs/stat(and.pbkfs/pbkfs.logby default in background mode with--log-sink file).
- Required in all cases:
unmount:-D/--mnt-pathis required;-d/--diff-diris a hint for broken mount endpoints;--forcedoes SIGKILL + lazy detach if needed.cleanup: wipes diff contents and clears lock/binding metadata; refuses to clean an active diff unless--forceis set.stat: signals the worker (SIGUSR1/SIGUSR2) and prints the refreshed.pbkfs/stat;--format text|json,--counters-reset.
- Console mode logs to stderr via
tracing; setRUST_LOG=debugto increase verbosity (or usepbkfs mount --debug). - Background mode logs to a file by default (
.pbkfs/pbkfs.logunder the mount root) unless--log-sink journaldis selected. - Exit codes:
0on success; non-zero withpbkfs error: ...on stderr for failures.
- Architecture:
ARCHITECTURE.md