diff --git a/cmd/k3s/main.go b/cmd/k3s/main.go index c2dfe775cb..bc528cbdaf 100644 --- a/cmd/k3s/main.go +++ b/cmd/k3s/main.go @@ -141,5 +141,16 @@ func extract(dataDir string) (string, error) { return "", err } + currentSymLink := filepath.Join(dataDir, "data", "current") + previousSymLink := filepath.Join(dataDir, "data", "previous") + if _, err := os.Lstat(currentSymLink); err == nil { + if err := os.Rename(currentSymLink, previousSymLink); err != nil { + return "", err + } + } + if err := os.Symlink(dir, currentSymLink); err != nil { + return "", err + } + return dir, os.Rename(tempDest, dir) }