Documentation
¶
Index ¶
- Constants
- Variables
- type Backup
- type BackupComponents
- type BackupListFilter
- type BackupMetadata
- type BackupSpec
- type BackupStatus
- type ContainerPath
- type CreateBackupRequest
- type DatabaseSpec
- type HookSpec
- type Job
- type JobStatus
- type JobTracker
- func (t *JobTracker) Cleanup(olderThan time.Duration)
- func (t *JobTracker) CreateJob(id string, jobType JobType, deploymentName string) *Job
- func (t *JobTracker) GetJob(id string) *Job
- func (t *JobTracker) ListJobs(deploymentName string, limit int) []*Job
- func (t *JobTracker) SetBackupID(id string, backupID string)
- func (t *JobTracker) SetError(id string, err error)
- func (t *JobTracker) UpdateStatus(id string, status JobStatus, progress string)
- type JobType
- type Manager
- func (m *Manager) CleanupOldBackups(deploymentName string, keepCount int) (int, error)
- func (m *Manager) CreateBackup(ctx context.Context, deploymentName string, spec *BackupSpec) (*Backup, error)
- func (m *Manager) DeleteBackup(backupID string) error
- func (m *Manager) GetBackup(backupID string) (*Backup, error)
- func (m *Manager) GetBackupPath(backupID string) (string, error)
- func (m *Manager) GetJob(jobID string) *Job
- func (m *Manager) ListBackups(filter *BackupListFilter) ([]Backup, error)
- func (m *Manager) ListJobs(deploymentName string, limit int) []*Job
- func (m *Manager) OpenBackupArchive(ctx context.Context, backupID string) (io.ReadCloser, int64, error)
- func (m *Manager) RestoreBackup(ctx context.Context, req *RestoreBackupRequest) error
- func (m *Manager) SetRemotes(remotes []Store)
- func (m *Manager) StartBackupJob(deploymentName string, spec *BackupSpec) string
- func (m *Manager) StartRestoreJob(req *RestoreBackupRequest) string
- type ObjectInfo
- type RestoreBackupRequest
- type S3Config
- type S3Store
- func (s *S3Store) Bucket() string
- func (s *S3Store) BucketStats(ctx context.Context, limit int) (count int, size int64, truncated bool, err error)
- func (s *S3Store) Delete(ctx context.Context, key string) error
- func (s *S3Store) DeleteBucket(ctx context.Context) error
- func (s *S3Store) EnsureBucket(ctx context.Context) error
- func (s *S3Store) List(ctx context.Context, prefix string) ([]ObjectInfo, error)
- func (s *S3Store) ListBuckets(ctx context.Context) ([]string, error)
- func (s *S3Store) ListObjects(ctx context.Context, prefix string) ([]ObjectInfo, error)
- func (s *S3Store) ListObjectsPage(ctx context.Context, prefix, token string, limit int32) ([]ObjectInfo, string, error)
- func (s *S3Store) Name() string
- func (s *S3Store) Open(ctx context.Context, key string) (io.ReadCloser, error)
- func (s *S3Store) Put(ctx context.Context, key string, r io.Reader, size int64) error
- func (s *S3Store) Stat(ctx context.Context, key string) (ObjectInfo, error)
- func (s *S3Store) WithBucket(bucket string) *S3Store
- type Store
Constants ¶
Variables ¶
var ErrObjectNotFound = errors.New("object not found")
ErrObjectNotFound is returned by a Store when the requested key is absent.
Functions ¶
This section is empty.
Types ¶
type Backup ¶
type Backup struct {
ID string `json:"id"`
DeploymentName string `json:"deployment_name"`
Status BackupStatus `json:"status"`
Size int64 `json:"size"`
Path string `json:"path"`
Components []string `json:"components"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// Locations lists where this backup exists: "local" and/or remote
// destination names. A backup may live remotely only if local retention
// has pruned the on-disk copy.
Locations []string `json:"locations,omitempty"`
}
type BackupComponents ¶
type BackupListFilter ¶
type BackupListFilter struct {
DeploymentName string
Status BackupStatus
Limit int
Offset int
}
type BackupMetadata ¶
type BackupMetadata struct {
ID string `json:"id"`
DeploymentName string `json:"deployment_name"`
DeploymentPath string `json:"deployment_path"`
CreatedAt time.Time `json:"created_at"`
AgentVersion string `json:"agent_version"`
Components BackupComponents `json:"components"`
ContainerStates map[string]string `json:"container_states,omitempty"`
}
type BackupSpec ¶
type BackupSpec = models.BackupSpec
type BackupStatus ¶
type BackupStatus string
const ( BackupStatusPending BackupStatus = "pending" BackupStatusInProgress BackupStatus = "in_progress" BackupStatusCompleted BackupStatus = "completed" BackupStatusFailed BackupStatus = "failed" )
type ContainerPath ¶
type ContainerPath = models.ContainerBackupPath
type CreateBackupRequest ¶
type DatabaseSpec ¶
type DatabaseSpec = models.DatabaseBackupSpec
type HookSpec ¶
type HookSpec = models.BackupHookSpec
type Job ¶
type Job struct {
ID string `json:"id"`
Type JobType `json:"type"`
Status JobStatus `json:"status"`
DeploymentName string `json:"deployment_name"`
BackupID string `json:"backup_id,omitempty"`
Progress string `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
}
type JobTracker ¶
type JobTracker struct {
// contains filtered or unexported fields
}
func NewJobTracker ¶
func NewJobTracker() *JobTracker
func (*JobTracker) Cleanup ¶
func (t *JobTracker) Cleanup(olderThan time.Duration)
func (*JobTracker) CreateJob ¶
func (t *JobTracker) CreateJob(id string, jobType JobType, deploymentName string) *Job
func (*JobTracker) GetJob ¶
func (t *JobTracker) GetJob(id string) *Job
func (*JobTracker) ListJobs ¶
func (t *JobTracker) ListJobs(deploymentName string, limit int) []*Job
func (*JobTracker) SetBackupID ¶
func (t *JobTracker) SetBackupID(id string, backupID string)
func (*JobTracker) SetError ¶
func (t *JobTracker) SetError(id string, err error)
func (*JobTracker) UpdateStatus ¶
func (t *JobTracker) UpdateStatus(id string, status JobStatus, progress string)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) CleanupOldBackups ¶
CleanupOldBackups prunes the local on-disk copies beyond keepCount. Retention applies to local disk only; remote copies are governed by the destination's own lifecycle policy and are never deleted here.
func (*Manager) CreateBackup ¶
func (*Manager) DeleteBackup ¶
DeleteBackup removes a backup from the local disk and every remote it may exist in. Remote deletes are idempotent, so a backup already absent remotely is not an error.
func (*Manager) GetBackup ¶
GetBackup resolves a backup by ID, preferring the local copy and falling back to the first remote that holds it.
func (*Manager) ListBackups ¶
func (m *Manager) ListBackups(filter *BackupListFilter) ([]Backup, error)
ListBackups returns backups from the local disk merged with those in every remote destination, deduped by ID with Locations tagged. A remote that fails to list is logged and skipped so the local listing still returns.
func (*Manager) OpenBackupArchive ¶
func (m *Manager) OpenBackupArchive(ctx context.Context, backupID string) (io.ReadCloser, int64, error)
OpenBackupArchive returns a reader for the backup archive, from local disk if present, otherwise streamed from the first remote that holds it.
func (*Manager) RestoreBackup ¶
func (m *Manager) RestoreBackup(ctx context.Context, req *RestoreBackupRequest) error
func (*Manager) SetRemotes ¶
SetRemotes replaces the set of remote destinations backups are mirrored to. It is called at startup and whenever the backup destination config changes.
func (*Manager) StartBackupJob ¶
func (m *Manager) StartBackupJob(deploymentName string, spec *BackupSpec) string
func (*Manager) StartRestoreJob ¶
func (m *Manager) StartRestoreJob(req *RestoreBackupRequest) string
type ObjectInfo ¶
ObjectInfo describes a stored backup archive in a remote destination.
type RestoreBackupRequest ¶
type S3Config ¶
type S3Config struct {
Name string
Endpoint string
Region string
Bucket string
Prefix string
AccessKeyID string
SecretKey string
UsePathStyle bool
}
S3Config holds everything needed to reach one S3-compatible bucket. It carries resolved secrets and is assembled by the caller from a destination plus its referenced credential; it is never persisted.
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
func NewS3Store ¶
func (*S3Store) BucketStats ¶
func (s *S3Store) BucketStats(ctx context.Context, limit int) (count int, size int64, truncated bool, err error)
BucketStats returns the object count and total size of the store's bucket. Counting stops at limit (when > 0), reporting truncated=true, so the bucket list stays responsive on very large buckets.
func (*S3Store) DeleteBucket ¶
DeleteBucket removes the store's bucket. S3 requires it to be empty.
func (*S3Store) EnsureBucket ¶
EnsureBucket creates the store's bucket when it does not already exist. A freshly deployed object store starts empty, so a managed store needs its bucket made before the first backup can be mirrored to it.
func (*S3Store) ListBuckets ¶
ListBuckets returns the names of every bucket reachable with the store's credentials. A store is configured with one bucket, but the server it points at (a self-hosted MinIO, say) can host many.
func (*S3Store) ListObjects ¶
ListObjects returns every object under prefix, unlike List which is scoped to backup archives (.tar.gz). It backs the object browser, where a store's full contents are shown.
func (*S3Store) ListObjectsPage ¶
func (s *S3Store) ListObjectsPage(ctx context.Context, prefix, token string, limit int32) ([]ObjectInfo, string, error)
ListObjectsPage returns one page of objects and a continuation token for the next page (empty when there are no more), so a browser can page through a bucket of any size instead of loading it whole.
func (*S3Store) WithBucket ¶
WithBucket returns a view of the store scoped to another bucket at its root (no prefix), so the object browser can work across buckets on the same server.
type Store ¶
type Store interface {
// Name is the destination's configured name, surfaced as a backup location.
Name() string
// Put writes an object of the given size at key.
Put(ctx context.Context, key string, r io.Reader, size int64) error
// Open returns a reader for the object at key.
Open(ctx context.Context, key string) (io.ReadCloser, error)
// List returns objects whose key begins with prefix.
List(ctx context.Context, prefix string) ([]ObjectInfo, error)
// Delete removes the object at key. Missing objects are not an error.
Delete(ctx context.Context, key string) error
// Stat returns metadata for a single object.
Stat(ctx context.Context, key string) (ObjectInfo, error)
}
Store is a remote destination that backup archives are mirrored to. The local filesystem remains the primary copy and is handled directly by the Manager; a Store is only ever a secondary, remote target.