fix: restic glob pattern in include
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
This commit is contained in:
parent
b1a0cdb195
commit
853bec1ec4
2 changed files with 14 additions and 5 deletions
|
|
@ -46,7 +46,12 @@ describe("executeBackup - include / exclude patterns", () => {
|
|||
expect.anything(),
|
||||
volumePath,
|
||||
expect.objectContaining({
|
||||
include: ["*.zip", path.join(volumePath, "Photos"), `!${path.join(volumePath, "Temp")}`, "!*.log"],
|
||||
include: [
|
||||
path.join(volumePath, "*.zip"),
|
||||
path.join(volumePath, "Photos"),
|
||||
`!${path.join(volumePath, "Temp")}`,
|
||||
`!${path.join(volumePath, "*.log")}`,
|
||||
],
|
||||
exclude: [".DS_Store", path.join(volumePath, "Config"), `!${path.join(volumePath, "Important")}`, "!*.tmp"],
|
||||
excludeIfPresent: [".nobackup"],
|
||||
}),
|
||||
|
|
@ -109,7 +114,7 @@ describe("executeBackup - include / exclude patterns", () => {
|
|||
expect.anything(),
|
||||
volumePath,
|
||||
expect.objectContaining({
|
||||
include: [relativeInclude, path.join(volumePath, "anchored/include")],
|
||||
include: [path.join(volumePath, relativeInclude), path.join(volumePath, "anchored/include")],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,12 +19,14 @@ export const calculateNextRun = (cronExpression: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const processPattern = (pattern: string, volumePath: string) => {
|
||||
export const processPattern = (pattern: string, volumePath: string, relative = false) => {
|
||||
const isNegated = pattern.startsWith("!");
|
||||
const p = isNegated ? pattern.slice(1) : pattern;
|
||||
|
||||
if (!p.startsWith("/")) {
|
||||
return pattern;
|
||||
if (!relative) return pattern;
|
||||
const processed = path.join(volumePath, p);
|
||||
return isNegated ? `!${processed}` : processed;
|
||||
}
|
||||
|
||||
const processed = path.join(volumePath, p.slice(1));
|
||||
|
|
@ -37,5 +39,7 @@ export const createBackupOptions = (schedule: BackupSchedule, volumePath: string
|
|||
signal,
|
||||
exclude: schedule.excludePatterns ? schedule.excludePatterns.map((p) => processPattern(p, volumePath)) : undefined,
|
||||
excludeIfPresent: schedule.excludeIfPresent ?? undefined,
|
||||
include: schedule.includePatterns ? schedule.includePatterns.map((p) => processPattern(p, volumePath)) : undefined,
|
||||
include: schedule.includePatterns
|
||||
? schedule.includePatterns.map((p) => processPattern(p, volumePath, true))
|
||||
: undefined,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue