Compare commits
2 commits
main
...
v0.19.2-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85f62d4996 | ||
|
|
bbefb8124e |
4 changed files with 31 additions and 11 deletions
|
|
@ -4,10 +4,6 @@ export const REPOSITORY_BASE = "/var/lib/zerobyte/repositories";
|
||||||
export const DATABASE_URL = "/var/lib/zerobyte/data/ironmount.db";
|
export const DATABASE_URL = "/var/lib/zerobyte/data/ironmount.db";
|
||||||
export const RESTIC_PASS_FILE = "/var/lib/zerobyte/data/restic.pass";
|
export const RESTIC_PASS_FILE = "/var/lib/zerobyte/data/restic.pass";
|
||||||
|
|
||||||
export const DEFAULT_EXCLUDES = [
|
export const DEFAULT_EXCLUDES = [DATABASE_URL, RESTIC_PASS_FILE, REPOSITORY_BASE];
|
||||||
DATABASE_URL,
|
|
||||||
RESTIC_PASS_FILE,
|
|
||||||
"/var/lib/zerobyte/repositories/**", // To avoid circular backups
|
|
||||||
];
|
|
||||||
|
|
||||||
export const REQUIRED_MIGRATIONS = ["v0.14.0"];
|
export const REQUIRED_MIGRATIONS = ["v0.14.0"];
|
||||||
|
|
|
||||||
28
app/server/jobs/auto-remount.ts
Normal file
28
app/server/jobs/auto-remount.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { Job } from "../core/scheduler";
|
||||||
|
import { volumeService } from "../modules/volumes/volume.service";
|
||||||
|
import { logger } from "../utils/logger";
|
||||||
|
import { db } from "../db/db";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { volumesTable } from "../db/schema";
|
||||||
|
|
||||||
|
export class VolumeAutoRemountJob extends Job {
|
||||||
|
async run() {
|
||||||
|
logger.debug("Running auto-remount for all errored volumes...");
|
||||||
|
|
||||||
|
const volumes = await db.query.volumesTable.findMany({
|
||||||
|
where: eq(volumesTable.status, "error"),
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const volume of volumes) {
|
||||||
|
if (volume.autoRemount) {
|
||||||
|
try {
|
||||||
|
await volumeService.mountVolume(volume.name);
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`Failed to auto-remount volume ${volume.name}:`, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { done: true, timestamp: new Date() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,6 @@ import { logger } from "../utils/logger";
|
||||||
import { db } from "../db/db";
|
import { db } from "../db/db";
|
||||||
import { eq, or } from "drizzle-orm";
|
import { eq, or } from "drizzle-orm";
|
||||||
import { repositoriesTable } from "../db/schema";
|
import { repositoriesTable } from "../db/schema";
|
||||||
import { repoMutex } from "../core/repository-mutex";
|
|
||||||
|
|
||||||
export class RepositoryHealthCheckJob extends Job {
|
export class RepositoryHealthCheckJob extends Job {
|
||||||
async run() {
|
async run() {
|
||||||
|
|
@ -15,11 +14,6 @@ export class RepositoryHealthCheckJob extends Job {
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const repository of repositories) {
|
for (const repository of repositories) {
|
||||||
if (repoMutex.isLocked(repository.id)) {
|
|
||||||
logger.debug(`Skipping health check for repository ${repository.name}: currently locked`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await repositoriesService.checkHealth(repository.id);
|
await repositoriesService.checkHealth(repository.id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import { BackupExecutionJob } from "../../jobs/backup-execution";
|
||||||
import { CleanupSessionsJob } from "../../jobs/cleanup-sessions";
|
import { CleanupSessionsJob } from "../../jobs/cleanup-sessions";
|
||||||
import { repositoriesService } from "../repositories/repositories.service";
|
import { repositoriesService } from "../repositories/repositories.service";
|
||||||
import { notificationsService } from "../notifications/notifications.service";
|
import { notificationsService } from "../notifications/notifications.service";
|
||||||
|
import { VolumeAutoRemountJob } from "~/server/jobs/auto-remount";
|
||||||
|
|
||||||
const ensureLatestConfigurationSchema = async () => {
|
const ensureLatestConfigurationSchema = async () => {
|
||||||
const volumes = await db.query.volumesTable.findMany({});
|
const volumes = await db.query.volumesTable.findMany({});
|
||||||
|
|
@ -67,4 +68,5 @@ export const startup = async () => {
|
||||||
Scheduler.build(RepositoryHealthCheckJob).schedule("50 12 * * *");
|
Scheduler.build(RepositoryHealthCheckJob).schedule("50 12 * * *");
|
||||||
Scheduler.build(BackupExecutionJob).schedule("* * * * *");
|
Scheduler.build(BackupExecutionJob).schedule("* * * * *");
|
||||||
Scheduler.build(CleanupSessionsJob).schedule("0 0 * * *");
|
Scheduler.build(CleanupSessionsJob).schedule("0 0 * * *");
|
||||||
|
Scheduler.build(VolumeAutoRemountJob).schedule("*/5 * * * *");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue