import type { CronJobDefinition } from "@rebasepro/types"; import type { StorageController } from "@rebasepro/server"; import { BackupDestination } from "./pg-tools"; export interface BackupCronConfig { /** Cron expression, e.g. `"0 3 * * *"` for 03:00 daily. */ schedule: string; /** Postgres connection string. Defaults to `DATABASE_URL`. */ connectionString: string; /** Where backups are written: a local path or an `s3://` / `gs://` URL. */ destination: BackupDestination; /** * Storage controller used for `s3`/`gcs` destinations. Reuse the one the * backend already configured (S3/GCS/Local StorageController). Not needed * for local destinations. */ storage?: StorageController; /** Delete backups older than this many days. `0` disables pruning. */ retentionDays?: number; /** Always keep at least this many recent backups regardless of age. */ keepMinimum?: number; /** Schemas to exclude from the dump (defaults to Atlas revision schema). */ excludeSchemas?: string[]; /** Cron job display name. */ name?: string; /** Whether the job is enabled. */ enabled?: boolean; } export interface EnvResolution { /** Resolved config, present when a schedule is configured. */ config?: Omit; /** True when `BACKUP_SCHEDULE` is unset — the cron should be a no-op. */ disabled?: boolean; /** Human-readable reason the config could not be built. */ error?: string; } /** * Build backup-cron config purely from environment variables. * Recognised keys: * - `BACKUP_SCHEDULE` cron expression (required to enable) * - `BACKUP_DESTINATION` local path or `s3://` / `gs://` URL (required) * - `BACKUP_RETENTION_DAYS` integer days (optional) * - `BACKUP_KEEP_MINIMUM` integer count (optional) * - `DATABASE_URL` connection string * * Pure and side-effect free so it can be unit-tested without a database. */ export declare function backupCronConfigFromEnv(env: Record): EnvResolution; /** * Create a {@link CronJobDefinition} that dumps the database, uploads the * result to the configured destination, and prunes old backups. Object * destinations require {@link BackupCronConfig.storage}. */ export declare function createBackupCron(config: BackupCronConfig): CronJobDefinition;