diegosouzapw/OmniRoute · error

[Migration] Failed to prune old backups: ${message}

Error message

[Migration] Failed to prune old backups: ${message}

What it means

Error "[Migration] Failed to prune old backups: ${message}" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/db/migrationRunner.ts:884

function pruneMigrationBackups(db: SqliteAdapter, backupDir: string): void {
  try {
    const maxFiles = process.env.DB_BACKUP_MAX_FILES
      ? parsePositiveInt(process.env.DB_BACKUP_MAX_FILES, MAX_DB_BACKUPS)
      : (readStoredBackupSetting(db, "maxFiles", 1) ?? MAX_DB_BACKUPS);
    const retentionDays = process.env.DB_BACKUP_RETENTION_DAYS
      ? parseNonNegativeInt(process.env.DB_BACKUP_RETENTION_DAYS, DEFAULT_DB_BACKUP_RETENTION_DAYS)
      : (readStoredBackupSetting(db, "retentionDays", 0) ?? DEFAULT_DB_BACKUP_RETENTION_DAYS);

    const result = pruneBackupDirectory({ backupDir, maxFiles, retentionDays });
    if (result.deletedFiles > 0) {
      console.log(
        `[Migration] Pruned ${result.deletedFiles} old backup file(s) ` +
          `(${result.keptBackupFamilies} kept, maxFiles=${maxFiles}, retentionDays=${retentionDays}).`
      );
    }
  } catch (err: unknown) {
    const message = err instanceof Error ? err.message : String(err);
    console.warn(`[Migration] Failed to prune old backups: ${message}`);
  }
}

/**
 * Create a pre-migration backup of the SQLite database using VACUUM INTO.
 * Returns the backup path on success, null on failure.
 */
function createPreMigrationBackup(db: SqliteAdapter): string | null {
  try {
    const sqliteFile = db.name;
    if (!sqliteFile || sqliteFile === ":memory:") return null;

    const backupDir = path.join(path.dirname(sqliteFile), "db_backups");
    if (!fs.existsSync(backupDir)) {
      fs.mkdirSync(backupDir, { recursive: true });
    }

    const timestamp = new Date().toISOString().replace(/[:.]/g, "-");

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/db/migrationRunner.ts:884 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/e7064faacf90e018. Report an issue: GitHub.