Files
tessera/crates/tessera-core/src/job.rs
Adnan Zahir 6320b6f244 feat: add managed database capture and operator restore
PostgreSQL and MySQL backups run through paired outposts, with operator sign-in, off-site copies, and legacy import. Retention stays on each orbit, so the unused retention console is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 23:26:49 +07:00

90 lines
2.1 KiB
Rust

use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum CaptureFormat {
PostgresCustom,
PostgresSql,
MysqlSql,
Filesystem,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct CaptureProfile {
pub application_id: Uuid,
pub orbit_id: Uuid,
pub outpost_id: Uuid,
pub format: CaptureFormat,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub schedule: Option<CaptureSchedule>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub retention: Option<crate::decay::CaptureRetention>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct CaptureSchedule {
pub hour: u8,
#[serde(default)]
pub minute: u8,
pub timezone: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CaptureJob {
pub id: Uuid,
pub profile: CaptureProfile,
pub actor: String,
pub status: String,
pub phase: String,
pub created_at: i64,
pub updated_at: i64,
pub snapshot_id: Option<Uuid>,
pub offsite_status: Option<String>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct CaptureEvent {
pub at: i64,
pub phase: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct CaptureLease {
pub job_id: Uuid,
pub profile: CaptureProfile,
pub lease_id: Uuid,
#[serde(default)]
pub restic: bool,
}
pub const CAPTURE_LEASE_SECONDS: i64 = 90;
pub const CAPTURE_HEARTBEAT_SECONDS: u64 = 20;
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum CaptureProgress {
Heartbeat,
Dumping,
Uploading,
DumpFailed,
UploadFailed,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct CaptureReport {
pub lease_id: Uuid,
pub progress: CaptureProgress,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ResticCaptureCommit {
pub lease_id: Uuid,
pub snapshot_id: String,
pub identity: Option<crate::restore::DatabaseIdentity>,
pub sha256: Option<String>,
}