Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flag to skip file errors during copy #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
19 changes: 10 additions & 9 deletions cmd/kube-tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ func NewRootCmd(args []string) *cobra.Command {
}

type simpleBackupCmd struct {
namespace string
selector string
container string
path string
dst string
parallel int
tag string
bufferSize float64
namespace string
selector string
container string
path string
dst string
parallel int
tag string
bufferSize float64
skipErrorFiles bool

out io.Writer
}
Expand All @@ -58,7 +59,7 @@ func NewSimpleBackupCmd(out io.Writer) *cobra.Command {
Short: "Backup files to cloud storage",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if _, err := kubetasks.SimpleBackup(b.namespace, b.selector, b.container, b.path, b.dst, b.parallel, b.tag, b.bufferSize); err != nil {
if _, err := kubetasks.SimpleBackup(b.namespace, b.selector, b.container, b.path, b.dst, b.parallel, b.tag, b.bufferSize, b.skipErrorFiles); err != nil {
log.Fatal(err)
}
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubetasks/kubetasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// SimpleBackup performs backup
func SimpleBackup(namespace, selector, container, path, dst string, parallel int, tag string, bufferSize float64) (string, error) {
func SimpleBackup(namespace, selector, container, path, dst string, parallel int, tag string, bufferSize float64, skipErrorFiles bool) (string, error) {
log.Println("Backup started!")
dstPrefix, dstPath := utils.SplitInTwo(dst, "://")
dstPath = filepath.Join(dstPath, tag)
Expand Down Expand Up @@ -41,7 +41,7 @@ func SimpleBackup(namespace, selector, container, path, dst string, parallel int
}

log.Println("Starting files copy to tag: " + tag)
if err := skbn.PerformCopy(k8sClient, dstClient, "k8s", dstPrefix, fromToPathsAllPods, parallel, bufferSize); err != nil {
if err := skbn.PerformCopy(k8sClient, dstClient, "k8s", dstPrefix, fromToPathsAllPods, parallel, bufferSize, skipErrorFiles); err != nil {
return "", err
}

Expand Down