feat: custom include patterns (#104)

* feat: add custom include patterns

* feat: add exclude-if-present option
This commit is contained in:
Nico
2025-12-04 18:44:34 +01:00
committed by Nicolas Meienberger
parent 2c11b7c7de
commit 6b6338291b
11 changed files with 963 additions and 11 deletions

View File

@@ -24,6 +24,7 @@ const backupScheduleSchema = type({
cronExpression: "string",
retentionPolicy: retentionPolicySchema.or("null"),
excludePatterns: "string[] | null",
excludeIfPresent: "string[] | null",
includePatterns: "string[] | null",
lastBackupAt: "number | null",
lastBackupStatus: "'success' | 'error' | 'in_progress' | 'warning' | null",
@@ -128,6 +129,7 @@ export const createBackupScheduleBody = type({
cronExpression: "string",
retentionPolicy: retentionPolicySchema.optional(),
excludePatterns: "string[]?",
excludeIfPresent: "string[]?",
includePatterns: "string[]?",
tags: "string[]?",
});
@@ -164,6 +166,7 @@ export const updateBackupScheduleBody = type({
cronExpression: "string",
retentionPolicy: retentionPolicySchema.optional(),
excludePatterns: "string[]?",
excludeIfPresent: "string[]?",
includePatterns: "string[]?",
tags: "string[]?",
});

View File

@@ -99,6 +99,7 @@ const createSchedule = async (data: CreateBackupScheduleBody) => {
cronExpression: data.cronExpression,
retentionPolicy: data.retentionPolicy ?? null,
excludePatterns: data.excludePatterns ?? [],
excludeIfPresent: data.excludeIfPresent ?? [],
includePatterns: data.includePatterns ?? [],
nextBackupAt: nextBackupAt,
})
@@ -246,6 +247,7 @@ const executeBackup = async (scheduleId: number, manual = false) => {
const backupOptions: {
exclude?: string[];
excludeIfPresent?: string[];
include?: string[];
tags?: string[];
signal?: AbortSignal;
@@ -258,6 +260,10 @@ const executeBackup = async (scheduleId: number, manual = false) => {
backupOptions.exclude = schedule.excludePatterns;
}
if (schedule.excludeIfPresent && schedule.excludeIfPresent.length > 0) {
backupOptions.excludeIfPresent = schedule.excludeIfPresent;
}
if (schedule.includePatterns && schedule.includePatterns.length > 0) {
backupOptions.include = schedule.includePatterns;
}