Documentation
¶
Index ¶
- Constants
- type Config
- func (c Config) GetMirror(name string) *Mirror
- func (c Config) GetVolume(name string) *Volume
- func (c Config) ResolveMirrors(vol, subvol string) []Mirror
- func (c Config) ResolveSnapshotInterval(vol, subvol string) (interval time.Duration)
- func (c Config) ResolveSnapshotMinimumRetention(vol, subvol string) (retention time.Duration)
- func (c Config) ResolveSnapshotPath(vol, subvol string) (path string)
- func (c Config) ResolveSnapshotRetention(vol, subvol string) (retention time.Duration)
- func (c Config) ResolveSnapshotRetentionInterval(vol, subvol string) (interval time.Duration)
- func (c Config) ResolveTimeFormat(vol, subvol string) (format string)
- func (c Config) Validate() error
- func (c Config) ValidateSubvolume(vol Volume, subvol Subvolume) error
- type Duration
- type Mirror
- type Subvolume
- type Volume
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) ResolveMirrors ¶
func (Config) ResolveSnapshotInterval ¶
func (Config) ResolveSnapshotMinimumRetention ¶
func (Config) ResolveSnapshotPath ¶
func (Config) ResolveSnapshotRetention ¶
func (Config) ResolveSnapshotRetentionInterval ¶
func (Config) ResolveTimeFormat ¶
type Duration ¶
func (Duration) MarshalJSON ¶
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 (Subvolume) GetSnapshotName ¶
func (Subvolume) IsMirrorExcluded ¶
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) GetSubvolume ¶
Click to show internal directories.
Click to hide internal directories.