Documentation ¶
Index ¶
- Constants
- func DurationHookFunc() mapstructure.DecodeHookFuncType
- type Config
- func (c Config) GetMirror(name string) *Mirror
- func (c Config) GetVolume(name string) *Volume
- func (c Config) ResolveMirrorSSHHostKey(name string) string
- func (c Config) ResolveMirrorSSHKeyFile(name string) string
- func (c Config) ResolveMirrorSSHPassword(name string) string
- func (c Config) ResolveMirrorSSHUser(name string) string
- 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
- func (c Config) VolumeNameInUse(name string) bool
- type DaemonConfig
- type Duration
- type Mirror
- type MirrorFormat
- type Subvolume
- type Volume
Constants ¶
View Source
const ( DefaultSnapshotsDir = "btrsync_snapshots" 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 DefaultDaemonScanInterval = Duration(1 * time.Minute) // Scan for operations every minute in daemon mode )
Variables ¶
This section is empty.
Functions ¶
func DurationHookFunc ¶
func DurationHookFunc() mapstructure.DecodeHookFuncType
Types ¶
type Config ¶
type Config struct { // Verbosity is the verbosity level. Verbosity int `mapstructure:"verbosity" toml:"verbosity,omitempty"` // Concurrency is the number of concurrent operations to perform. Defaults to 1. Concurrency int `mapstructure:"concurrency" toml:"concurrency,omitempty"` // SnapshotsDir is the directory where snapshots are stored. Defaults to "btrsync_snapshots" // on the root of each volume. SnapshotsDir string `mapstructure:"snapshots_dir" toml:"snapshots_dir,omitempty"` // SnapshotInterval is the global interval between snapshots. SnapshotInterval Duration `mapstructure:"snapshot_interval" toml:"snapshot_interval,omitempty"` // SnapshotMinimumRetention is the global minimum retention time for snapshots. SnapshotMinimumRetention Duration `mapstructure:"snapshot_min_retention" toml:"snapshot_min_retention,omitempty"` // SnapshotRetention is the global retention time for snapshots. SnapshotRetention Duration `mapstructure:"snapshot_retention" toml:"snapshot_retention,omitempty"` // SnapshotRetentionInterval is the global interval for which snapshots will be retained in // the snapshot_retention. SnapshotRetentionInterval Duration `mapstructure:"snapshot_retention_interval" toml:"snapshot_retention_interval,omitempty"` // TimeFormat is the global time format for snapshots. TimeFormat string `mapstructure:"time_format" toml:"time_format,omitempty"` // SSHUser is the user to use for SSH connections to this mirror. If left unset, defaults // to the current user. SSHUser string `mapstructure:"ssh_user" toml:"ssh_user,omitempty"` // SSHPassword is the password to use for SSH connections to this mirror. If left unset, // or no identity key is provided, passwordless authentication is attempted. SSHPassword string `mapstructure:"ssh_password" toml:"ssh_password,omitempty"` // SSHKeyIdentityFile is the path to the SSH key identity file to use for SSH connections. SSHKeyIdentityFile string `mapstructure:"ssh_key_identity_file" toml:"ssh_key_identity_file,omitempty"` // SSHHostKey is the SSH host key to use for SSH connections. If left unset, the host key // is not verified. SSHHostKey string `mapstructure:"ssh_host_key" toml:"ssh_host_key,omitempty"` // Volumes is a list of volumes to sync. Volumes []Volume `mapstructure:"volumes" toml:"volumes,omitempty"` // Mirrors is a list of mirrors to sync snapshots to. Mirrors []Mirror `mapstructure:"mirrors" toml:"mirrors,omitempty"` // Daemon configuration Daemon DaemonConfig `mapstructure:"daemon" toml:"daemon,omitempty"` }
Config is the root configuration object.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
func (Config) ResolveMirrorSSHHostKey ¶
func (Config) ResolveMirrorSSHKeyFile ¶
func (Config) ResolveMirrorSSHPassword ¶
func (Config) ResolveMirrorSSHUser ¶
func (Config) ResolveMirrors ¶
func (Config) ResolveSnapshotInterval ¶
func (Config) ResolveSnapshotMinimumRetention ¶
func (Config) ResolveSnapshotPath ¶
func (Config) ResolveSnapshotRetention ¶
func (Config) ResolveSnapshotRetentionInterval ¶
func (Config) ResolveTimeFormat ¶
func (Config) ValidateSubvolume ¶
func (Config) VolumeNameInUse ¶
type DaemonConfig ¶
type DaemonConfig struct { // ScanInterval is the interval between scans for work to do. ScanInterval Duration `mapstructure:"scan_interval" toml:"scan_interval,omitempty"` }
DaemonConfig is the configuration for the daemon process
type Duration ¶
func (Duration) MarshalJSON ¶
func (Duration) MarshalText ¶
func (*Duration) UnmarshalJSON ¶
func (*Duration) UnmarshalText ¶
type Mirror ¶
type Mirror struct { // Name is a unique identifier for this mirror. Name string `mapstructure:"name" toml:"name,omitempty"` // 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" toml:"path,omitempty"` // Format is the format to use for snapshots mirrored to this mirror. If left unset, // defaults to "subvolume". Format MirrorFormat `mapstructure:"format" toml:"format,omitempty"` // SSHUser is the user to use for SSH connections to this mirror. If left unset, the // global value is used. SSHUser string `mapstructure:"ssh_user" toml:"ssh_user,omitempty"` // SSHPassword is the password to use for SSH connections to this mirror. If left unset, // the global value is used. SSHPassword string `mapstructure:"ssh_password" toml:"ssh_password,omitempty"` // SSHKeyIdentityFile is the path to the SSH key identity file to use for mirroring // snapshots to this mirror. If left unset, defaults to the global value. SSHKeyIdentityFile string `mapstructure:"ssh_key_identity_file" toml:"ssh_key_identity_file,omitempty"` // SSHHostKey is the host key to use for SSH connections to this mirror. If left unset, // the global value is used. SSHHostKey string `mapstructure:"ssh_host_key" toml:"ssh_host_key,omitempty"` // Disabled is a flag to disable managing this mirror temporarily. Disabled bool `mapstructure:"disabled" toml:"disabled,omitempty"` }
Mirror is the configuration for a btrfs snapshot mirror.
type MirrorFormat ¶
type MirrorFormat string
MirrorFormat is the format of the mirror path.
const ( // MirrorFormatSubvolume is the subvolume format. This is the default // format if no format is specified. Only works on Btrfs. MirrorFormatSubvolume MirrorFormat = "subvolume" // MirrorFormatDirectory is the directory format. This format is // compatible with all filesystems, however, it does not support // atomic snapshots. The most recent snapshot's contents will be stored // in the mirror path and retention settings will be ignored. MirrorFormatDirectory MirrorFormat = "directory" // // MirrorFormatZfs is the ZFS format. This format is compatible with // // ZFS filesystems. ZFS snapshots are used to create atomic snapshots // // of the subvolume and are stored in the mirror path. // MirrorFormatZfs MirrorFormat = "zfs" // MirrorFormatGzip is the gzip format. This format is compatible with all // filesystems. Snapshots are sent in stream format to the mirror path and // compressed with gzip. MirrorFormatGzip MirrorFormat = "gzip" // MirrorFormatLzw is the lzw format. This format is compatible with all // filesystems. Snapshots are sent in stream format to the mirror path and // compressed with lzw. MirrorFormatLzw MirrorFormat = "lzw" // MirrorFormatZlib is the zlib format. This format is compatible with all // filesystems. Snapshots are sent in stream format to the mirror path and // compressed with zlib. MirrorFormatZlib MirrorFormat = "zlib" // MirrorFormatZstd is the zstd format. This format is compatible with all // filesystems. Snapshots are sent in stream format to the mirror path and // compressed with zstd. MirrorFormatZstd MirrorFormat = "zstd" )
func (MirrorFormat) IsCompressed ¶
func (m MirrorFormat) IsCompressed() bool
type Subvolume ¶
type Subvolume struct { // Name is a unique identifier for this subvolume. Defaults to the path. Name string `mapstructure:"name" toml:"name,omitempty"` // Path is the path of the btrfs subvolume, relative to the volume mount. Path string `mapstructure:"path" toml:"path,omitempty"` // 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" toml:"snapshots_dir,omitempty"` // SnapshotName is the name prefix to give snapshots of this subvolume. Defaults to the // subvolume name. SnapshotName string `mapstructure:"snapshot_name" toml:"snapshot_name,omitempty"` // 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" toml:"snapshot_interval,omitempty"` // 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" toml:"snapshot_min_retention,omitempty"` // 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" toml:"snapshot_retention,omitempty"` // SnapshotRetentionInterval is the interval for which snapshots will be retained in // the snapshot_retention. If left unset either the volume or global value is used respectively. SnapshotRetentionInterval time.Duration `mapstructure:"snapshot_retention_interval" toml:"snapshot_retention_interval,omitempty"` // 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" toml:"time_format,omitempty"` // Mirrors is a list of mirror names to sync snapshots to. Automatically includes the // volume mirrors. Mirrors []string `mapstructure:"mirrors" toml:"mirrors,omitempty"` // ExcludeMirrors is a list of mirror names to exclude from syncing snapshots to. ExcludeMirrors []string `mapstructure:"exclude_mirrors" toml:"exclude_mirrors,omitempty"` // Disabled is a flag to disable managing this subvolume temporarily. Disabled bool `mapstructure:"disabled" toml:"disabled,omitempty"` }
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" toml:"name,omitempty"` // Path is the mount path of the btrfs volume. Path string `mapstructure:"path" toml:"path,omitempty"` // SnapshotsDir is the directory where snapshots are stored for this volume. If left // unset the global value is used. SnapshotsDir string `mapstructure:"snapshots_dir" toml:"snapshots_dir,omitempty"` // SnapshotInterval is the interval between snapshots for this volume. If left unset // the global value is used. SnapshotInterval time.Duration `mapstructure:"snapshot_interval" toml:"snapshot_interval,omitempty"` // 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" toml:"snapshot_min_retention,omitempty"` // SnapshotRetention is the retention time for snapshots for this volume. If left unset // the global value is used. SnapshotRetention time.Duration `mapstructure:"snapshot_retention" toml:"snapshot_retention,omitempty"` // SnapshotRetentionInterval is the interval for which snapshots will be retained in // the snapshot_retention. If left unset the global value is used. SnapshotRetentionInterval time.Duration `mapstructure:"snapshot_retention_interval" toml:"snapshot_retention_interval,omitempty"` // TimeFormat is the time format for snapshots for this volume. If left unset the global // value is used. TimeFormat string `mapstructure:"time_format" toml:"time_format,omitempty"` // Subvolumes is a list of subvolumes to manage. Subvolumes []Subvolume `mapstructure:"subvolumes" toml:"subvolumes,omitempty"` // Mirrors is a list of mirror names to sync snapshots to. Mirrors []string `mapstructure:"mirrors" toml:"mirrors,omitempty"` // Disabled is a flag to disable managing this volume temporarily. Disabled bool `mapstructure:"disabled" toml:"disabled,omitempty"` }
Volume is the global configuration for a btrfs volume.
func (Volume) GetSubvolume ¶
func (Volume) SubvolumeNameInUse ¶
Click to show internal directories.
Click to hide internal directories.