Summary:
Need Bootstrap API:
```
yba xcluster needs-full-copy-tables
Check whether source universe tables need full copy before setting up xCluster replication
Usage:
yba xcluster needs-full-copy-tables [flags]
Aliases:
needs-full-copy-tables, needs-full-copy, needs-fullcopy, full-copy, fullcopy, bootstrap, bootstrap-tables
Examples:
yba xcluster needs-full-copy-tables --source-universe-name <source-universe-name> \
--target-universe-name <target-universe-name> \
--table-uuids <uuid-1>,<uuid-2>,<uuid-3>
Flags:
--source-universe-name string [Required] The name of the source universe for the xcluster.
--target-universe-name string [Optional] The name of the target universe for the xcluster. If tables do not exist on the target universe, full copy is required. If not specified, only source table is checked for data.
--table-uuids string [Optional] The IDs/UUIDs of the source universe tables that need to checked for full copy. If left empty, all tables on the source universe will be checked.
-h, --help help for needs-full-copy-tables
Global Flags:
-a, --apiToken string YugabyteDB Anywhere api token.
--config string Config file, defaults to $HOME/.yba-cli.yaml
--debug Use debug mode, same as --logLevel debug.
--disable-color Disable colors in output. (default false)
-H, --host string YugabyteDB Anywhere Host (default "http://localhost:9000")
-l, --logLevel string Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
-o, --output string Select the desired output format. Allowed values: table, json, pretty. (default "table")
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately. (default true)
```
Create xcluster:
```
yba xcluster create
Create an asynchronous replication config in YugabyteDB Anywhere
Usage:
yba xcluster create [flags]
Aliases:
create, add
Examples:
yba xcluster create --name <xcluster-name> \
--source-universe-name <source-universe-name> \
--target-universe-name <target-universe-name> \
--table-uuids <uuid-1>,<uuid-2>,<uuid-3> \
--storage-config-name <storage-config-name>
Flags:
-n, --name string [Required] Name of the xcluster config to create. The name of the replication config cannot contain [SPACE '_' '*' '<' '>' '?' '|' '"' NULL] characters.
--source-universe-name string [Required] The name of the source universe for the xcluster config.
--target-universe-name string [Required] The name of the target universe for the xcluster config.
--table-type string [Optional] Table type. Required when table-uuids is not specified. Allowed values: ysql, ycql
--table-uuids string [Optional] Comma separated list of source universe table IDs/UUIDs. All tables must be of the same type. Run "yba universe table list --name <source-universe-name> --xcluster-supported-only" to check the list of tables that can be added for asynchronous replication. If left empty, all tables of specified table-type will be added for asynchronous replication.
--storage-config-name string [Required] Storage config to be used for taking the backup for replication.
--tables-need-full-copy-uuids string [Optional] Comma separated list of source universe table IDs/UUIDs would be dropped from target universe and replaced with the source universe table. Must be a subset of table-uuids. If left empty, allow-bootstrap is set to true. Run "yba xcluster needs-full-copy-tables --source-universe-name <source-universe-name> --target-universe-name <target-universe-name> --table-uuids <tables-from-table-uuids-flag>" to check the list of tables that need bootstrapping.
--parallelism int [Optional] Number of concurrent commands to run on nodes over SSH via "yb_backup" script. (default 8)
--allow-bootstrap [Optional] Allow backup on whole database when only set of tables require bootstrap. (default false)
--config-type string [Optional] Scope of the xcluster config to create. Allowed values: basic, txn, db. (default "basic")
--dry-run [Optional] Run the pre-checks without actually running the subtasks. (default false)
-h, --help help for create
Global Flags:
-a, --apiToken string YugabyteDB Anywhere api token.
--config string Config file, defaults to $HOME/.yba-cli.yaml
--debug Use debug mode, same as --logLevel debug.
--disable-color Disable colors in output. (default false)
-H, --host string YugabyteDB Anywhere Host (default "http://localhost:9000")
-l, --logLevel string Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
-o, --output string Select the desired output format. Allowed values: table, json, pretty. (default "table")
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately. (default true)
```
Edit xcluster:
```
yba xcluster update
Update an asynchronous replication config in YugabyteDB Anywhere
Usage:
yba xcluster update [flags]
Aliases:
update, edit
Examples:
yba xcluster update --uuid <uuid> \
--add-table-uuids <uuid-1>,<uuid-2>,<uuid-3> \
--storage-config-name <storage-config-name>
Flags:
-u, --uuid string [Required] The uuid of the xcluster to update.
--source-role string [Optional] The role that the source universe should have in the xCluster config. Allowed values: active, standby, unrecognized.
--target-role string [Optional] The role that the target universe should have in the xCluster config. Allowed values: active, standby, unrecognized.
--add-table-uuids string [Optional] Comma separated list of source universe table IDs/UUIDs. All tables must be of the same type. Run "yba universe table list --name <source-universe-name> --xcluster-supported-only" to check the list of tables that can be added for asynchronous replication.
--remove-table-uuids string [Optional] Comma separated list of source universe table IDs/UUIDs. Run "yba xcluster describe --uuid <xcluster-uuid>" to check the list of tables that can be removed from asynchronous replication.
--storage-config-name string [Optional] Storage config to be used for taking the backup for replication. Required when tables require bootstrapping.
--tables-need-full-copy-uuids string [Optional]Comma separated list of source universe table IDs/UUIDs would be dropped from target universe and replaced with the source universe table. Must be a subset of table-uuids. If left empty, allow-bootstrap is set to true. Run "yba xcluster needs-full-copy-tables --source-universe-name <source-universe-name> --target-universe-name <target-universe-name> --table-uuids <tables-from-add-table-uuids-flag>" to check the list of tables that need bootstrapping.
--parallelism int [Optional] Number of concurrent commands to run on nodes over SSH via "yb_backup" script. (default 8)
--allow-bootstrap [Optional] Allow backup on whole database when only set of tables require bootstrap. (default false)
--dry-run [Optional] Run the pre-checks without actually running the subtasks. (default false)
--auto-include-index-tables [Optional] Whether or not YBA should also include all index tables from any provided main tables. (default false)
-h, --help help for update
Global Flags:
-a, --apiToken string YugabyteDB Anywhere api token.
--config string Config file, defaults to $HOME/.yba-cli.yaml
--debug Use debug mode, same as --logLevel debug.
--disable-color Disable colors in output. (default false)
-H, --host string YugabyteDB Anywhere Host (default "http://localhost:9000")
-l, --logLevel string Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
-o, --output string Select the desired output format. Allowed values: table, json, pretty. (default "table")
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately. (default true)
```
Test Plan:
Needbootstrap:
```
yba xcluster needs-full-copy-tables --source-universe-name dkumar-cli --target-universe-name dkumar-cli-1
Table UUID Is Bootstrap Required Reasons
00000005000030008000000000004000 true TABLE_MISSING_ON_TARGET, TABLE_HAS_DATA
c823de57c0cf4b9fb9d8c174b475c3cb true TABLE_HAS_DATA
```
Create cluster
```
yba xcluster create -n test-cli-xcluster --source-universe-name dkumar-cli --target-universe-name dkumar-cli-1 --t
able-uuids "00000005000030008000000000004000" --storage-config-name dkumar-test-s3 --tables-need-bootstrapping-uuids "00000005000030008000000000004000"
Waiting for xcluster test-cli-xcluster to be created
The xcluster config test-cli-xcluster between source universe dkumar-cli (463187ea-edef-4f32-9646-9c786bd5a565) and target universe dkumar-cli-1 (53f55ea7-b856-4025-8f1f-b7c93eb921bc) has been created
Name UUID Source Universe Target Universe Status
test-cli-xcluster 2bae4d94-f201-4204-a1dc-ee7d9dca5086 dkumar-cli(463187ea-edef-4f32-9646-9c786bd5a565) dkumar-cli-1(53f55ea7-b856-4025-8f1f-b7c93eb921bc) Running
````
Edit:
```
yba xcluster update --uuid f62b8a63-eb47-4245-8b4f-2320d4369c26 --remove-table-uuids 00004000000030008000000000004000 --add-table-uuids 00000005000030008000000000004000 --debug --storage-config-name dkumar-test-s3
DEBUG[2025-02-04T06:24:38Z]root.go:168 Using config file: /home/deeptikumar/.yba-cli.yaml
DEBUG[2025-02-04T06:24:38Z]update_xcluster.go:130 Removing tables from XCluster
DEBUG[2025-02-04T06:24:38Z]update_xcluster.go:140 Adding tables to XCluster
DEBUG[2025-02-04T06:24:39Z]update_xcluster.go:179 Updating tables needing bootstrap
DEBUG[2025-02-04T06:24:39Z]update_xcluster.go:199 Updating parallelism
DEBUG[2025-02-04T06:24:39Z]update_xcluster.go:252 Adding storage config for bootstrap
INFO[2025-02-04T06:24:40Z]update_xcluster.go:274 Waiting for xcluster test-cli-xcluster (f62b8a63-eb47-4245-8b4f-2320d4369c26) to be updated
INFO[2025-02-04T06:25:38Z]update_xcluster.go:281 The xcluster config test-cli-xcluster (f62b8a63-eb47-4245-8b4f-2320d4369c26) has been updated
Name UUID Source Universe Target Universe Status
test-cli-xcluster f62b8a63-eb47-4245-8b4f-2320d4369c26 dkumar-cli(463187ea-edef-4f32-9646-9c786bd5a565) dkumar-cli-1(53f55ea7-b856-4025-8f1f-b7c93eb921bc) Running
```
Reviewers: hzare
Reviewed By: hzare
Subscribers: yugaware
Differential Revision: https://phorge.dev.yugabyte.com/D41403