Added option to run local (rsync) or cloud (rclone) backups, in case you prefer a "full" copy with hardlinks via rsync, or latest/incremental snapshots via rclone

This commit is contained in:
2026-09-03 13:21:54 -04:00
parent fe6101a532
commit 0144cc2b4e
11 changed files with 1428 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package config
import (
"errors"
"fmt"
"github.com/spf13/viper"
)
type Config struct {
Source string `mapstructure:"source"`
Destination string `mapstructure:"destination"`
Workers int `mapstructure:"workers"`
KeepIncrementals int `mapstructure:"keep_incrementals"`
Verbose bool `mapstructure:"verbose"`
}
// Load unmarshals the current Viper state into a Config struct and validates it.
func Load() (*Config, error) {
var cfg Config
if err := viper.Unmarshal(&cfg); err != nil {
return nil, fmt.Errorf("failed to unmarshal configuration: %w", err)
}
if cfg.Source == "" {
return nil, errors.New("source path must be specified")
}
if cfg.Destination == "" {
return nil, errors.New("destination path must be specified")
}
if cfg.KeepIncrementals < 0 {
cfg.KeepIncrementals = 0
}
return &cfg, nil
}