diff --git a/app.go b/app.go index ff96e51..e9ae3ab 100644 --- a/app.go +++ b/app.go @@ -586,7 +586,7 @@ func (a AppConfig) SendSnapshots() error { func (a AppConfig) CleanupSnapshot() error { if *debugFlag { - log.Printf("AppConfig.CleanupSnapshot : %s : Start]", a.Name) + log.Printf("AppConfig.CleanupSnapshot : %s : Start", a.Name) } cleanupSnapshot := make(map[string]string) diff --git a/backup.go b/backup.go index 7ae903a..bfbc785 100644 --- a/backup.go +++ b/backup.go @@ -28,6 +28,7 @@ type BoxConfig struct { } var ( + appFlag = flag.String("app", "", "run specific app") cfgFile = flag.String("config", "config.json", "config file") schedFlag = flag.String("schedule", "", "specific schedule") testFlag = flag.Bool("test", false, "test run") @@ -203,7 +204,7 @@ func main() { os.Exit(1) } - err = RunBackup() + err = RunBackup(*appFlag) if err != nil { log.Printf("Cannot run schedule (%s)", err) os.Exit(1) @@ -211,18 +212,34 @@ func main() { } //RunBackup run all backup targets where schedule is registered -func RunBackup() error { - if *debugFlag { - log.Printf("RunBackup() : Start") - } - - for _, app := range cfg.Apps { - err := app.RunAppBackup() - if err != nil { - if *debugFlag { - log.Printf("RunBackup() : Error running %s", app.Name) +func RunBackup(app string) error { + if app == "" { + if *debugFlag { + log.Printf("RunBackup() : Start") + } + for _, a := range cfg.Apps { + err := a.RunAppBackup() + if err != nil { + if *debugFlag { + log.Printf("RunBackup() : Error running %s", a.Name) + } + return err + } + } + } else { + if *debugFlag { + log.Printf("RunBackup() : Start %s", app) + } + for _, a := range cfg.Apps { + if a.Name == app { + err := a.RunAppBackup() + if err != nil { + if *debugFlag { + log.Printf("RunBackup() : Error running %s", a.Name) + } + return err + } } - return err } }