* Getting environment variables and passwords from Vault (not tested
yet)
* Vault configuration to config (not tested yet)
* Ability to run scripts from file on local machine on the remote host
* Ability to get ouput in the notification of a list for individual
commands or all commands
* Make SSH connections close after all commands have been run; reuse
previous connections if needed
This commit is contained in:
2023-07-01 21:46:54 -05:00
parent 5e7c52997c
commit 4b382bddd9
831 changed files with 83782 additions and 107 deletions

3
cmd/.gitignore vendored
View File

@ -1 +1,2 @@
*.yaml
*.yaml
*.yml

View File

@ -12,9 +12,9 @@ import (
var (
backupCmd = &cobra.Command{
Use: "backup [--lists=list1,list2]",
Use: "backup [--lists=list1,list2,... | -l 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.",
Long: "Backup executes commands defined in config file.\nUse the --lists or -l flag to execute the specified lists. If not flag is not given, all lists will be executed.",
Run: Backup,
}
)
@ -34,7 +34,7 @@ func Backup(cmd *cobra.Command, args []string) {
config := backy.ReadConfig(backyConfOpts)
config.RunBackyConfig("", backyConfOpts)
config.RunListConfig("", backyConfOpts)
for _, host := range config.Hosts {
if host.SshClient != nil {
host.SshClient.Close()

View File

@ -9,7 +9,7 @@ import (
var (
cronCmd = &cobra.Command{
Use: "cron [flags]",
Short: "Runs command lists defined in config file.",
Short: "Starts a scheduler that runs lists defined in config file.",
Long: `Cron starts a scheduler that executes command lists at the time defined in config file.`,
Run: cron,
}
@ -19,6 +19,6 @@ func cron(cmd *cobra.Command, args []string) {
opts := backy.NewOpts(cfgFile, backy.UseCron())
opts.InitConfig()
backy.ReadConfig(opts).Cron()
backy.ReadConfig(opts)
opts.Cron()
}

View File

@ -14,8 +14,8 @@ import (
var (
execCmd = &cobra.Command{
Use: "exec command ...",
Short: "Runs commands defined in config file.",
Long: `Exec executes commands defined in config file.`,
Short: "Runs commands defined in config file in order given.",
Long: `Exec executes commands defined in config file in order given.`,
Run: execute,
}
)

View File

@ -7,29 +7,35 @@ import (
"github.com/spf13/cobra"
)
const versionStr = "0.2.4"
const versionStr = "0.3.0"
var (
versionCmd = &cobra.Command{
Use: "version [flags]",
Short: "Prints the version and exits.",
Short: "Prints the version and exits",
Long: "Prints the version and exits. No arguments just prints the version number only.",
Run: version,
}
numOnly bool
vPre bool
)
func version(cmd *cobra.Command, args []string) {
func init() {
versionCmd.PersistentFlags().BoolVarP(&numOnly, "num", "n", true, "Output the version number only.")
versionCmd.PersistentFlags().BoolVarP(&vPre, "vpre", "V", false, "Output the version with v prefixed.")
}
cmd.PersistentFlags().BoolVarP(&numOnly, "num", "n", true, "Output the version number only.")
cmd.PersistentFlags().BoolVarP(&vPre, "vpre", "V", false, "Output the version with v prefixed.")
func version(cmd *cobra.Command, args []string) {
if numOnly && !vPre {
fmt.Printf("%s\n", versionStr)
} else if vPre {
fmt.Printf("v%s", versionStr)
} else if vPre && !numOnly {
fmt.Printf("v%s\n", versionStr)
} else {
fmt.Printf("Backy version: %s", versionStr)
if vPre && numOnly {
fmt.Println("vpre flag and num flag both detected!")
}
fmt.Printf("Backy version: %s\n", versionStr)
}
os.Exit(0)