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

feat(1-1-restore): adds 1-1-restore cli and service stub #4221

Open
wants to merge 18 commits into
base: 1-1-restore-feature-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b115ad5
feat(managerclient): adds new task type - fastrestore
VAveryanov8 Jan 20, 2025
ad35965
refactor: renames fastrestore to 1-1-restore
VAveryanov8 Jan 23, 2025
d412522
chore(go.mod): updates to the latest version of pkg/managerclient
VAveryanov8 Jan 29, 2025
e7b9831
feat(fastrestore cli): adds new fastrestore cli to sctool
VAveryanov8 Jan 20, 2025
640729c
feat(scheduler): adds fastrestore support to the task scheduler
VAveryanov8 Jan 20, 2025
fd70ab9
feat(fastrestore): adds fastrestore service stub
VAveryanov8 Jan 20, 2025
239ba40
chore(docs): generates docs for the new cli command
VAveryanov8 Jan 20, 2025
fe216b5
chore: adds empty line, comment here and there
VAveryanov8 Jan 21, 2025
7d7a323
refactor: renames fastrestore to 1-1 restore
VAveryanov8 Jan 23, 2025
28719f5
chore(docs): make docs
VAveryanov8 Jan 23, 2025
04d23e2
chore(docs): updates 1-1-restore command docs
VAveryanov8 Jan 27, 2025
9180b45
chore(comments): explains why seperate check for required args is needed
VAveryanov8 Jan 27, 2025
5ade183
chore(tests): adds golden file helpers for nodemapping tests
VAveryanov8 Jan 27, 2025
24985b1
refactor(1-1-restore): removed not needed options && src-cluster-id i…
VAveryanov8 Jan 29, 2025
7e9f877
chore(docs): make docs
VAveryanov8 Jan 29, 2025
36a3058
chore(go.mod): downgrades some of the deps
VAveryanov8 Jan 30, 2025
595c6e6
refactor(1-1-restore): adds small improvements here and there
VAveryanov8 Feb 3, 2025
cb3cc42
chore(docs): generates docs (make docs)
VAveryanov8 Feb 3, 2025
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
1 change: 1 addition & 0 deletions docs/source/sctool/partials/sctool_restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,5 @@ inherited_options:
If running sctool on the same machine as server, it's generated based on '/etc/scylla-manager/scylla-manager.yaml' file.
see_also:
- sctool - Scylla Manager Snapshot
- sctool restore 1-1-restore - Run an ad-hoc restore of tables to a cluster that mirrors the topology (DCs, racks, nodes structure and tokens) of a backup cluster.
- sctool restore update - Modify properties of the existing restore task
149 changes: 149 additions & 0 deletions docs/source/sctool/partials/sctool_restore_1-1-restore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: sctool restore 1-1-restore
synopsis: |
Run an ad-hoc restore of tables to a cluster that mirrors the topology (DCs, racks, nodes structure and tokens) of a backup cluster.
description: "This command allows you to run ad-hoc restore of tables to a cluster that mirrors the topology of a backup cluster. This means that the target cluster must have \nthe same number of nodes in each datacenter and rack, as well as the same token assignment for each node. \n**Note:** This command only restores the data within the tables. \nYou must first restore the schema of the database separately using the regular restore command with the `--restore-schema` flag.\n"
usage: sctool restore 1-1-restore --cluster <id|name> --location [<dc>:]<provider>:<bucket> --snapshot-tag <tag> [flags] --source-cluster-id <id> --nodes-mapping <filepath>
options:
- name: cluster
shorthand: c
usage: |
The target cluster `name or ID` (envvar SCYLLA_MANAGER_CLUSTER).
- name: cron
usage: |
Task schedule as a cron `expression`.
It supports the extended syntax including @monthly, @weekly, @daily, @midnight, @hourly, @every X[h|m|s].
- name: dry-run
default_value: "false"
usage: |
Validates and displays restore information without actually running the restore.
This allows you to display what will happen should the restore run with the parameters you set.
- name: enabled
default_value: "true"
usage: |
Not enabled tasks are not executed and are hidden from the task list.
- name: help
shorthand: h
default_value: "false"
usage: help for 1-1-restore
- name: interval
shorthand: i
usage: |
--interval is deprecated, please use `--cron` instead


Time after which a successfully completed task would be run again. The supported units are:

* 'd' - days
* 'h' - hours
* 'm' - minutes
* 's' - seconds
* 'ms' - milliseconds

