Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a332fa4fa |
3 changed files with 15 additions and 6 deletions
|
|
@ -75,7 +75,7 @@ export const PathsSection = ({
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
{...field}
|
{...field}
|
||||||
placeholder="/data/** /config/*.json *.db"
|
placeholder="/data/** /config/*.json *.db **/*.log"
|
||||||
className="font-mono text-sm min-h-25"
|
className="font-mono text-sm min-h-25"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,12 @@ describe("executeBackup - include / exclude patterns", () => {
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
volumePath,
|
volumePath,
|
||||||
expect.objectContaining({
|
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"],
|
exclude: [".DS_Store", path.join(volumePath, "Config"), `!${path.join(volumePath, "Important")}`, "!*.tmp"],
|
||||||
excludeIfPresent: [".nobackup"],
|
excludeIfPresent: [".nobackup"],
|
||||||
}),
|
}),
|
||||||
|
|
@ -109,7 +114,7 @@ describe("executeBackup - include / exclude patterns", () => {
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
volumePath,
|
volumePath,
|
||||||
expect.objectContaining({
|
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 isNegated = pattern.startsWith("!");
|
||||||
const p = isNegated ? pattern.slice(1) : pattern;
|
const p = isNegated ? pattern.slice(1) : pattern;
|
||||||
|
|
||||||
if (!p.startsWith("/")) {
|
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));
|
const processed = path.join(volumePath, p.slice(1));
|
||||||
|
|
@ -37,5 +39,7 @@ export const createBackupOptions = (schedule: BackupSchedule, volumePath: string
|
||||||
signal,
|
signal,
|
||||||
exclude: schedule.excludePatterns ? schedule.excludePatterns.map((p) => processPattern(p, volumePath)) : undefined,
|
exclude: schedule.excludePatterns ? schedule.excludePatterns.map((p) => processPattern(p, volumePath)) : undefined,
|
||||||
excludeIfPresent: schedule.excludeIfPresent ?? 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