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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user