refactor: run forget commands in the background
This commit is contained in:
parent
33e6f3773b
commit
7ff38f0128
1 changed files with 2 additions and 7 deletions
|
|
@ -263,12 +263,7 @@ const executeBackup = async (scheduleId: number, manual = false) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schedule.retentionPolicy) {
|
if (schedule.retentionPolicy) {
|
||||||
const releaseForgetLock = await repoMutex.acquireExclusive(repository.id, `forget:${volume.name}`);
|
void runForget(schedule.id);
|
||||||
try {
|
|
||||||
await restic.forget(repository.config, schedule.retentionPolicy, { tag: schedule.id.toString() });
|
|
||||||
} finally {
|
|
||||||
releaseForgetLock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextBackupAt = calculateNextRun(schedule.cronExpression);
|
const nextBackupAt = calculateNextRun(schedule.cronExpression);
|
||||||
|
|
@ -415,7 +410,7 @@ const runForget = async (scheduleId: number) => {
|
||||||
throw new NotFoundError("Repository not found");
|
throw new NotFoundError("Repository not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Manually running retention policy (forget) for schedule ${scheduleId}`);
|
logger.info(`running retention policy (forget) for schedule ${scheduleId}`);
|
||||||
const releaseLock = await repoMutex.acquireExclusive(repository.id, `forget:manual:${scheduleId}`);
|
const releaseLock = await repoMutex.acquireExclusive(repository.id, `forget:manual:${scheduleId}`);
|
||||||
try {
|
try {
|
||||||
await restic.forget(repository.config, schedule.retentionPolicy, { tag: schedule.id.toString() });
|
await restic.forget(repository.config, schedule.retentionPolicy, { tag: schedule.id.toString() });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue