group zfsnap a bit more

This commit is contained in:
shoopea 2021-10-12 15:27:49 +08:00
parent f7df39f916
commit a0cd2cdbcc

View File

@ -533,20 +533,25 @@ func (a AppConfig) RunAppSchedule(schedule string) error {
} }
} }
} }
var refreshSnapshot map[string]bool
refreshSnapshot = make(map[string]bool) refreshSnapshot := make(map[string]bool)
takeSnapshot := make(map[string]string)
for _, v := range a.Sources { for _, v := range a.Sources {
if *debugFlag { takeSnapshot[v.Box()] = takeSnapshot[v.Box()] + " " + v.Path()
log.Printf("RunAppSchedule : taking %s snapshot for %s", schedule, v.Path()) refreshSnapshot[v.Box()] = true
} }
err := cfg.ssh[v.Box()].exec("/usr/sbin/zfsnap snapshot -p '" + schedule + "-' -a " + cfg.Zfsnap[schedule] + " " + v.Path()) for k, v := range takeSnapshot {
if *debugFlag {
log.Printf("RunAppSchedule : taking %s snapshot on %s for%s", schedule, k, v)
}
err := cfg.ssh[k].exec("/usr/sbin/zfsnap snapshot -p '" + schedule + "-' -a " + cfg.Zfsnap[schedule] + v)
if err != nil { if err != nil {
if *debugFlag { if *debugFlag {
log.Printf("RunAppSchedule : Error executing zfsnap on %s", string(v)) log.Printf("RunAppSchedule : Error executing zfsnap on %s", k)
} }
return err return err
} }
refreshSnapshot[v.Box()] = true
} }
for _, v := range a.Destinations { for _, v := range a.Destinations {
refreshSnapshot[v.Box()] = true refreshSnapshot[v.Box()] = true