Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/lib/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lib
import (
"context"
"fmt"
"io"
"os"
"path/filepath"

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down