added backups to help with reboot

This commit is contained in:
0xdcarns
2021-11-03 15:43:10 -04:00
parent 0d8513150e
commit c7ca3c2495
4 changed files with 59 additions and 4 deletions

View File

@@ -5,6 +5,9 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"os/exec"
nodepb "github.com/gravitl/netmaker/grpc"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/netclient/auth"
@@ -16,8 +19,6 @@ import (
"github.com/gravitl/netmaker/netclient/wireguard"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"google.golang.org/grpc"
"log"
"os/exec"
)
// JoinNetwork - helps a client join a network
@@ -185,6 +186,10 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
if err != nil {
return err
}
// attempt to make backup
if err = config.SaveBackup(node.Network); err != nil {
ncutils.Log("failed to make backup, node will not auto restore if config is corrupted")
}
}
ncutils.Log("retrieving peers")