specific app

This commit is contained in:
shoopea 2021-10-18 22:20:44 +08:00
parent 26e4b56507
commit 29d37e0dc1
2 changed files with 30 additions and 13 deletions

2
app.go
View File

@ -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)

View File

@ -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,20 +212,36 @@ func main() {
}
//RunBackup run all backup targets where schedule is registered
func RunBackup() error {
func RunBackup(app string) error {
if app == "" {
if *debugFlag {
log.Printf("RunBackup() : Start")
}
for _, app := range cfg.Apps {
err := app.RunAppBackup()
for _, a := range cfg.Apps {
err := a.RunAppBackup()
if err != nil {
if *debugFlag {
log.Printf("RunBackup() : Error running %s", app.Name)
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 nil
}