config

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: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultResticPasswordEnvVar = "CODEBAK_RESTIC_PASSWORD"

DefaultResticPasswordEnvVar is the default environment variable for the restic password. #nosec G101 -- This is an env var name, not a credential

Variables

View Source
var ErrNoHomeDir = fmt.Errorf("cannot determine home directory: HOME environment variable not set")

ErrNoHomeDir is returned when the home directory cannot be determined

Functions

func ConfigPath

func ConfigPath() (string, error)

func DefaultResticRepoPath added in v1.0.0

func DefaultResticRepoPath() (string, error)

DefaultResticRepoPath returns the default restic repository path.

func DefaultSensitivePaths added in v1.0.0

func DefaultSensitivePaths() []string

DefaultSensitivePaths returns the default paths to back up with restic encryption. These are common dotfiles and config directories containing sensitive data.

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath expands ~ to home directory. Returns error if path starts with ~ but home directory cannot be determined.

func IsValidSourceType added in v1.0.0

func IsValidSourceType(t SourceType) bool

IsValidSourceType checks if a source type is valid

Types

type Config

type Config struct {
	// Deprecated: Use Sources instead. Kept for backwards compatibility.
	SourceDir string   `yaml:"source_dir,omitempty"`
	Sources   []Source `yaml:"sources,omitempty"`
	// Individual projects outside source dirs (a la carte)
	Projects  []string `yaml:"projects,omitempty"`
	BackupDir string   `yaml:"backup_dir"`
	Schedule  string   `yaml:"schedule"`
	Time      string   `yaml:"time"`
	Exclude   []string `yaml:"exclude"`
	Retention struct {
		KeepLast int `yaml:"keep_last"`
	} `yaml:"retention"`
	// Restic configuration for sensitive path backups
	Restic ResticConfig `yaml:"restic,omitempty"`
}

func DefaultConfig

func DefaultConfig() (*Config, error)

func Load

func Load() (*Config, error)

func (*Config) GetResticPassword added in v1.0.0

func (c *Config) GetResticPassword() (string, error)

GetResticPassword retrieves the restic password from the configured environment variable. Returns an error if the environment variable is not set.

func (*Config) GetResticPasswordEnvVar added in v1.0.0

func (c *Config) GetResticPasswordEnvVar() string

GetResticPasswordEnvVar returns the environment variable name for the restic password.

func (*Config) GetResticRepoPath added in v1.0.0

func (c *Config) GetResticRepoPath() (string, error)

GetResticRepoPath returns the restic repository path with defaults applied.

func (*Config) GetSources added in v1.0.0

func (c *Config) GetSources() []Source

GetSources returns all sources, migrating from SourceDir if needed

func (*Config) GetSourcesByType added in v1.0.0

func (c *Config) GetSourcesByType(t SourceType) []Source

GetSourcesByType returns sources filtered by type

func (*Config) Save

func (c *Config) Save() error

type ResticConfig added in v1.0.0

type ResticConfig struct {
	// RepoPath is the path to the restic repository for sensitive backups.
	// Defaults to ~/.codebak/restic-repo
	RepoPath string `yaml:"repo_path,omitempty"`
	// PasswordEnvVar is the environment variable name containing the repository password.
	// Defaults to CODEBAK_RESTIC_PASSWORD
	PasswordEnvVar string `yaml:"password_env_var,omitempty"`
}

ResticConfig holds configuration for restic encrypted backups.

type Source added in v1.0.0

type Source struct {
	Path  string     `yaml:"path"`
	Label string     `yaml:"label,omitempty"` // Display label (defaults to path basename)
	Icon  string     `yaml:"icon,omitempty"`  // Emoji icon for TUI display
	Type  SourceType `yaml:"type,omitempty"`  // Backup type: git (default) or sensitive
}

Source represents a directory to scan for projects

type SourceType added in v1.0.0

type SourceType string

SourceType defines how a source should be backed up

const (
	// SourceTypeGit backs up using git bundles (default for code directories)
	SourceTypeGit SourceType = "git"
	// SourceTypeSensitive backs up using restic for encrypted incremental backups
	SourceTypeSensitive SourceType = "sensitive"
)

Jump to

Keyboard shortcuts

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