-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#20972] YSQL, Backups: Implement new ROLEs related flags
Summary: The following **NEW** `yb_backup.py` flags were implemented: * `--backup_roles` * `--restore_roles` * `--ignore_existing_roles` * `--use_roles` 2 last flags are passed into `ysqlsh -v ignore_existing_roles=true -v use_roles=true ....`. **SEMANTICS**: Backup-create: "--backup_roles" ~ backup Roles Backup-restore: "--restore_roles" ~ restore the stored Roles Backup-restore: "--ignore_existing_roles" ~ do not create the role if it already exists Backup-restore: "--use_roles" ~ use the Roles for the tables via `ALTER TABLE ... OWNER TO <role>` and `REVOKE/GRANT ... ON TABLE ... FROM/TO <role>` syntax. NOTE: The API is changed only when `ENABLE_STOP_ON_YSQL_DUMP_RESTORE_ERROR` is set into `True` (now it's `False`). In the YSQL dump the new logic is implemented: ``` \if :{?ignore_existing_roles} \else \set ignore_existing_roles false \endif \set role_exists false \if :ignore_existing_roles SELECT EXISTS(SELECT 1 FROM pg_roles WHERE rolname = 'role_admin') AS role_exists \gset \endif \if :role_exists \echo 'Role role_admin already exists.' \else CREATE ROLE role_admin; \endif ``` ``` \if :{?use_roles} \else \set use_roles true \endif CREATE TABLE ... \if :use_roles ALTER TABLE t OWNER TO role_admin; \endif \if :use_roles GRANT SELECT ON TABLE t TO role_admin; \endif ``` Jira: DB-9947 Test Plan: Set ENABLE_STOP_ON_YSQL_DUMP_RESTORE_ERROR=True in yb_backup.py. New tests: ybd --java-test org.yb.pgsql.TestYbBackup#testBackupRestoreRoles ybd --java-test org.yb.pgsql.TestYbBackup#testBackupRolesWithoutUseRoles ybd --java-test org.yb.pgsql.TestYbBackup#testBackupRolesWithoutRestoreRoles Other related tests: ybd --java-test org.yb.pgsql.TestYsqlDump#ysqlDumpWithYbMetadata ybd --java-test org.yb.pgsql.TestYsqlDump#ysqlDumpWithoutYbMetadata ybd --java-test org.yb.pgsql.TestYsqlDump#ysqlDumpAllWithoutYbMetadata ybd --java-test org.yb.pgsql.TestYsqlDump#ysqlDumpAllWithYbMetadata ybd --java-test org.yb.pgsql.TestYsqlDump#ysqlDumpLegacyColocatedDB ybd --java-test org.yb.pgsql.TestYsqlDump#ysqlDumpColocatedDB ybd --java-test org.yb.pgsql.TestYbBackup#testExtensionBackupUsingTestExtension ybd --java-test org.yb.pgsql.TestYbBackup#testBackupRestoreTablespaces ybd --java-test org.yb.pgsql.TestYbBackup#testFailureOnExistingTablespaces ybd --java-test org.yb.pgsql.TestYbBackup#testIgnoreExistingTablespaces ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioning ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningNoRegions ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningOneRegion ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningRestoringIntoExisting ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningWithTablespaces ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningNoRegionsWithTablespaces ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningOneRegionWithTablespaces ybd --java-test org.yb.pgsql.TestYbBackup#testGeoPartitioningRestoringIntoExistingWithTablespaces Reviewers: mihnea, tverona, myang, yguan, vkumar, yng Reviewed By: myang Subscribers: yugaware, yql Differential Revision: https://phorge.dev.yugabyte.com/D32252
- Loading branch information
1 parent
e6dca26
commit 5659b73
Showing
9 changed files
with
579 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.