backup: include cross-checker discovery entries in backup/restore
Extend Backup to carry the two new KV indexes introduced by the discovery mechanism.
This commit is contained in:
parent
3739d1a3e0
commit
53b4001f3c
2 changed files with 47 additions and 13 deletions
|
|
@ -160,6 +160,26 @@ func (bc *BackupController) DoBackup() (ret happydns.Backup) {
|
|||
}
|
||||
}
|
||||
|
||||
// Discovery entries.
|
||||
if entryIter, err := bc.store.ListAllDiscoveryEntries(); err != nil {
|
||||
ret.Errors = append(ret.Errors, fmt.Sprintf("unable to retrieve DiscoveryEntries: %s", err.Error()))
|
||||
} else {
|
||||
defer entryIter.Close()
|
||||
for entryIter.Next() {
|
||||
ret.DiscoveryEntries = append(ret.DiscoveryEntries, entryIter.Item())
|
||||
}
|
||||
}
|
||||
|
||||
// Discovery observation refs.
|
||||
if refIter, err := bc.store.ListAllDiscoveryObservationRefs(); err != nil {
|
||||
ret.Errors = append(ret.Errors, fmt.Sprintf("unable to retrieve DiscoveryObservationRefs: %s", err.Error()))
|
||||
} else {
|
||||
defer refIter.Close()
|
||||
for refIter.Next() {
|
||||
ret.DiscoveryObservationRefs = append(ret.DiscoveryObservationRefs, refIter.Item())
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -238,6 +258,18 @@ func (bc *BackupController) DoRestore(backup *happydns.Backup) (errs error) {
|
|||
errs = errors.Join(errs, bc.store.RestoreExecution(exec))
|
||||
}
|
||||
|
||||
// Discovery entries. Restored after snapshots (referenced indirectly via
|
||||
// target + producer, no FK), before observation refs which carry snapshot
|
||||
// pointers that must resolve at lookup time.
|
||||
for _, entry := range backup.DiscoveryEntries {
|
||||
errs = errors.Join(errs, bc.store.RestoreDiscoveryEntry(entry))
|
||||
}
|
||||
|
||||
// Discovery observation refs.
|
||||
for _, ref := range backup.DiscoveryObservationRefs {
|
||||
errs = errors.Join(errs, bc.store.RestoreDiscoveryObservationRef(ref))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,17 +22,19 @@
|
|||
package happydns
|
||||
|
||||
type Backup struct {
|
||||
Version int
|
||||
Domains []*Domain
|
||||
DomainsLogs map[string][]*DomainLog
|
||||
Errors []string
|
||||
Providers []*ProviderMessage
|
||||
Sessions []*Session
|
||||
Users []*User
|
||||
UsersAuth UserAuths
|
||||
Zones []*ZoneMessage
|
||||
CheckerConfigurations []*CheckerOptionsPositional
|
||||
CheckPlans []*CheckPlan
|
||||
CheckEvaluations []*CheckEvaluation
|
||||
Executions []*Execution
|
||||
Version int
|
||||
Domains []*Domain
|
||||
DomainsLogs map[string][]*DomainLog
|
||||
Errors []string
|
||||
Providers []*ProviderMessage
|
||||
Sessions []*Session
|
||||
Users []*User
|
||||
UsersAuth UserAuths
|
||||
Zones []*ZoneMessage
|
||||
CheckerConfigurations []*CheckerOptionsPositional
|
||||
CheckPlans []*CheckPlan
|
||||
CheckEvaluations []*CheckEvaluation
|
||||
Executions []*Execution
|
||||
DiscoveryEntries []*StoredDiscoveryEntry
|
||||
DiscoveryObservationRefs []*DiscoveryObservationRef
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue