mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-21 07:22:47 -04:00
fix: restic glob pattern in include
This commit is contained in:
@@ -75,7 +75,7 @@ export const PathsSection = ({
|
||||
<FormControl>
|
||||
<Textarea
|
||||
{...field}
|
||||
placeholder="/data/** /config/*.json *.db"
|
||||
placeholder="/data/** /config/*.json *.db **/*.log"
|
||||
className="font-mono text-sm min-h-25"
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user