fix: preserve files of all sources in multi-source backup - #557
Closed
Lauri-Nomme wants to merge 1 commit into
Closed
fix: preserve files of all sources in multi-source backup#557Lauri-Nomme wants to merge 1 commit into
Lauri-Nomme wants to merge 1 commit into
Conversation
When backing up more than one source path in a single call, only the first source's files were archived (or rustic panicked with StripPrefixError). The archiver received only backup_paths[0] as its strip-prefix base, so files belonging to other sources could not be mapped into the snapshot tree and were silently dropped. Pass the full backup_paths slice to Archiver::archive and strip each entry against the backup root it belongs to. With --as-path and multiple sources, keep each source as its own subtree to avoid path collisions. Fixes rustic issue #1905. Co-authored-by: Lauri Nomme <lauri.nomme@gmail.com>
Author
|
Retracting per maintainer feedback: as-path+multi-source is already rejected in the rustic CLI, and the no-as-path path needs a cleaner verification. Will pursue root-cause analysis and reopen/replace with a validated fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Backing up more than one source path in a single call silently drops the second source's files — or panics with
StripPrefixError.Repro:
before this change:
Reported upstream: rustic-rs/rustic#1905
Root cause
Archiver::archivereceived onlybackup_paths[0]as the singlebackup_pathused forstrip_prefix(crates/core/src/commands/backup.rs). Theignore-based walker emits absolute paths per source root for every entry. With multiple sources, an entry from the second source (.../src2/file.txt) cannotstrip_prefix(backup_paths[0]), so:--as-pathset: theunwrap()panics,--as-path: the second source's file blobs never get archived while its directory tree is still written — a silent, successful-looking backup missing data.Fix
Pass the full
backup_pathsslice intoArchiver::archiveand strip each entry against the backup root it actually belongs to (falling back to the entry path unchanged if no root matches). When--as-pathis used with multiple sources, keep each source as its own subtree under the target to avoid collisions between sources that contain identically-named files.Tests
Two regression tests added in
crates/core/tests/integration/backup.rs:test_backup_multi_source_preserves_files_of_all_sources(with--as-path)test_backup_multi_source_preserves_files_without_as_path(default mode)Verified:
Notes
This changes the signature of
Archiver::archive(backup_path&Path→ backup_paths&[PathBuf]). It ispub, so downstream users calling it directly would need to update — but the normal entry points (repo.backup,repo.archive) are unchanged.