config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeFormat                = "2006-01-02_15-04-05"
	DefaultSnapshotInterval          = Duration(1 * time.Hour)      // Hourly snapshots
	DefaultSnapshotMinimumRetention  = Duration(1 * 24 * time.Hour) // Keep all snapshots at least a day
	DefaultSnapshotRetention         = Duration(7 * 24 * time.Hour) // Retain snapshots for 7 days
	DefaultSnapshotRetentionInterval = Duration(1 * 24 * time.Hour) // One snapshot retained per day
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Verbosity is the verbosity level.
	Verbosity int `mapstructure:"verbosity"`
	// SnapshotsDir is the directory where snapshots are stored. Defaults to "btrsync_snapshots"
	// on the root of each volume.
	SnapshotsDir string `mapstructure:"snapshots_dir"`
	// SnapshotInterval is the global interval between snapshots.
	SnapshotInterval Duration `mapstructure:"snapshot_interval"`
	// SnapshotMinimumRetention is the global minimum retention time for snapshots.
	SnapshotMinimumRetention Duration `mapstructure:"snapshot_min_retention"`
	// SnapshotRetention is the global retention time for snapshots.
	SnapshotRetention Duration `mapstructure:"snapshot_retention"`
	// SnapshotRetentionInterval is the global interval between snapshot retention runs.
	SnapshotRetentionInterval Duration `mapstructure:"snapshot_retention_interval"`
	// TimeFormat is the global time format for snapshots.
	TimeFormat string `mapstructure:"time_format"`
	// Volumes is a list of volumes to sync.
	Volumes []Volume `mapstructure:"volumes"`
	// Mirrors is a list of mirrors to sync snapshots to.
	Mirrors []Mirror `mapstructure:"mirrors"`
}

Config is the root configuration object.

func NewDefaultConfig

func NewDefaultConfig() Config

func (Config) GetMirror

func (c Config) GetMirror(name string) *Mirror

func (Config) GetVolume

func (c Config) GetVolume(name string) *Volume

func (Config) ResolveMirrors

func (c Config) ResolveMirrors(vol, subvol string) []Mirror

func (Config) ResolveSnapshotInterval

func (c Config) ResolveSnapshotInterval(vol, subvol string) (interval time.Duration)

func (Config) ResolveSnapshotMinimumRetention

func (c Config) ResolveSnapshotMinimumRetention(vol, subvol string) (retention time.Duration)

func (Config) ResolveSnapshotPath

func (c Config) ResolveSnapshotPath(vol, subvol string) (path string)

func (Config) ResolveSnapshotRetention

func (c Config) ResolveSnapshotRetention(vol, subvol string) (retention time.Duration)

func (Config) ResolveSnapshotRetentionInterval

func (c Config) ResolveSnapshotRetentionInterval(vol, subvol string) (interval time.Duration)

func (Config) ResolveTimeFormat

func (c Config) ResolveTimeFormat(vol, subvol string) (format string)

func (Config) Validate

func (c Config) Validate() error

func (Config) ValidateSubvolume

func (c Config) ValidateSubvolume(vol Volume, subvol Subvolume) error

type Duration

type Duration time.Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

type Mirror

type Mirror struct {
	// Name is a unique identifier for this mirror.
	Name string `mapstructure:"name"`
	// Path is the location of the mirror. Each subvolume mirrored to this mirror will be
	// stored in a subdirectory of this path.
	Path string `mapstructure:"path"`
	// Disabled is a flag to disable managing this mirror temporarily.
	Disabled bool `mapstructure:"disabled"`
}

Mirror is the configuration for a btrfs snapshot mirror.

type Subvolume

