Skip to content

Commit

Permalink
Check if the k0s version has the ability to take/restore backups (#153)
Browse files Browse the repository at this point in the history
* Check if k0s version has the ability to take/restore backups

* Fix
  • Loading branch information
kke committed Jun 17, 2021
1 parent f51a48d commit cebe904
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions phase/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (p *Backup) Prepare(config *config.Cluster) error {
if leader.Metadata.K0sRunningVersion == "" {
return fmt.Errorf("failed to find a running controller")
}

if leader.Exec(leader.Configurer.K0sCmdf("backup --help")) != nil {
return fmt.Errorf("the version of k0s on the host does not support taking backups")
}

p.leader = leader
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions phase/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func (p *Restore) Prepare(config *config.Cluster) error {
log.Debugf("restore from: %s", p.RestoreFrom)
p.Config = config
p.leader = p.Config.Spec.K0sLeader()

if p.RestoreFrom != "" && p.leader.Exec(p.leader.Configurer.K0sCmdf("restore --help")) != nil {
return fmt.Errorf("the version of k0s on the host does not support restoring backups")
}

log.Debugf("restore leader: %s", p.leader)
log.Debugf("restore leader state: %+v", p.leader.Metadata)
return nil
Expand Down

0 comments on commit cebe904

Please sign in to comment.