backup

package
v0.1.54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobTypeBackup  JobType = "backup"
	JobTypeRestore JobType = "restore"

	JobStatusPending   JobStatus = "pending"
	JobStatusRunning   JobStatus = "running"
	JobStatusCompleted JobStatus = "completed"
	JobStatusFailed    JobStatus = "failed"
)

Variables

This section is empty.

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"`
}

type BackupComponents

type BackupComponents struct {
	ComposeFile   bool     `json:"compose_file"`
	EnvFile       bool     `json:"env_file"`
	Metadata      bool     `json:"metadata"`
	MountedData   []string `json:"mounted_data,omitempty"`
	ContainerData []string `json:"container_data,omitempty"`
	Databases     []string `json:"databases,omitempty"`
}

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 CreateBackupRequest struct {
	DeploymentName string `json:"deployment_name" binding:"required"`
	Description    string `json:"description,omitempty"`
}

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 JobStatus

type JobStatus string

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 JobType

type JobType string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(deploymentsPath string) (*Manager, error)

func (*Manager) CleanupOldBackups

func (m *Manager) CleanupOldBackups(deploymentName string, keepCount int) (int, error)

func (*Manager) CreateBackup

func (m *Manager) CreateBackup(ctx context.Context, deploymentName string, spec *BackupSpec) (*Backup, error)

func (*Manager) DeleteBackup

func (m *Manager) DeleteBackup(backupID string) error

func (*Manager) GetBackup

func (m *Manager) GetBackup(backupID string) (*Backup, error)

func (*Manager) GetBackupPath

func (m *Manager) GetBackupPath(backupID string) (string, error)

func (*Manager) GetJob

func (m *Manager) GetJob(jobID string) *Job

func (*Manager) ListBackups

func (m *Manager) ListBackups(filter *BackupListFilter) ([]Backup, error)

func (*Manager) ListJobs

func (m *Manager) ListJobs(deploymentName string, limit int) []*Job

func (*Manager) RestoreBackup

func (m *Manager) RestoreBackup(ctx context.Context, req *RestoreBackupRequest) error

func (*Manager) StartBackupJob

func (m *Manager) StartBackupJob(deploymentName string, spec *BackupSpec) string

func (*Manager) StartRestoreJob

func (m *Manager) StartRestoreJob(req *RestoreBackupRequest) string

type RestoreBackupRequest

type RestoreBackupRequest struct {
	BackupID       string `json:"backup_id" binding:"required"`
	DeploymentName string `json:"deployment_name,omitempty"`
	RestoreData    bool   `json:"restore_data"`
	RestoreDB      bool   `json:"restore_db"`
	StopFirst      bool   `json:"stop_first"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL