diff --git a/internal/lib/restore.go b/internal/lib/restore.go index 8b3f0fa4f7f..374cb683d48 100644 --- a/internal/lib/restore.go +++ b/internal/lib/restore.go @@ -3,6 +3,7 @@ package lib import ( "context" "fmt" + "io" "os" "path/filepath" @@ -87,6 +88,7 @@ func (c *ContainerServer) ContainerRestore( metadata.PodDumpFile, stats.StatsDump, "bind.mounts", + annotations.LogPath, } for _, name := range checkpoint { src := filepath.Join(imageMountPoint, name) @@ -104,6 +106,25 @@ func (c *ContainerServer) ContainerRestore( return "", err } + _, err = os.Stat(filepath.Join(ctr.Dir(), annotations.LogPath)) + if err == nil { + src, err := os.Open(filepath.Join(ctr.Dir(), annotations.LogPath)) + if err != nil { + return "", fmt.Errorf("error opening log file %q: %w", annotations.LogPath, err) + } + defer src.Close() + destLogPath := ctrSpec.Config.Annotations[annotations.LogPath] + destLog, err := os.Create(destLogPath) + if err != nil { + return "", fmt.Errorf("error opening log file %q: %w", destLogPath, err) + } + defer destLog.Close() + _, err = io.Copy(destLog, src) + if err != nil { + return "", fmt.Errorf("copying log file to %q failed: %w", destLogPath, err) + } + } + _, err = os.Stat(filepath.Join(ctr.Dir(), "bind.mounts")) if err == nil { // If the file does not exist we assume it is an older checkpoint archive