Help us shape the future of Go! Take the 2026 Go Developer Survey

backup

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats bytes as human-readable.

func GetGitHead

func GetGitHead(projectPath string) string

GetGitHead returns the current HEAD commit hash for a git repo. Uses the default production dependencies.

func HasChanges

func HasChanges(projectPath string, lastBackup *manifest.BackupEntry) (bool, string)

HasChanges checks if project has changed since last backup. Uses the default production dependencies.

func ListProjects

func ListProjects(sourceDir string) ([]string, error)

ListProjects returns all directories in the source directory. Uses the default production dependencies.

Types

type BackupResult

type BackupResult struct {
	Project    string
	ZipPath    string
	SnapshotID string // For restic backups
	Size       int64
	FileCount  int
	GitHead    string
	Skipped    bool
	Reason     string
	Error      error
	SourceType config.SourceType // git or sensitive
}

BackupResult contains the result of a backup operation.

func BackupProject

func BackupProject(cfg *config.Config, project string) BackupResult

BackupProject creates a zip backup of a single project. Uses the default production dependencies.

func RunBackup

func RunBackup(cfg *config.Config) ([]BackupResult, error)

RunBackup backs up all changed projects. Uses the default production dependencies.

type Service

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

Service provides backup operations with injected dependencies.

func NewDefaultService

func NewDefaultService() *Service

NewDefaultService creates a backup service with real production dependencies.

func NewService

func NewService(fs ports.FileSystem, git ports.GitClient, archiver ports.Archiver, restic ports.ResticClient) *Service

NewService creates a new backup service with the given dependencies.

func (*Service) BackupProject

func (s *Service) BackupProject(cfg *config.Config, project string) BackupResult

BackupProject creates a zip backup of a single project.

func (*Service) BackupSensitiveSource added in v1.0.0

func (s *Service) BackupSensitiveSource(cfg *config.Config, source config.Source) BackupResult

BackupSensitiveSource backs up a sensitive source using restic.

func (*Service) GetGitHead

func (s *Service) GetGitHead(projectPath string) string

GetGitHead returns the current HEAD commit hash for a git repo.

func (*Service) HasChanges

func (s *Service) HasChanges(projectPath string, lastBackup *manifest.BackupEntry) (bool, string)

HasChanges checks if project has changed since last backup.

func (*Service) ListProjects

func (s *Service) ListProjects(sourceDir string) ([]string, error)

ListProjects returns all directories in the source directory.

func (*Service) RunBackup

func (s *Service) RunBackup(cfg *config.Config) ([]BackupResult, error)

RunBackup backs up all changed projects from all configured sources.

type ZipResult

type ZipResult struct {
	FileCount int
	Skipped   []string
}

ZipResult contains results from createZip including any skipped files.

Jump to

Keyboard shortcuts

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