Skip to content

Build your personal knowledge base with Trilium Notes

feat(standalone): disabled scheduled backups for now

Elian Doran959b4da95a38
diff --git a/apps/build-docs/src/build-docs.ts b/apps/build-docs/src/build-docs.ts
index f5c97fb36c..7e415e025e 100644
--- a/apps/build-docs/src/build-docs.ts
+++ b/apps/build-docs/src/build-docs.ts
@@ -21,6 +21,9 @@ class StubBackupService extends BackupService {
setOption: () => {}
});
}
+ scheduleBackups(): void {
+ // No scheduled backups in build-docs
+ }
async backupNow(_name: string): Promise<string> {
throw new Error("Backup not supported in build-docs");
}
diff --git a/apps/server/src/backup_provider.ts b/apps/server/src/backup_provider.ts
index 71f9221f6c..289d97b60c 100644
--- a/apps/server/src/backup_provider.ts
+++ b/apps/server/src/backup_provider.ts
@@ -28,7 +28,13 @@ export default class ServerBackupService extends BackupService {
});
}
- // regularBackup() inherited from BackupService - uses getContext().init()
+ override scheduleBackups(): void {
+ // Run regular backups every 4 hours
+ setInterval(() => this.regularBackup(), 4 * 60 * 60 * 1000);
+
+ // Kickoff first backup soon after startup
+ setTimeout(() => this.regularBackup(), 5 * 60 * 1000);
+ }
override async backupNow(name: string): Promise<string> {
// we don't want to back up DB in the middle of sync with potentially inconsistent DB state
diff --git a/apps/standalone/src/lightweight/backup_provider.ts b/apps/standalone/src/lightweight/backup_provider.ts
index 7677e88325..2ceaefdd9d 100644
--- a/apps/standalone/src/lightweight/backup_provider.ts
+++ b/apps/standalone/src/lightweight/backup_provider.ts
@@ -17,6 +17,10 @@ export default class StandaloneBackupService extends BackupService {
super(options);
}
+ override scheduleBackups(): void {
+ // No scheduled backups on standalone/mobile
+ }
+
private isOpfsAvailable(): boolean {
if (this.opfsAvailable === null) {
this.opfsAvailable = typeof navigator !== "undefined"
diff --git a/packages/trilium-core/src/services/backup.ts b/packages/trilium-core/src/services/backup.ts
index d1f8dea223..46a1182a19 100644
--- a/packages/trilium-core/src/services/backup.ts
+++ b/packages/trilium-core/src/services/backup.ts
@@ -36,6 +36,12 @@ export default abstract class BackupService {
});
}
+ /**
+ * Schedule automatic backups.
+ * Platform-specific: server uses timers, standalone/mobile is a no-op.
+ */
+ abstract scheduleBackups(): void;
+
/**
* Get list of existing backups.
*/
diff --git a/packages/trilium-core/src/services/sql_init.ts b/packages/trilium-core/src/services/sql_init.ts
index b360a02747..58d9505c97 100644
--- a/packages/trilium-core/src/services/sql_init.ts
+++ b/packages/trilium-core/src/services/sql_init.ts
@@ -107,11 +107,7 @@ function initializeDb() {
getContext().init(initDbConnection);
dbReady.then(() => {
- // Run regular backups every 4 hours
- setInterval(() => getBackup().regularBackup(), 4 * 60 * 60 * 1000);
-
- // Kickoff first backup soon after start up
- setTimeout(() => getBackup().regularBackup(), 5 * 60 * 1000);
+ getBackup().scheduleBackups();
// Optimize is usually inexpensive no-op, so running it semi-frequently is not a big deal
setTimeout(() => optimize(), 60 * 60 * 1000);