mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: limit upload speed during backups
This commit is contained in:
@@ -83,6 +83,7 @@ export const backupSchedulesTable = sqliteTable("backup_schedules_table", {
|
||||
}>(),
|
||||
excludePatterns: text("exclude_patterns", { mode: "json" }).$type<string[]>().default([]),
|
||||
includePatterns: text("include_patterns", { mode: "json" }).$type<string[]>().default([]),
|
||||
limitUploadKbps: int("limit_upload_kbps", { mode: "number" }),
|
||||
lastBackupAt: int("last_backup_at", { mode: "number" }),
|
||||
lastBackupStatus: text("last_backup_status").$type<"success" | "error" | "in_progress">(),
|
||||
lastBackupError: text("last_backup_error"),
|
||||
|
||||
@@ -24,6 +24,7 @@ const backupScheduleSchema = type({
|
||||
retentionPolicy: retentionPolicySchema.or("null"),
|
||||
excludePatterns: "string[] | null",
|
||||
includePatterns: "string[] | null",
|
||||
limitUploadKbps: "number | null",
|
||||
lastBackupAt: "number | null",
|
||||
lastBackupStatus: "'success' | 'error' | 'in_progress' | null",
|
||||
lastBackupError: "string | null",
|
||||
@@ -114,6 +115,7 @@ export const createBackupScheduleBody = type({
|
||||
retentionPolicy: retentionPolicySchema.optional(),
|
||||
excludePatterns: "string[]?",
|
||||
includePatterns: "string[]?",
|
||||
limitUploadKbps: "number?",
|
||||
tags: "string[]?",
|
||||
});
|
||||
|
||||
@@ -149,6 +151,7 @@ export const updateBackupScheduleBody = type({
|
||||
retentionPolicy: retentionPolicySchema.optional(),
|
||||
excludePatterns: "string[]?",
|
||||
includePatterns: "string[]?",
|
||||
limitUploadKbps: "number?",
|
||||
tags: "string[]?",
|
||||
});
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ const createSchedule = async (data: CreateBackupScheduleBody) => {
|
||||
retentionPolicy: data.retentionPolicy ?? null,
|
||||
excludePatterns: data.excludePatterns ?? [],
|
||||
includePatterns: data.includePatterns ?? [],
|
||||
limitUploadKbps: data.limitUploadKbps ?? null,
|
||||
nextBackupAt: nextBackupAt,
|
||||
})
|
||||
.returning();
|
||||
@@ -212,9 +213,11 @@ const executeBackup = async (scheduleId: number, manual = false) => {
|
||||
exclude?: string[];
|
||||
include?: string[];
|
||||
tags?: string[];
|
||||
limitUploadKbps?: number | null;
|
||||
signal?: AbortSignal;
|
||||
} = {
|
||||
tags: [schedule.id.toString()],
|
||||
limitUploadKbps: schedule.limitUploadKbps,
|
||||
signal: abortController.signal,
|
||||
};
|
||||
|
||||
|
||||
@@ -234,6 +234,7 @@ const backup = async (
|
||||
exclude?: string[];
|
||||
include?: string[];
|
||||
tags?: string[];
|
||||
limitUploadKbps?: number | null;
|
||||
signal?: AbortSignal;
|
||||
onProgress?: (progress: BackupProgress) => void;
|
||||
},
|
||||
@@ -243,6 +244,10 @@ const backup = async (
|
||||
|
||||
const args: string[] = ["--repo", repoUrl, "backup", "--one-file-system"];
|
||||
|
||||
if (options?.limitUploadKbps) {
|
||||
args.push("--limit-upload", String(options.limitUploadKbps));
|
||||
}
|
||||
|
||||
if (options?.tags && options.tags.length > 0) {
|
||||
for (const tag of options.tags) {
|
||||
args.push("--tag", tag);
|
||||
|
||||
Reference in New Issue
Block a user