Andrew
059f4c0097
- Added `cron` command to run lists with `cron` time specifed - Changed `-c` flag to `-f` flag for passing config file - Modified some config keys - cmdArgs -> Args - Got rid of `hosts.config` - better SSH handling - respects values in config file
38 lines
862 B
Go
38 lines
862 B
Go
// backup.go
|
|
// Copyright (C) Andrew Woodlee 2023
|
|
// License: Apache-2.0
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
backupCmd = &cobra.Command{
|
|
Use: "backup [--lists==list1,list2]",
|
|
Short: "Runs commands defined in config file.",
|
|
Long: `Backup executes commands defined in config file.
|
|
Use the --lists flag to execute the specified commands.`,
|
|
Run: Backup,
|
|
}
|
|
)
|
|
|
|
// Holds command list to run
|
|
var cmdLists []string
|
|
|
|
func init() {
|
|
|
|
backupCmd.Flags().StringSliceVarP(&cmdLists, "lists", "l", nil, "Accepts a comma-separated names of command lists to execute.")
|
|
|
|
}
|
|
|
|
func Backup(cmd *cobra.Command, args []string) {
|
|
backyConfOpts := backy.NewOpts(cfgFile, backy.AddCommandLists(cmdLists))
|
|
backyConfOpts.InitConfig()
|
|
config := backy.ReadConfig(backyConfOpts)
|
|
config.RunBackyConfig("")
|
|
}
|