backea/internal/backup/strategy.go
2025-03-20 22:14:45 +01:00

58 lines
1.6 KiB
Go

package backup
import (
"context"
"io"
"time"
)
// Strategy defines the backup/restore strategy interface
type Strategy interface {
// Execute performs a backup
Execute(ctx context.Context, serviceName, directory string) error
ListBackups(ctx context.Context, serviceName string) ([]BackupInfo, error)
GetStorageUsage(ctx context.Context, serviceName string) (*StorageUsageInfo, error)
RestoreBackup(ctx context.Context, backupID string, serviceName string) error
DownloadBackup(ctx context.Context, backupID, serviceName string) (io.ReadCloser, error)
GetBackupInfo(context.Context, string, string) (*BackupInfo, error)
}
// BackupInfo contains information about a single backup
type BackupInfo struct {
ID string // Unique identifier for the backup
CreationTime time.Time // When the backup was created
Size int64 // Size in bytes
Source string // Original source path
Type string // Type of backup (e.g., "kopia", "restic")
RetentionTag string // Retention policy applied (e.g., "latest", "daily", "weekly")
}
// StorageUsageInfo contains information about backup storage usage
type StorageUsageInfo struct {
TotalBytes int64 // Total bytes stored
Provider string // Storage provider (e.g., "local", "b2", "s3")
ProviderID string // Provider-specific ID (bucket name, path, etc.)
}
// Retention represents retention policy for backups
type Retention struct {
KeepLatest int
KeepHourly int
KeepDaily int
KeepWeekly int
KeepMonthly int
KeepYearly int
}
// Destination represents rsync destination
type Destination struct {
Host string
Path string
SSHKey string
}