do not try to backup app when one source offline
This commit is contained in:
		
							parent
							
								
									e62627e406
								
							
						
					
					
						commit
						4d24ded4d7
					
				
							
								
								
									
										53
									
								
								app.go
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								app.go
									
									
									
									
									
								
							@ -23,6 +23,9 @@ func (a AppConfig) getSchedule() (schedule string, err error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	refreshSnapshot := make(map[string]bool)
 | 
						refreshSnapshot := make(map[string]bool)
 | 
				
			||||||
	for _, v := range a.Sources {
 | 
						for _, v := range a.Sources {
 | 
				
			||||||
 | 
							if !cfg.Box[v.Box()].online {
 | 
				
			||||||
 | 
								return "", nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		refreshSnapshot[v.Box()] = true
 | 
							refreshSnapshot[v.Box()] = true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for k, _ := range refreshSnapshot {
 | 
						for k, _ := range refreshSnapshot {
 | 
				
			||||||
@ -537,6 +540,36 @@ func (a AppConfig) RefreshSnapshot() error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (a AppConfig) CreatePath() (err error) {
 | 
				
			||||||
 | 
						if *debugFlag {
 | 
				
			||||||
 | 
							log.Printf("AppConfig.CreatePath : %s : Start", a.Name)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, src := range a.Sources {
 | 
				
			||||||
 | 
							for _, dest := range a.Destinations {
 | 
				
			||||||
 | 
								if cfg.Box[dest.Box()].online {
 | 
				
			||||||
 | 
									if *debugFlag {
 | 
				
			||||||
 | 
										log.Printf("AppConfig.CreatePath : %s : Checking path on %s", a.Name, string(dest))
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if !cfg.Box[dest.Box()].ZFSIsZFS(dest.Path() + "/" + src.Box() + "/" + src.Path()) {
 | 
				
			||||||
 | 
										if *debugFlag {
 | 
				
			||||||
 | 
											log.Printf("AppConfig.CreatePath : %s : Creating on %s path %s", a.Name, dest.Box(), dest.Path()+"/"+src.Box()+"/"+src.Path())
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										if err = cfg.Box[dest.Box()].ZFSCreateZFS(dest.Path() + "/" + src.Box() + "/" + src.Path()); err != nil {
 | 
				
			||||||
 | 
											if *debugFlag {
 | 
				
			||||||
 | 
												log.Printf("AppConfig.CreatePath : %s : Creating on %s path %s failed (%s)", a.Name, dest.Box(), dest.Path()+"/"+src.Box()+"/"+src.Path(), err)
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											return
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						err = nil
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a AppConfig) SendSnapshots() (err error) {
 | 
					func (a AppConfig) SendSnapshots() (err error) {
 | 
				
			||||||
	if *debugFlag {
 | 
						if *debugFlag {
 | 
				
			||||||
		log.Printf("AppConfig.SendSnapshots : %s : Start", a.Name)
 | 
							log.Printf("AppConfig.SendSnapshots : %s : Start", a.Name)
 | 
				
			||||||
@ -565,18 +598,6 @@ func (a AppConfig) SendSnapshots() (err error) {
 | 
				
			|||||||
						return
 | 
											return
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if !cfg.Box[dest.Box()].ZFSIsZFS(dest.Path() + "/" + src.Box() + "/" + src.Path()) {
 | 
					 | 
				
			||||||
						if *debugFlag {
 | 
					 | 
				
			||||||
							log.Printf("AppConfig.SendSnapshots : %s : Creating on %s path %s", a.Name, dest.Box(), dest.Path()+"/"+src.Box()+"/"+src.Path())
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						if err = cfg.Box[dest.Box()].ZFSCreateZFS(dest.Path() + "/" + src.Box() + "/" + src.Path()); err != nil {
 | 
					 | 
				
			||||||
							if *debugFlag {
 | 
					 | 
				
			||||||
								log.Printf("AppConfig.SendSnapshots : %s : Creating on %s path %s failed (%s)", a.Name, dest.Box(), dest.Path()+"/"+src.Box()+"/"+src.Path(), err)
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							return
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if *debugFlag {
 | 
										if *debugFlag {
 | 
				
			||||||
						log.Printf("AppConfig.SendSnapshots : %s : Initializing snapshot on %s from %s", a.Name, dest.Box(), string(sFirstSnapshot))
 | 
											log.Printf("AppConfig.SendSnapshots : %s : Initializing snapshot on %s from %s", a.Name, dest.Box(), string(sFirstSnapshot))
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
@ -738,6 +759,14 @@ func (a AppConfig) RunAppBackup() error {
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = a.CreatePath()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							if *debugFlag {
 | 
				
			||||||
 | 
								log.Printf("AppConfig.RunAppBackup : %s : CreatePath : %s", a.Name, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = a.SendSnapshots()
 | 
						err = a.SendSnapshots()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if *debugFlag {
 | 
							if *debugFlag {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
 | 
					// Code generated by version.sh (@generated) DO NOT EDIT.
 | 
				
			||||||
package main
 | 
					package main
 | 
				
			||||||
var githash = "41d56eb"
 | 
					var githash = "e62627e"
 | 
				
			||||||
var buildstamp = "2022-06-17_12:53:48"
 | 
					var buildstamp = "2022-06-17_13:44:04"
 | 
				
			||||||
var commits = "34"
 | 
					var commits = "35"
 | 
				
			||||||
var version = "41d56eb-b34 - 2022-06-17_12:53:48"
 | 
					var version = "e62627e-b35 - 2022-06-17_13:44:04"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user