Documentation
¶
Overview ¶
Package platformbackup is the admin-only disaster-recovery feature for Miabi's own control plane. It reuses the per-workspace backup primitives but draws its database connection from control-plane config and runs on the manager node. Artifacts are GPG-encrypted with the backup passphrase, not the master key.
Index ¶
- Variables
- type AppLifecycle
- type AppStopper
- type DBBackupRunner
- type DBConn
- type DiscoveredArtifact
- type DiscoveredSet
- type Enqueuer
- type IdentitySource
- type ImageResolver
- type MountAppStopper
- type NodeDocker
- type PlatformVolume
- type RepoTenantSource
- func (s *RepoTenantSource) BackupTenantDatabase(ctx context.Context, td TenantDatabase, dest backup.Destination) (*models.Backup, error)
- func (s *RepoTenantSource) ListTenantDatabases() ([]TenantDatabase, error)
- func (s *RepoTenantSource) ListTenantVolumes() ([]TenantVolume, error)
- func (s *RepoTenantSource) RestoreTenantDatabase(ctx context.Context, td TenantDatabase, dest backup.Destination, ...) error
- type RestoreSelection
- type SaveInput
- type SelectiveRestoreReport
- type SelectiveRestoreResult
- type Service
- func (s *Service) Create(ctx context.Context, subject models.PlatformBackupSubject, ...) (*models.PlatformBackup, error)
- func (s *Service) CreateSet(ctx context.Context, trigger string) (*models.PlatformBackupSet, error)
- func (s *Service) Delete(ctx context.Context, b *models.PlatformBackup) error
- func (s *Service) DeleteSet(ctx context.Context, set *models.PlatformBackupSet) error
- func (s *Service) DiscoverSets(ctx context.Context) ([]DiscoveredSet, error)
- func (s *Service) DiscoverVolumes(ctx context.Context) ([]PlatformVolume, error)
- func (s *Service) Download(_ context.Context, _ *models.PlatformBackup) (io.ReadCloser, int64, string, error)
- func (s *Service) EnableTenantCapture(db *gorm.DB, runner DBBackupRunner)
- func (s *Service) Get(id uint) (*models.PlatformBackup, error)
- func (s *Service) GetSet(id uint) (*models.PlatformBackupSet, error)
- func (s *Service) GetSetByRef(ref string) (*models.PlatformBackupSet, error)
- func (s *Service) GetSettings() (*models.PlatformBackupSettings, error)
- func (s *Service) ImportSet(ctx context.Context, ref string) (*models.PlatformBackupSet, error)
- func (s *Service) LatestRestorableSet() (*models.PlatformBackupSet, error)
- func (s *Service) List() ([]models.PlatformBackup, error)
- func (s *Service) ListPaged(limit, offset int) ([]models.PlatformBackup, int64, error)
- func (s *Service) ListSets() ([]models.PlatformBackupSet, error)
- func (s *Service) ListSetsPaged(limit, offset int) ([]models.PlatformBackupSet, int64, error)
- func (s *Service) Prune(ctx context.Context, maxBackups, retentionDays int) (int, error)
- func (s *Service) PruneSets(ctx context.Context, maxSets, retentionDays int) (int, error)
- func (s *Service) Restore(ctx context.Context, b *models.PlatformBackup) error
- func (s *Service) RestoreSelected(ctx context.Context, set *models.PlatformBackupSet, sel RestoreSelection) (*SelectiveRestoreReport, error)
- func (s *Service) RestoreTenantData(ctx context.Context, set *models.PlatformBackupSet) (*TenantRestoreReport, error)
- func (s *Service) RetrySet(ctx context.Context, set *models.PlatformBackupSet) (*models.PlatformBackupSet, error)
- func (s *Service) RunBackup(ctx context.Context, backupID uint) error
- func (s *Service) RunScheduled(ctx context.Context) error
- func (s *Service) S3Configured() bool
- func (s *Service) SaveSettings(in SaveInput) (*models.PlatformBackupSettings, error)
- func (s *Service) SetAppStopper(a AppStopper)
- func (s *Service) SetEnqueuer(e Enqueuer)
- func (s *Service) SetEnv(cfg config.PlatformBackupConfig)
- func (s *Service) SetFingerprinter(fn func(label string) string)
- func (s *Service) SetIdentitySource(fn IdentitySource)
- func (s *Service) SetImageResolver(r ImageResolver)
- func (s *Service) SetInternalNetwork(name string)
- func (s *Service) SetKeyFingerprinter(fn func(key, label string) string)
- func (s *Service) SetLogStore(store *logstore.Store)
- func (s *Service) SetTenantSource(src TenantSource)
- func (s *Service) TenantCaptureAvailable() bool
- func (s *Service) VerifySet(ctx context.Context, set *models.PlatformBackupSet, passphrase string) (*VerifyReport, error)
- type TenantDatabase
- type TenantRestoreReport
- type TenantSource
- type TenantVolume
- type VerifyFinding
- type VerifyReport
Constants ¶
This section is empty.
Variables ¶
var ( // ErrS3NotConfigured is returned when an operation needs an S3 target that is // not set up (volume backups have no local destination, like volume-bkup). ErrS3NotConfigured = errors.New("platform backup requires an S3/MinIO target; configure one in Admin → Platform Backup or via MIABI_PLATFORM_BACKUP_S3_*") // ErrNoArtifact is returned when restoring/downloading a backup with no file. ErrNoArtifact = errors.New("platform backup has no artifact") // ErrDownloadRemote is returned by the download endpoint: artifacts live in // the operator's bucket, and Miabi does not proxy them back out. ErrDownloadRemote = errors.New("platform backup artifacts are stored in your S3 bucket; fetch them from there") // ErrUnknownSubject is returned for an unrecognized backup subject. ErrUnknownSubject = errors.New("unknown platform backup subject") // ErrVolumeExcluded is returned for a volume that must never appear in a // platform backup (backup volumes, tenant volumes, the registry's storage). ErrVolumeExcluded = errors.New("this volume cannot be included in a platform backup") // ErrNoPassphrase is returned when encryption is on but no passphrase is set. ErrNoPassphrase = errors.New("backup encryption is enabled but no backup passphrase is set") // ErrSetNeedsS3 is returned when a recovery point is requested without an S3 // target. A recovery point that lives only on the host it protects is not a // recovery point. ErrSetNeedsS3 = errors.New("a platform recovery point requires an S3 target: a backup stored only on the host you are recovering from is no disaster recovery at all") )
var ( // ErrNothingSelected is returned when a restore request selects no artifacts. ErrNothingSelected = errors.New("select at least one artifact to restore") // ErrNotRestorableHere is returned for an artifact the dashboard must not // restore into a live platform — see restorableFromDashboard. ErrNotRestorableHere = errors.New("this artifact cannot be restored from the dashboard") )
var ErrNothingToRetry = errors.New("this recovery point has no failed artifacts to retry")
ErrNothingToRetry is returned when a recovery point has no failed artifacts.
Functions ¶
This section is empty.
Types ¶
type AppLifecycle ¶ added in v1.8.0
type AppLifecycle interface {
Stop(ctx context.Context, app *models.Application) error
Start(ctx context.Context, app *models.Application) (*models.Deployment, error)
}
AppLifecycle is the slice of the application service needed to quiesce a volume: stop the containers using it, and start them again afterwards.
type AppStopper ¶ added in v1.8.0
type AppStopper interface {
// StopUsers stops every application using the volume and returns their ids,
// so the same set can be started again afterwards.
StopUsers(ctx context.Context, volumeName string) ([]uint, error)
StartApps(ctx context.Context, appIDs []uint) error
}
AppStopper stops and starts the applications attached to a volume, so an archive is not unpacked underneath a running container. Optional: without it a volume restore still runs, and the report says the app was left running.
type DBBackupRunner ¶ added in v1.8.0
type DBBackupRunner interface {
Run(ctx context.Context, inst *models.DatabaseInstance, db *models.Database, opts backup.RunOptions, dest backup.Destination) (*models.Backup, error)
Restore(ctx context.Context, inst *models.DatabaseInstance, db *models.Database, spec backup.RestoreSpec) error
}
DBBackupRunner is the slice of services/backup platform DR needs: dump and restore a managed database against a destination it chooses.
type DBConn ¶
DBConn carries the resolved control-plane Postgres connection parameters the platform DB backup runner feeds to pg-bkup.
type DiscoveredArtifact ¶ added in v1.8.0
type DiscoveredArtifact struct {
Subject string `json:"subject"`
Workspace string `json:"workspace,omitempty"`
Database string `json:"database,omitempty"`
Volume string `json:"volume,omitempty"`
Engine string `json:"engine,omitempty"`
File string `json:"file"`
Key string `json:"key"`
SizeBytes int64 `json:"size_bytes,omitempty"`
Encrypted bool `json:"encrypted"`
// Restorable reports whether THIS platform can restore this artifact from the dashboard, and Reason says
// why not. The control-plane dump is never restorable this way: it overwrites the database the running
// platform is using, which is a maintenance-mode operation and not a checkbox.
Restorable bool `json:"restorable"`
Reason string `json:"reason,omitempty"`
// Present reports whether the object is actually in the bucket. A manifest
// records what happened when the backup ran; retention and lifecycle rules
// act on the bucket afterwards.
Present bool `json:"present"`
}
DiscoveredArtifact is one restorable file in a discovered recovery point.
type DiscoveredSet ¶ added in v1.8.0
type DiscoveredSet struct {
Ref string `json:"ref"`
InstallID string `json:"install_id,omitempty"`
MiabiVersion string `json:"miabi_version,omitempty"`
Encrypted bool `json:"encrypted"`
IdentitySealed bool `json:"identity_sealed"`
CreatedAt time.Time `json:"created_at"`
Artifacts []DiscoveredArtifact `json:"artifacts"`
// Known is true when this platform already has the recovery point in its own
// database; those can be verified and retried, not just restored from.
Known bool `json:"known"`
// SetID is the local row, when Known.
SetID uint `json:"set_id,omitempty"`
// Foreign marks a recovery point taken by a DIFFERENT install. Its tenant data restores here perfectly
// well — a database dump is data. Its control-plane dump would fill this platform with secrets encrypted
// under a key it does not have, which is what KEKMatches reports.
Foreign bool `json:"foreign"`
// KEKMatches reports whether the recovery point was taken under this
// platform's master key. False means anything control-plane from it is
// unusable here, whatever the artifact list says.
KEKMatches bool `json:"kek_matches"`
}
DiscoveredSet is a recovery point found in the bucket. The bucket is the authority, not this platform's database: after a control-plane restore the sets a platform knows about are whatever its dump contained, while everything taken since is still in object storage. Discovery makes those reachable again.
type Enqueuer ¶
Enqueuer schedules a platform backup to run in the background worker. Satisfied by worker.Producer. When unset, backups run synchronously (tests / no-redis).
type IdentitySource ¶ added in v1.8.0
IdentitySource supplies the platform identity sealed into each recovery point: the master encryption key, the JWT secret and the install's identity. Wired at the composition root, because those values come from process configuration and platform settings rather than from this service's own tables.
type ImageResolver ¶
ImageResolver resolves a deployment-config catalog key to an image ref.
type MountAppStopper ¶ added in v1.8.0
type MountAppStopper struct {
// contains filtered or unexported fields
}
MountAppStopper finds the applications mounting a volume and stops them around a restore. Mounts are a JSON column rather than a join table, so this scans applications instead of querying by volume — fine at the scale involved, and a restore is not a hot path.
func NewMountAppStopper ¶ added in v1.8.0
func NewMountAppStopper(apps *repositories.ApplicationRepository, lifecycle AppLifecycle) *MountAppStopper
NewMountAppStopper builds the app-quiesce hook for volume restores.
func (*MountAppStopper) StartApps ¶ added in v1.8.0
func (s *MountAppStopper) StartApps(ctx context.Context, appIDs []uint) error
StartApps starts the applications StopUsers stopped.
func (*MountAppStopper) StopUsers ¶ added in v1.8.0
StopUsers stops every running application mounting the volume and returns their ids. Only RUNNING apps are returned, so starting them again restores the state that was there before — an app the operator had deliberately stopped must not come back up because a volume it mounts was restored.
type NodeDocker ¶
NodeDocker resolves the Docker client for a node id (0 = local manager node).
type PlatformVolume ¶
PlatformVolume is a candidate platform/system volume the admin may include in backups. Role is the io.miabi.role label value when the volume is infra.
type RepoTenantSource ¶ added in v1.8.0
type RepoTenantSource struct {
// contains filtered or unexported fields
}
RepoTenantSource is the production TenantSource: it walks the workspace, database and volume repositories and delegates the actual dump to the existing backup service. It lives here so the traversal — which workspaces, databases and volumes count as tenant data — is stated once.
func NewRepoTenantSource ¶ added in v1.8.0
func NewRepoTenantSource( workspaces *repositories.WorkspaceRepository, databases *repositories.DatabaseRepository, volumes *repositories.VolumeRepository, runner DBBackupRunner, ) *RepoTenantSource
NewRepoTenantSource builds the repository-backed tenant source.
func (*RepoTenantSource) BackupTenantDatabase ¶ added in v1.8.0
func (s *RepoTenantSource) BackupTenantDatabase(ctx context.Context, td TenantDatabase, dest backup.Destination) (*models.Backup, error)
BackupTenantDatabase dumps one database to the platform's own destination.
func (*RepoTenantSource) ListTenantDatabases ¶ added in v1.8.0
func (s *RepoTenantSource) ListTenantDatabases() ([]TenantDatabase, error)
ListTenantDatabases returns every logical database on every managed instance. Redis is skipped: it is a cache in every Miabi topology, the backup tooling has no dump for it, and pretending to capture it would put a reassuring line in a recovery point that restores nothing.
func (*RepoTenantSource) ListTenantVolumes ¶ added in v1.8.0
func (s *RepoTenantSource) ListTenantVolumes() ([]TenantVolume, error)
ListTenantVolumes returns every workspace-owned volume.
func (*RepoTenantSource) RestoreTenantDatabase ¶ added in v1.8.0
func (s *RepoTenantSource) RestoreTenantDatabase(ctx context.Context, td TenantDatabase, dest backup.Destination, filename string) error
RestoreTenantDatabase loads a dump back into a live database instance. Force is set, so the database is dropped and recreated first: a DR restore lands in a database the platform just provisioned, and layering a dump over what a fresh instance seeded gives constraint violations that look like a corrupt backup.
type RestoreSelection ¶ added in v1.8.0
type RestoreSelection struct {
// ArtifactIDs are PlatformBackup rows of the set. Selecting by id rather than
// by name means the request refers to exactly what the operator was shown,
// not to whatever matches a name by the time the worker runs.
ArtifactIDs []uint
// Passphrase decrypts the artifacts. Empty uses the stored one, which is
// right for this platform's own recovery points and wrong for a foreign one.
Passphrase string
// StopApps stops the applications using a volume before overwriting it, and
// starts them afterwards. Restoring underneath a running app hands it files
// that change while it is reading them.
StopApps bool
}
RestoreSelection asks for specific artifacts of a recovery point to be restored into this live platform.
type SaveInput ¶
type SaveInput struct {
S3Enabled bool
S3Endpoint string
S3Bucket string
S3Region string
S3AccessKey string
S3SecretKey *string
S3UseSSL bool
S3ForcePathStyle bool
RootPath string
DatabaseBackupPath string
VolumeBackupPath string
EncryptBackups bool
// BackupPassphrase is nil/empty to keep the stored passphrase unchanged.
BackupPassphrase *string
IncludeIdentity bool
IncludeTenantData bool
ScheduleEnabled bool
ScheduleCron string
MaxBackups int
RetentionDays int
Volumes []string
}
SaveInput carries the desired platform backup settings. S3SecretKey is nil/empty to keep the stored secret unchanged (so the UI never round-trips it).
type SelectiveRestoreReport ¶ added in v1.8.0
type SelectiveRestoreReport struct {
Ref string `json:"ref"`
Requested int `json:"requested"`
Restored int `json:"restored"`
Results []SelectiveRestoreResult `json:"results"`
// StartedAt/FinishedAt bound the run; a selective restore of a large volume
// is minutes, not seconds.
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
}
SelectiveRestoreReport is what the operator gets back.
type SelectiveRestoreResult ¶ added in v1.8.0
type SelectiveRestoreResult struct {
ArtifactID uint `json:"artifact_id"`
Label string `json:"label"`
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
}
SelectiveRestoreResult is one artifact's outcome.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service backs up and restores the platform's own database and volumes.
func NewService ¶
func NewService(repo *repositories.PlatformBackupRepository, sets *repositories.PlatformBackupSetRepository, settings *repositories.PlatformBackupSettingsRepository, clients NodeDocker, db DBConn, network string) *Service
NewService builds the platform backup service. db is the control-plane DB connection; network is the proxy network the DB-backup container joins so it can reach a Compose/managed Postgres by service name.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, subject models.PlatformBackupSubject, volumeName, trigger string) (*models.PlatformBackup, error)
Create records a pending platform backup and enqueues it for the background worker, returning the pending record immediately. With no enqueuer wired it runs synchronously. Volume backups require an S3 target, since volume-bkup has no local destination.
func (*Service) CreateSet ¶ added in v1.8.0
CreateSet opens a recovery point and enqueues its items: the sealed identity envelope, the control-plane database dump, and one archive per selected platform volume. A recovery point requires an S3 target — one stored on the host it protects cannot be read once that host is gone.
func (*Service) Delete ¶
Delete removes a backup record and its artifact from the bucket. With S3 as the only destination, a record removed without its artifact leaves a file nobody knows about, paying storage forever. A failed object delete is logged but does not block removing the record.
func (*Service) DeleteSet ¶ added in v1.8.0
DeleteSet removes a recovery point: its identity envelope from object storage, each item record (and any local artifact), then the set itself.
func (*Service) DiscoverSets ¶ added in v1.8.0
func (s *Service) DiscoverSets(ctx context.Context) ([]DiscoveredSet, error)
DiscoverSets lists the recovery points in the configured bucket. It reads the cleartext info files — no passphrase needed to see what exists, which is the point of keeping them readable. Artifact presence is checked so the list distinguishes "recorded" from "actually there".
func (*Service) DiscoverVolumes ¶
func (s *Service) DiscoverVolumes(ctx context.Context) ([]PlatformVolume, error)
DiscoverVolumes lists candidate platform/system volumes on the manager node. Three classes are excluded: backup volumes (which must never back themselves up), per-workspace volumes (tenant data with their own path), and the registry data volume (a live-blob tar restores cleanly and then fails on pull).
func (*Service) Download ¶
func (s *Service) Download(_ context.Context, _ *models.PlatformBackup) (io.ReadCloser, int64, string, error)
Download is not supported: artifacts live in the operator's own bucket, and streaming gigabytes of encrypted dump back out through the control plane would add nothing they cannot do with their S3 client.
func (*Service) EnableTenantCapture ¶ added in v1.8.0
func (s *Service) EnableTenantCapture(db *gorm.DB, runner DBBackupRunner)
EnableTenantCapture wires tenant capture from a database handle: one call instead of four constructor arguments, because it must be done identically in every composition root. A root that forgets it does not fail at startup — it fails at backup time, with "no tenant source is wired".
func (*Service) Get ¶
func (s *Service) Get(id uint) (*models.PlatformBackup, error)
Get returns a single platform backup.
func (*Service) GetSet ¶ added in v1.8.0
func (s *Service) GetSet(id uint) (*models.PlatformBackupSet, error)
GetSet returns one recovery point with its items.
func (*Service) GetSetByRef ¶ added in v1.8.0
func (s *Service) GetSetByRef(ref string) (*models.PlatformBackupSet, error)
GetSetByRef resolves a recovery point by the ref an operator quotes.
func (*Service) GetSettings ¶
func (s *Service) GetSettings() (*models.PlatformBackupSettings, error)
GetSettings returns the platform backup settings, or an empty (unsaved) record when none exist yet. Secrets are never included; the *Set booleans report their presence so the UI can render "••••• (set)".
func (*Service) ImportSet ¶ added in v1.8.0
ImportSet records a discovered recovery point in this platform's database, so it can be verified, retried and restored like any other. Needed because a restored control plane only knows the points its dump contained — every one taken since is in the bucket and invisible to it. Idempotent on the ref.
func (*Service) LatestRestorableSet ¶ added in v1.8.0
func (s *Service) LatestRestorableSet() (*models.PlatformBackupSet, error)
LatestRestorableSet returns the newest completed recovery point, which is what a post-restore reconcile pulls tenant data from.
func (*Service) List ¶
func (s *Service) List() ([]models.PlatformBackup, error)
List returns all platform backups, newest first.
func (*Service) ListSets ¶ added in v1.8.0
func (s *Service) ListSets() ([]models.PlatformBackupSet, error)
ListSets returns recovery points, newest first.
func (*Service) ListSetsPaged ¶ added in v1.8.0
ListSetsPaged returns a page of recovery points plus the total count.
func (*Service) Prune ¶
Prune enforces the retention policy on platform backups: keep at most maxBackups most-recent, and delete any older than retentionDays. A zero bound is ignored. Returns the number removed.
func (*Service) PruneSets ¶ added in v1.8.0
PruneSets enforces retention over whole recovery points: keep at most maxSets recent completed sets and drop any older than retentionDays. Retention operates on sets because the artifacts are not independently useful — pruning a dump while keeping its volumes leaves something that recovers nothing.
func (*Service) Restore ¶
Restore restores a completed platform backup. It runs synchronously — the admin confirms a destructive, maintenance-mode operation and waits for the result. A DB restore overwrites the control-plane database in place; a volume restore overwrites the target volume.
func (*Service) RestoreSelected ¶ added in v1.8.0
func (s *Service) RestoreSelected(ctx context.Context, set *models.PlatformBackupSet, sel RestoreSelection) (*SelectiveRestoreReport, error)
RestoreSelected restores chosen artifacts of a recovery point into this platform. This is restore into a LIVE platform, a different operation from `miabi restore`: the control plane is already running, its encryption key is present, and the operator wants specific data back.
func (*Service) RestoreTenantData ¶ added in v1.8.0
func (s *Service) RestoreTenantData(ctx context.Context, set *models.PlatformBackupSet) (*TenantRestoreReport, error)
RestoreTenantData restores a recovery point's workload data. It runs LATE, after reconcile has recreated the database containers and volumes: a dump has nowhere to go until its instance exists. Individual failures are collected rather than returned, so an operator learns which workspaces did not come back.
func (*Service) RetrySet ¶ added in v1.8.0
func (s *Service) RetrySet(ctx context.Context, set *models.PlatformBackupSet) (*models.PlatformBackupSet, error)
RetrySet re-runs the failed artifacts of a recovery point in place rather than taking a fresh one: the artifacts that DID succeed are often the expensive ones, and re-capturing them to recover from one failed item wastes bandwidth and storage. Successful items keep their recorded artifacts.
func (*Service) RunBackup ¶
RunBackup executes a pending platform backup (the worker entry point), dispatching by subject.
func (*Service) RunScheduled ¶
RunScheduled is the cron entry point. With an S3 target it takes a whole recovery point (identity envelope + database + selected volumes) and prunes by recovery point; with only a local destination it falls back to the legacy per-artifact backup, useful for same-host rollback but not disaster recovery.
func (*Service) S3Configured ¶
S3Configured reports whether a usable S3 target is set (the UI uses it to gate volume backups, which have no local destination).
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(in SaveInput) (*models.PlatformBackupSettings, error)
SaveSettings upserts the platform backup settings, encrypting the S3 secret when a new one is supplied and preserving it otherwise. It writes against the RAW stored row, not the environment-overlaid one, so the first save cannot bake this process's environment into the database.
func (*Service) SetAppStopper ¶ added in v1.8.0
func (s *Service) SetAppStopper(a AppStopper)
SetAppStopper wires the quiesce-around-a-volume-restore behaviour.
func (*Service) SetEnqueuer ¶
SetEnqueuer wires the background worker producer.
func (*Service) SetEnv ¶ added in v1.8.0
func (s *Service) SetEnv(cfg config.PlatformBackupConfig)
SetEnv wires the environment-supplied platform backup configuration. Values present there override the stored row and are reported as env-locked.
func (*Service) SetFingerprinter ¶ added in v1.8.0
SetFingerprinter overrides how the master-key fingerprint is computed (tests). Production uses crypto.DeriveToken over the fixed KEKFingerprintLabel.
func (*Service) SetIdentitySource ¶ added in v1.8.0
func (s *Service) SetIdentitySource(fn IdentitySource)
SetIdentitySource wires the identity provider. Without one, recovery points are still taken but carry no identity envelope — they can be restored back onto this host, not onto a fresh one.
func (*Service) SetImageResolver ¶
func (s *Service) SetImageResolver(r ImageResolver)
SetImageResolver wires the deployment-config resolver for the backup tool images.
func (*Service) SetInternalNetwork ¶ added in v1.9.2
SetInternalNetwork names the platform's private network, which is where the control-plane database sits on a managed install. Leave it unset for a Compose stack: there is no such network there, and the proxy network alone is what it has always been.
func (*Service) SetKeyFingerprinter ¶ added in v1.8.0
SetKeyFingerprinter wires the fingerprint-of-an-arbitrary-key function.
func (*Service) SetLogStore ¶
SetLogStore wires the shared execution-log store. When set, a run's full output is externalized on terminal state and the DB row keeps only a bounded tail plus a reference. Platform backups have no workspace, so their objects live under an admin-only prefix.
func (*Service) SetTenantSource ¶ added in v1.8.0
func (s *Service) SetTenantSource(src TenantSource)
SetTenantSource wires tenant capture. Without one, IncludeTenantData is reported as unavailable rather than silently producing control-plane-only recovery points that look complete.
func (*Service) TenantCaptureAvailable ¶ added in v1.8.0
TenantCaptureAvailable reports whether tenant data can be included.
func (*Service) VerifySet ¶ added in v1.8.0
func (s *Service) VerifySet(ctx context.Context, set *models.PlatformBackupSet, passphrase string) (*VerifyReport, error)
VerifySet checks a recovery point without restoring anything: every artifact is present in object storage, and the identity envelope opens with the passphrase and carries the master key this platform runs on. A recovery point that has never been opened is a hypothesis.
type TenantDatabase ¶ added in v1.8.0
type TenantDatabase struct {
WorkspaceID uint
Workspace string // slug, used in the object path
Instance *models.DatabaseInstance
Database *models.Database
}
TenantDatabase is one managed logical database to capture.
type TenantRestoreReport ¶ added in v1.8.0
type TenantRestoreReport struct {
Ref string `json:"ref"`
DatabasesRestored int `json:"databases_restored"`
VolumesRestored int `json:"volumes_restored"`
Skipped []string `json:"skipped"`
Failures []string `json:"failures"`
}
TenantRestoreReport is the outcome of restoring workload data.
type TenantSource ¶ added in v1.8.0
type TenantSource interface {
ListTenantDatabases() ([]TenantDatabase, error)
ListTenantVolumes() ([]TenantVolume, error)
BackupTenantDatabase(ctx context.Context, td TenantDatabase, dest backup.Destination) (*models.Backup, error)
RestoreTenantDatabase(ctx context.Context, td TenantDatabase, dest backup.Destination, filename string) error
}
TenantSource enumerates tenant data and runs a database dump against a chosen destination. It is an interface rather than a direct dependency because dumping a tenant database is already solved by services/backup, which knows every engine and how to reach a managed instance's network.
type TenantVolume ¶ added in v1.8.0
type TenantVolume struct {
WorkspaceID uint
Workspace string
Name string // Docker volume name
ServerID uint
}
TenantVolume is one workspace-owned Docker volume to capture.
type VerifyFinding ¶ added in v1.8.0
type VerifyFinding struct {
// Severity is "error" (this set cannot restore) or "warning" (it can, with a
// caveat the operator should know before they need it).
Severity string `json:"severity"`
Message string `json:"message"`
}
VerifyFinding is one problem, in the operator's terms.
type VerifyReport ¶ added in v1.8.0
type VerifyReport struct {
Ref string `json:"ref"`
// Restorable is the bottom line: this set can rebuild the platform on a fresh
// host. False does not always mean useless — see Findings.
Restorable bool `json:"restorable"`
Findings []VerifyFinding `json:"findings"`
IdentityOpened bool `json:"identity_opened"`
KEKMatches bool `json:"kek_matches"`
InstallID string `json:"install_id,omitempty"`
MiabiVersion string `json:"miabi_version,omitempty"`
ArtifactsFound int `json:"artifacts_found"`
ArtifactsTotal int `json:"artifacts_total"`
}
VerifyReport is the outcome of a recovery-point drill.