type Subvolume struct {
	// Name is a unique identifier for this subvolume. Defaults to the path.
	Name string `mapstructure:"name"`
	// Path is the path of the btrfs subvolume, relative to the volume mount.
	Path string `mapstructure:"path"`
	// SnapshotsDir is the directory where snapshots are stored for this subvolume. If left
	// unset either the volume or global value is used respectively.
	SnapshotsDir string `mapstructure:"snapshots_dir"`
	// SnapshotName is the name prefix to give snapshots of this subvolume. Defaults to the
	// subvolume name.
	SnapshotName string `mapstructure:"snapshot_name"`
	// SnapshotInterval is the interval between snapshots for this subvolume. If left unset
	// either the volume or global value is used respectively.
	SnapshotInterval time.Duration `mapstructure:"snapshot_interval"`
	// SnapshotMinimumRetention is the minimum retention time for snapshots for this subvolume.
	// If left unset either the volume or global value is used respectively.
	SnapshotMinimumRetention time.Duration `mapstructure:"snapshot_min_retention"`
	// SnapshotRetention is the retention time for snapshots for this subvolume. If left unset
	// either the volume or global value is used respectively.
	SnapshotRetention time.Duration `mapstructure:"snapshot_retention"`
	// SnapshotRetentionInterval is the interval between snapshot retention runs for this
	// subvolume. If left unset either the volume or global value is used respectively.
	SnapshotRetentionInterval time.Duration `mapstructure:"snapshot_retention_interval"`
	// TimeFormat is the time format for snapshots for this subvolume. If left unset either
	// the volume or global value is used respectively.
	TimeFormat string `mapstructure:"time_format"`
	// Mirrors is a list of mirror names to sync snapshots to. Automatically includes the
	// volume mirrors.
	Mirrors []string `mapstructure:"mirrors"`
	// ExcludeMirrors is a list of mirror names to exclude from syncing snapshots to.
	ExcludeMirrors []string `mapstructure:"exclude_mirrors"`
	// Disabled is a flag to disable managing this subvolume temporarily.
	Disabled bool `mapstructure:"disabled"`
}

Subvolume is the configuration for a btrfs subvolume.

func (Subvolume) FilterExcludedMirrors

func (s Subvolume) FilterExcludedMirrors(mm []Mirror) []Mirror

func (Subvolume) GetName

func (s Subvolume) GetName() string

func (Subvolume) GetSnapshotName

func (s Subvolume) GetSnapshotName() string

func (Subvolume) IsMirrorExcluded

func (s Subvolume) IsMirrorExcluded(name string) bool

type Volume

type Volume struct {
	// Name is a unique identifier for this volume. Defaults to the path.
	Name string `mapstructure:"name"`
	// Path is the mount path of the btrfs volume.
	Path string `mapstructure:"path"`
	// SnapshotsDir is the directory where snapshots are stored for this volume. If left
	// unset the global value is used.
	SnapshotsDir string `mapstructure:"snapshots_dir"`
	// SnapshotInterval is the interval between snapshots for this volume. If left unset
	// the global value is used.
	SnapshotInterval time.Duration `mapstructure:"snapshot_interval"`
	// SnapshotMinimumRetention is the minimum retention time for snapshots for this volume.
	// If left unset the global value is used.
	SnapshotMinimumRetention time.Duration `mapstructure:"snapshot_min_retention"`
	// SnapshotRetention is the retention time for snapshots for this volume. If left unset
	// the global value is used.
	SnapshotRetention time.Duration `mapstructure:"snapshot_retention"`
	// SnapshotRetentionInterval is the interval between snapshot retention runs for this
	// volume. If left unset the global value is used.
	SnapshotRetentionInterval time.Duration `mapstructure:"snapshot_retention_interval"`
	// TimeFormat is the time format for snapshots for this volume. If left unset the global
	// value is used.
	TimeFormat string `mapstructure:"time_format"`
	// Subvolumes is a list of subvolumes to manage.
	Subvolumes []Subvolume `mapstructure:"subvolumes"`
	// Mirrors is a list of mirror names to sync snapshots to.
	Mirrors []string `mapstructure:"mirrors"`
	// Disabled is a flag to disable managing this volume temporarily.
	Disabled bool `mapstructure:"disabled"`
}

Volume is the global configuration for a btrfs volume.

func (Volume) GetName

func (v Volume) GetName() string

func (Volume) GetSubvolume

func (v Volume) GetSubvolume(name string) *Subvolume

func (Volume) Validate

func (v Volume) Validate() error

Jump to

Keyboard shortcuts

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