mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: custom include patterns (#104)
* feat: add custom include patterns * feat: add exclude-if-present option
This commit is contained in:
committed by
Nicolas Meienberger
parent
2c11b7c7de
commit
6b6338291b
@@ -86,6 +86,7 @@ export const backupSchedulesTable = sqliteTable("backup_schedules_table", {
|
||||
keepWithinDuration?: string;
|
||||
}>(),
|
||||
excludePatterns: text("exclude_patterns", { mode: "json" }).$type<string[]>().default([]),
|
||||
excludeIfPresent: text("exclude_if_present", { mode: "json" }).$type<string[]>().default([]),
|
||||
includePatterns: text("include_patterns", { mode: "json" }).$type<string[]>().default([]),
|
||||
lastBackupAt: int("last_backup_at", { mode: "number" }),
|
||||
lastBackupStatus: text("last_backup_status").$type<"success" | "error" | "in_progress" | "warning">(),
|
||||
|
||||
@@ -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[]?",
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -235,6 +235,7 @@ const backup = async (
|
||||
source: string,
|
||||
options?: {
|
||||
exclude?: string[];
|
||||
excludeIfPresent?: string[];
|
||||
include?: string[];
|
||||
tags?: string[];
|
||||
compressionMode?: CompressionMode;
|
||||
@@ -280,6 +281,12 @@ const backup = async (
|
||||
}
|
||||
}
|
||||
|
||||
if (options?.excludeIfPresent && options.excludeIfPresent.length > 0) {
|
||||
for (const filename of options.excludeIfPresent) {
|
||||
args.push("--exclude-if-present", filename);
|
||||
}
|
||||
}
|
||||
|
||||
addCommonArgs(args, env);
|
||||
|
||||
const logData = throttle((data: string) => {
|
||||
|
||||
Reference in New Issue
Block a user