Andrew
ee83586072
* Notifications now display errors and the output of the failed command. * CI configs for GitHub and Woodpecker * Added `version` subcommand * Console logging can be disabled by setting `console-disabled` in the `logging` object * If Host was not defined for an incomplete `hosts` object, any commands would fail as they could not look up the values in the SSH config files.
37 lines
907 B
Go
37 lines
907 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.\nUse the --lists flag to execute the specified commands. If not specified, all lists will be executed.",
|
|
Run: Backup,
|
|
}
|
|
)
|
|
|
|
// Holds command list to run
|
|
var cmdLists []string
|
|
|
|
func init() {
|
|
|
|
backupCmd.Flags().StringSliceVarP(&cmdLists, "lists", "l", nil, "Accepts 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("")
|
|
}
|