The task run date is aligned with '--start date' value.
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: keyspace
shorthand: K
default_value: '[]'
usage: |+
A list of `glob` patterns separated by a comma used to include or exclude tables.
The patterns match keyspaces and tables, separate the keyspace name from the table name with a dot e.g. 'keyspace,!keyspace.table_prefix_*'.
The following syntax for glob patterns is supported:

* '*' - matches any number of any characters including none
* '?' - matches any single character
* '[abc]' - matches one character given in the bracket
* '[a-z]' - matches one character from the range given in the bracket

Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
usage: |
A list of backup locations separated by a comma, specifies places where restored backup is stored.

The format is `[<dc>:]<provider>:<bucket>`.
The `<dc>` parameter is optional. It allows you to specify the datacenter whose nodes will be used to restore the data
from this location in a multi-dc setting, it must match Scylla nodes datacenter.
By default, all live nodes are used to restore data from specified locations.

Note that specifying datacenters closest to backup locations might reduce download time of restored data.
The supported storage '<provider>'s are 'azure', 'gcs', 's3'.
The `<bucket>` parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used instead of ID.
- name: nodes-mapping
usage: |
Path to a file with source cluster and target cluster nodes mapping. Each line should contain node mapping in the following format <source_dc>:<source_rack>:<source_host_id>=<destination_dc>:<destination_rack>:<destination_host_id>
- name: num-retries
shorthand: r
default_value: "3"
usage: |
Number of times a task reruns following a failure.
- name: retry-wait
default_value: 10m
usage: |
Initial exponential backoff `duration` X[h|m|s].
With --retry-wait 10m task will wait 10 minutes, 20 minutes and 40 minutes after first, second and third consecutire failure.
- name: snapshot-tag
shorthand: T
usage: |
Scylla Manager snapshot tag identifying restored backup.
Snapshot tags can be obtained from backup listing ('./sctool backup list' command - e.g. sm_20060102150405UTC).
- name: source-cluster-id
usage: |
Cluster ID of the backup cluster.
- name: start-date
shorthand: s
usage: |
The date can be expressed relatively to now or as a RFC3339 formatted string.
To run the task in 2 hours use 'now+2h'. The supported units are:

* 'd' - days
* 'h' - hours
* 'm' - minutes
* 's' - seconds
* 'ms' - milliseconds

If you want the task to start at a specified date use RFC3339 formatted string i.e. '2018-01-02T15:04:05-07:00'.
If you want the repair to start immediately, use the value 'now' or skip this flag.
- name: timezone
default_value: UTC
usage: |
Timezone of --cron and --window flag values.
The default value is taken from this system, namely 'TZ' envvar or '/etc/localtime' file.
- name: window
default_value: '[]'
usage: |
A comma-separated list of time markers in a form `[WEEKDAY-]HH:MM`.
WEEKDAY can be written as the whole word or only using the first 3 characters, HH:MM is an hour from 00:00 to 23:59.

* 'MON-00:00,FRI-15:00' - can be executed from Monday to Friday 3PM
* '23:00,06:00' - can be executed every night from 11PM to 6AM
* '23:00,06:00,SAT-00:00,SUN-23:59' - can be executed every night from 11PM to 6AM and all day during the weekend
inherited_options:
- name: api-cert-file
usage: |
File `path` to HTTPS client certificate used to access the Scylla Manager server when client certificate validation is enabled (envvar SCYLLA_MANAGER_API_CERT_FILE).
- name: api-key-file
usage: |
File `path` to HTTPS client key associated with --api-cert-file flag (envvar SCYLLA_MANAGER_API_KEY_FILE).
- name: api-url
default_value: http://127.0.0.1:5080/api/v1
usage: |
Base `URL` of Scylla Manager server (envvar SCYLLA_MANAGER_API_URL).
If running sctool on the same machine as server, it's generated based on '/etc/scylla-manager/scylla-manager.yaml' file.
see_also:
- sctool restore - Run an ad-hoc restore of schema or tables
- sctool restore 1-1-restore update - Modify properties of the existing 1_1_restore task
149 changes: 149 additions & 0 deletions docs/source/sctool/partials/sctool_restore_1-1-restore_update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: sctool restore 1-1-restore update
synopsis: Modify properties of the existing 1_1_restore task
description: |
This command allows you to modify properties of an already existing 1_1_restore task.
If there is one 1_1_restore task the '1_1_restore/task-id' argument is not needed.
usage: sctool restore 1-1-restore update --cluster <id|name> [flags] [<1_1_restore/task-id>]
options:
- name: cluster
shorthand: c
usage: |
The target cluster `name or ID` (envvar SCYLLA_MANAGER_CLUSTER).
- name: cron
usage: |
Task schedule as a cron `expression`.
It supports the extended syntax including @monthly, @weekly, @daily, @midnight, @hourly, @every X[h|m|s].
- name: dry-run
default_value: "false"
usage: |
Validates and displays restore information without actually running the restore.
This allows you to display what will happen should the restore run with the parameters you set.
- name: enabled
default_value: "true"
usage: |
Not enabled tasks are not executed and are hidden from the task list.
- name: help
shorthand: h
default_value: "false"
usage: help for update
- name: interval
shorthand: i
usage: |
--interval is deprecated, please use `--cron` instead


