Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/go-connections/nat"
"github.com/kennygrant/sanitize"
"github.com/spf13/cobra"
)

// Backup is used to gather all of a container's metadata, so we can encode it
// as JSON and store it
type Backup struct {
Config *container.Config
PortMap nat.PortMap
Mounts []types.MountPoint
Config *container.Config
Mounts []types.MountPoint
HostConfig *container.HostConfig
}

var (
Expand Down Expand Up @@ -156,9 +155,9 @@ func backup(ID string) error {

paths = []string{}
backup := Backup{
PortMap: conf.HostConfig.PortBindings,
Config: conf.Config,
Mounts: conf.Mounts,
Config: conf.Config,
HostConfig: conf.HostConfig,
Mounts: conf.Mounts,
}

filename := sanitize.Path(fmt.Sprintf("%s-%s", conf.Config.Image, ID))
Expand Down
5 changes: 1 addition & 4 deletions restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -173,9 +172,7 @@ func createContainer(backup Backup) (string, error) {
}
// io.Copy(os.Stdout, reader)

resp, err := cli.ContainerCreate(ctx, backup.Config, &container.HostConfig{
PortBindings: backup.PortMap,
}, nil, "")
resp, err := cli.ContainerCreate(ctx, backup.Config, backup.HostConfig, nil, "")
if err != nil {
return "", err
}
Expand Down