Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: restore individually selected files with rsync 3

[._.]/ Adam Eivy0f94da01cdd7
diff --git a/server/services/backup.js b/server/services/backup.js
index d8b10d30da..f795318454 100644
--- a/server/services/backup.js
+++ b/server/services/backup.js
@@ -1555,6 +1555,8 @@ export async function restoreSnapshot(destPath, snapshotId, { dryRun = true, sub
// `data/brain/youtube/**` over live files the user never selected. The
// integrity preflight above scopes itself to `data/<filter>/**` only, so an
// unanchored transfer overwrites bytes it never verified.
+ // Exact files need their own rule: rsync 3 excludes a file from the directory-only /*** pattern.
+ flags.push(`--include=/${subdirFilter}`);
flags.push(`--include=/${subdirFilter}/***`);
flags.push('--include=*/');
flags.push('--exclude=*');
diff --git a/server/services/backup.test.js b/server/services/backup.test.js
index 9c4dfa5282..de823899fa 100644
--- a/server/services/backup.test.js
+++ b/server/services/backup.test.js
@@ -2335,6 +2335,15 @@ describe('restoreSnapshot manifest verification', () => {
subdirFilter: 'brain',
});
expect(equalPreview.changedFiles.filter(line => line.includes(relativePath))).toEqual([]);
+
+ // A selected file needs an exact include rule on rsync 3.x; the
+ // directory-only /file/*** pattern silently skips it there.
+ await realFs.writeFile(livePath, liveContent);
+ const filePreview = await restoreSnapshot(tmpRoot, 'snap-1', { dryRun: true, subdirFilter: relativePath });
+ expect(filePreview.changedFiles.some(line => line.includes(relativePath))).toBe(true);
+ expect(await realFs.readFile(livePath, 'utf8')).toBe(liveContent);
+ await restoreSnapshot(tmpRoot, 'snap-1', { dryRun: false, subdirFilter: relativePath });
+ expect(await realFs.readFile(livePath, 'utf8')).toBe(snapshotContent);
} finally {
if (previousRsync === undefined) delete process.env.PORTOS_RSYNC;
else process.env.PORTOS_RSYNC = previousRsync;
@@ -3068,6 +3077,7 @@ describe('restoreSnapshot snapshotId, filter flags, and settings re-sync', () =>
// Leading `/` is load-bearing: rsync matches an unanchored pattern
// against the end of every path, so `brain/***` would also restore
// `data/<anything>/brain/**` — outside the scope the preflight verified.
+ '--include=/brain',
'--include=/brain/***',
'--include=*/',
'--exclude=*',