backup

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 11 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
	Size      int64
	FileCount int
	GitHead   string
	Skipped   bool
	Reason    string
	Error     error
}

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) *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) 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.

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