Time after which a successfully completed task would be run again. The supported units are:

* 'd' - days
* 'h' - hours
* 'm' - minutes
* 's' - seconds
* 'ms' - milliseconds

The task run date is aligned with '--start date' value.
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: keyspace
shorthand: K
default_value: '[]'
usage: |+
A list of `glob` patterns separated by a comma used to include or exclude tables.
The patterns match keyspaces and tables, separate the keyspace name from the table name with a dot e.g. 'keyspace,!keyspace.table_prefix_*'.
The following syntax for glob patterns is supported:

* '*' - matches any number of any characters including none
* '?' - matches any single character
* '[abc]' - matches one character given in the bracket
* '[a-z]' - matches one character from the range given in the bracket

Patterns are evaluated from left to right.
If a pattern starts with '!' it unselects items that were selected by previous patterns i.e. 'a?,!aa' selects *ab* but not *aa*.

- name: label
usage: |
A comma-separated list of label modifications. Labels are represented as a key-value store.
Character '=' has a special meaning and cannot be a part of label's key nor value.
A single modification takes form of:
* '<key>=<value>' - sets the label <key> to <value>
* '<key>-' - removes the label

For example, '--label k1=v1,k2-' will set the label 'k1' to 'v1' and will also remove label 'k2'.
- name: location
shorthand: L
default_value: '[]'
usage: |
A list of backup locations separated by a comma, specifies places where restored backup is stored.

The format is `[<dc>:]<provider>:<bucket>`.
The `<dc>` parameter is optional. It allows you to specify the datacenter whose nodes will be used to restore the data
from this location in a multi-dc setting, it must match Scylla nodes datacenter.
By default, all live nodes are used to restore data from specified locations.

Note that specifying datacenters closest to backup locations might reduce download time of restored data.
The supported storage '<provider>'s are 'azure', 'gcs', 's3'.
The `<bucket>` parameter is a bucket name, it must be an alphanumeric string and **may contain a dash and or a dot, but other characters are forbidden**.
- name: name
usage: |
Task name that can be used instead of ID.
- name: nodes-mapping
usage: |
Path to a file with source cluster and target cluster nodes mapping. Each line should contain node mapping in the following format <source_dc>:<source_rack>:<source_host_id>=<destination_dc>:<destination_rack>:<destination_host_id>
- name: num-retries
shorthand: r
default_value: "3"
usage: |
Number of times a task reruns following a failure.
- name: retry-wait
default_value: 10m
usage: |
Initial exponential backoff `duration` X[h|m|s].
With --retry-wait 10m task will wait 10 minutes, 20 minutes and 40 minutes after first, second and third consecutire failure.
- name: snapshot-tag
shorthand: T
usage: |
Scylla Manager snapshot tag identifying restored backup.
Snapshot tags can be obtained from backup listing ('./sctool backup list' command - e.g. sm_20060102150405UTC).
- name: source-cluster-id
usage: |
Cluster ID of the backup cluster.
- name: start-date
shorthand: s
usage: |
The date can be expressed relatively to now or as a RFC3339 formatted string.
To run the task in 2 hours use 'now+2h'. The supported units are:

* 'd' - days
* 'h' - hours
* 'm' - minutes
* 's' - seconds
* 'ms' - milliseconds

If you want the task to start at a specified date use RFC3339 formatted string i.e. '2018-01-02T15:04:05-07:00'.
If you want the repair to start immediately, use the value 'now' or skip this flag.
- name: timezone
default_value: UTC
usage: |
Timezone of --cron and --window flag values.
The default value is taken from this system, namely 'TZ' envvar or '/etc/localtime' file.
- name: window
default_value: '[]'
usage: |
A comma-separated list of time markers in a form `[WEEKDAY-]HH:MM`.
WEEKDAY can be written as the whole word or only using the first 3 characters, HH:MM is an hour from 00:00 to 23:59.

