faster incremental backups when multiple stacks share one repository
This commit is contained in:
2 files changed
+17
-2
No files matched your search
@@ -114,7 +114,12 @@ export function buildBackupArgs(input: {
|
||||
swapArtifacts: readonly string[];
|
||||
}): string[] {
|
||||
const paths = input.hasVolumes ? ['/volumes/', '/metadata/'] : ['/metadata/'];
|
||||
const args = ['backup', '--json', '--retry-lock', '5m', '--host', input.host, ...paths];
|
||||
// Every stack backs up from the SAME host + paths (/volumes/, /metadata/), so restic's
|
||||
// default parent selection (host,paths) picks the newest snapshot of ANY stack in the
|
||||
// repo as the parent - making a stack look entirely new whenever another stack was
|
||||
// backed up in between, forcing a full re-hash of its source (#1494). Group by the
|
||||
// dockhand tags too so a stack's parent is its OWN previous snapshot.
|
||||
const args = ['backup', '--json', '--retry-lock', '5m', '--group-by', 'host,paths,tags', '--host', input.host, ...paths];
|
||||
for (const t of input.tags) args.push('--tag', t);
|
||||
for (const a of input.swapArtifacts) args.push('--exclude', a);
|
||||
for (const p of input.excludePatterns ?? []) if (p.trim()) args.push('--exclude', p.trim());
|
||||
|
||||
@@ -12,10 +12,20 @@ describe('buildBackupArgs', () => {
|
||||
|
||||
it('builds the core backup argv over /volumes and /metadata', () => {
|
||||
const a = buildBackupArgs(base);
|
||||
expect(a.slice(0, 6)).toEqual(['backup', '--json', '--retry-lock', '5m', '--host', 'dockhand.local']);
|
||||
expect(a.slice(0, 4)).toEqual(['backup', '--json', '--retry-lock', '5m']);
|
||||
const hostIdx = a.indexOf('--host');
|
||||
expect(a[hostIdx + 1]).toBe('dockhand.local');
|
||||
expect(a).toContain('/volumes/');
|
||||
expect(a).toContain('/metadata/');
|
||||
});
|
||||
it('groups parent selection by the dockhand tags so a stack parents its own snapshot (#1494)', () => {
|
||||
// Without this, every stack shares host+paths (/volumes/, /metadata/), so restic picks
|
||||
// the newest snapshot of ANY stack as the parent and re-hashes the whole source.
|
||||
const a = buildBackupArgs(base);
|
||||
const i = a.indexOf('--group-by');
|
||||
expect(i).toBeGreaterThanOrEqual(0);
|
||||
expect(a[i + 1]).toBe('host,paths,tags');
|
||||
});
|
||||
it('backs up ONLY /metadata when the target has no volumes (config-only snapshot)', () => {
|
||||
const a = buildBackupArgs({ ...base, hasVolumes: false });
|
||||
expect(a).toContain('/metadata/');
|
||||
|
||||
Reference in new issue
Block a user