From 7da42bbae36a2b49436eaaf9bcca2b6b7f723f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Wed, 2 Oct 2024 12:30:01 +0200 Subject: [PATCH] feat(command/backup): add --transfers flag This commit allows user to control the amount of rclone transfers used during backup. --- docs/source/sctool/partials/sctool_backup.yaml | 4 ++++ docs/source/sctool/partials/sctool_backup_update.yaml | 4 ++++ pkg/command/backup/cmd.go | 6 ++++++ pkg/command/backup/res.yaml | 3 +++ 4 files changed, 17 insertions(+) diff --git a/docs/source/sctool/partials/sctool_backup.yaml b/docs/source/sctool/partials/sctool_backup.yaml index 1da58e4c4..5cba4ef4c 100644 --- a/docs/source/sctool/partials/sctool_backup.yaml +++ b/docs/source/sctool/partials/sctool_backup.yaml @@ -159,6 +159,10 @@ options: usage: | Timezone of --cron and --window flag values. The default value is taken from this system, namely 'TZ' envvar or '/etc/localtime' file. + - name: transfers + default_value: "2" + usage: | + Sets the amount of file transfers to run in parallel when uploading files from a Scylla node to its backup location. - name: upload-parallel default_value: '[]' usage: | diff --git a/docs/source/sctool/partials/sctool_backup_update.yaml b/docs/source/sctool/partials/sctool_backup_update.yaml index 611b60b4a..29ae541b4 100644 --- a/docs/source/sctool/partials/sctool_backup_update.yaml +++ b/docs/source/sctool/partials/sctool_backup_update.yaml @@ -160,6 +160,10 @@ options: usage: | Timezone of --cron and --window flag values. The default value is taken from this system, namely 'TZ' envvar or '/etc/localtime' file. + - name: transfers + default_value: "2" + usage: | + Sets the amount of file transfers to run in parallel when uploading files from a Scylla node to its backup location. - name: upload-parallel default_value: '[]' usage: | diff --git a/pkg/command/backup/cmd.go b/pkg/command/backup/cmd.go index f091e005e..e66216723 100644 --- a/pkg/command/backup/cmd.go +++ b/pkg/command/backup/cmd.go @@ -32,6 +32,7 @@ type command struct { retention int retentionDays int rateLimit []string + transfers int snapshotParallel []string uploadParallel []string dryRun bool @@ -84,6 +85,7 @@ func (cmd *command) init() { w.Unwrap().IntVar(&cmd.retention, "retention", 7, "") w.Unwrap().IntVar(&cmd.retentionDays, "retention-days", 0, "") w.Unwrap().StringSliceVar(&cmd.rateLimit, "rate-limit", nil, "") + w.Unwrap().IntVar(&cmd.transfers, "transfers", 2, "") w.Unwrap().StringSliceVar(&cmd.snapshotParallel, "snapshot-parallel", nil, "") w.Unwrap().StringSliceVar(&cmd.uploadParallel, "upload-parallel", nil, "") w.Unwrap().BoolVar(&cmd.dryRun, "dry-run", false, "") @@ -144,6 +146,10 @@ func (cmd *command) run(args []string) error { props["rate_limit"] = cmd.rateLimit ok = true } + if cmd.Flag("transfers").Changed { + props["transfers"] = cmd.transfers + ok = true + } if cmd.Flag("snapshot-parallel").Changed { props["snapshot_parallel"] = cmd.snapshotParallel ok = true diff --git a/pkg/command/backup/res.yaml b/pkg/command/backup/res.yaml index 92021520b..f6512afa2 100644 --- a/pkg/command/backup/res.yaml +++ b/pkg/command/backup/res.yaml @@ -19,6 +19,9 @@ rate-limit: | The : part is optional and is only needed when different datacenters require different upload limits. Set to 0 for no limit (default 100). +transfers: | + Sets the amount of file transfers to run in parallel when uploading files from a Scylla node to its backup location. + snapshot-parallel: | A comma-separated list of snapshot parallelism limits in the format `[:]`. The ``dc`` part is optional and allows for specifying different limits in selected datacenters.