* 'MON-00:00,FRI-15:00' - can be executed from Monday to Friday 3PM
* '23:00,06:00' - can be executed every night from 11PM to 6AM
* '23:00,06:00,SAT-00:00,SUN-23:59' - can be executed every night from 11PM to 6AM and all day during the weekend
inherited_options:
- name: api-cert-file
usage: |
File `path` to HTTPS client certificate used to access the Scylla Manager server when client certificate validation is enabled (envvar SCYLLA_MANAGER_API_CERT_FILE).
- name: api-key-file
usage: |
File `path` to HTTPS client key associated with --api-cert-file flag (envvar SCYLLA_MANAGER_API_KEY_FILE).
- name: api-url
default_value: http://127.0.0.1:5080/api/v1
usage: |
Base `URL` of Scylla Manager server (envvar SCYLLA_MANAGER_API_URL).
If running sctool on the same machine as server, it's generated based on '/etc/scylla-manager/scylla-manager.yaml' file.
see_also:
- sctool restore 1-1-restore - Run an ad-hoc restore of tables to a cluster that mirrors the topology (DCs, racks, nodes structure and tokens) of a backup cluster.
14 changes: 13 additions & 1 deletion docs/source/sctool/restore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ restore update
==============

.. datatemplate:yaml:: partials/sctool_restore_update.yaml
:template: command.tmpl
:template: command.tmpl

1-1-restore
===========

.. datatemplate:yaml:: partials/sctool_restore_1-1-restore.yaml
:template: command.tmpl

1-1-restore update
==================

.. datatemplate:yaml:: partials/sctool_restore_1-1-restore_update.yaml
:template: command.tmpl
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/scylladb/go-reflectx v1.0.1
github.com/scylladb/go-set v1.0.2
github.com/scylladb/gocqlx/v2 v2.8.0
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20250122142320-e1127475cc4c
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20250129134654-ad359657f571
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20250122142320-e1127475cc4c
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20250122142320-e1127475cc4c
github.com/spf13/cobra v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,8 @@ github.com/scylladb/google-api-go-client v0.34.1-patched h1:DW+T0HA+74o6FDr3TFzV
github.com/scylladb/google-api-go-client v0.34.1-patched/go.mod h1:RriRmS2wJXH+2yd9PRTEcR380U9AXmurWwznqVhzsSc=
github.com/scylladb/rclone v1.54.1-0.20240312172628-afe1fd2aa65e h1:lJRphCtu+nKd+mfo8whOTeFkgjMWvk8iCSlqgibKSa8=
github.com/scylladb/rclone v1.54.1-0.20240312172628-afe1fd2aa65e/go.mod h1:JGZp4EvCUK+6AM1Fe1dye5xvihTc/Bk0WnHHSCJOePM=
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20250122142320-e1127475cc4c h1:scmfi5j0Sgl7i3g6tVsu5yhCBlnT/PLN/PYVaY8B+Hc=
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20250122142320-e1127475cc4c/go.mod h1:7+yHDmds+qO/8b0w4xTptCLh/Gr/hXyAjIIZkMj4KHk=
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20250129134654-ad359657f571 h1:oZihHS9xlhRbzOeQeFz0VlsD61mdh+arBfFS8i8YcKQ=
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20250129134654-ad359657f571/go.mod h1:IUo0KL/TTqXUg8ur6sGhAc1jDDF8TBV6LYVTKB2AlIQ=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20250122142320-e1127475cc4c h1:RLgSH0r/TI+Aw1f2bHUqnjVOI+8cOc9eX5Kr73N9Iuc=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20250122142320-e1127475cc4c/go.mod h1:VKqHSrDj9zfgCKilpbdpmqV1TjmSglt/df79eIg6wuI=
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20250122142320-e1127475cc4c h1:1qkWdf5FbOwW3iE712s7mwOFSHaTRf9vlZ1LW+HDmVE=
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/sctool/sctool.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/scylladb/scylla-manager/v3/pkg/command/legacy/task/taskstart"
"github.com/scylladb/scylla-manager/v3/pkg/command/legacy/task/taskstop"
"github.com/scylladb/scylla-manager/v3/pkg/command/legacy/task/taskupdate"
"github.com/scylladb/scylla-manager/v3/pkg/command/one2onerestore"
"github.com/scylladb/scylla-manager/v3/pkg/command/progress"
"github.com/scylladb/scylla-manager/v3/pkg/command/repair"
"github.com/scylladb/scylla-manager/v3/pkg/command/repair/repaircontrol"
Expand Down Expand Up @@ -63,6 +64,7 @@ func buildCommand() *cobra.Command {
)

restoreCmd := restore.NewCommand(&client)
restoreCmd.AddCommand(one2onerestore.NewCommand(&client))

clusterCmd := &cobra.Command{
Use: "cluster",
Expand Down
Loading