package cmd

import (
	"fmt"

	"git.metaunix.net/bitgoblin/goblin-store/lib/backup"
	"git.metaunix.net/bitgoblin/goblin-store/lib/config"

	"github.com/spf13/cobra"
)

var backupLocalCmd = &cobra.Command{
	Use:   "local",
	Short: "Run local hardlinked snapshot backup (via Rsync)",
	RunE: func(cmd *cobra.Command, args []string) error {
		cfg, err := config.Load()
		if err != nil {
			return fmt.Errorf("configuration error: %w", err)
		}

		return backup.RunRsyncIncremental(cmd.Context(), cfg)
	},
}

func init() {
	backupCmd.AddCommand(backupLocalCmd)
}
