3
0
mirror of https://github.com/kolaente/docker-db-backup.git synced 2026-03-25 05:53:48 +01:00

fix(deps): update module github.com/docker/docker to v28 (#3)

Also updates all affected new types.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: kolaente <k@knt.li>
This commit is contained in:
renovate[bot]
2026-01-07 09:18:44 +01:00
committed by GitHub
parent ce57987ade
commit c1bcc56574
10 changed files with 131 additions and 66 deletions

17
save.go
View File

@@ -7,30 +7,30 @@ import (
"io"
"os"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
)
func runAndSaveCommandInContainer(c *client.Client, container *types.ContainerJSON, command string, args ...string) error {
func runAndSaveCommandInContainer(c *client.Client, ctr *container.InspectResponse, command string, args ...string) error {
ctx := context.Background()
filename := getDumpFilename(container.Name)
filename := getDumpFilename(ctr.Name)
if config.CompressBackups {
filename += ".gz"
}
containerConfig := types.ExecConfig{
execConfig := container.ExecOptions{
AttachStderr: true,
AttachStdout: true,
Cmd: append([]string{command}, args...),
}
r, err := c.ContainerExecCreate(ctx, container.ID, containerConfig)
r, err := c.ContainerExecCreate(ctx, ctr.ID, execConfig)
if err != nil {
return err
}
resp, err := c.ContainerExecAttach(ctx, r.ID, types.ExecStartCheck{})
resp, err := c.ContainerExecAttach(ctx, r.ID, container.ExecStartOptions{})
if err != nil {
return err
}
@@ -59,8 +59,11 @@ func runAndSaveCommandInContainer(c *client.Client, container *types.ContainerJS
}
execInspect, err := c.ContainerExecInspect(ctx, r.ID)
if err != nil {
return err
}
if execInspect.ExitCode != 0 {
return fmt.Errorf("backup from container %s failed with exit code %d", container.Name, execInspect.ExitCode)
return fmt.Errorf("backup from container %s failed with exit code %d", ctr.Name, execInspect.ExitCode)
}
return err
}