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

[Feature] Support new syntax for Backup/Restore #52746

Open
srlch opened this issue Nov 8, 2024 · 0 comments · May be fixed by #52729
Open

[Feature] Support new syntax for Backup/Restore #52746

srlch opened this issue Nov 8, 2024 · 0 comments · May be fixed by #52729

Comments

@srlch
Copy link
Contributor

srlch commented Nov 8, 2024

Why we need a new syntax for Backup/Restore

  1. The semantic design of the old syntax is not easy to understand and is not user-friendly.
  2. The newly introduced syntax has strong scalability and flexibility to support (multiple) catalog, multiple object type and multiple DBs Backup/Restore.

New syntax design for Backup/Restore

BACKUP [DATABASE <db_name>] SNAPSHOT [<dbname>.]<snapshot_name>
TO <repo_name>
[ ON ( backup_restore_object [, ...] ) ]
[PROPERTIES]

RESTORE SNAPSHOT [<dbname>.]<snapshot_name> FROM <repo_name>
[DATABASE <db_name> [AS <db_alias>] ]
[ ON ( backup_restore_object [, ...] ) ]
[PROPERTIES]

backup_restore_object ::=
    ALL (TABLE | TABLES)            | (TABLE | TABLES) <table_name> [ PARTITION (...) ] [AS <alias>] |
    ALL MATERIALIZED (VIEW | VIEWS) | MATERIALIZED (VIEW | VIEWS) <mv_name> [AS <alias>] |
    ALL (VIEW | VIEWS)              | (VIEW | VIEWS) <view_name> [AS <alias>] |
    ALL (FUNCTION | FUNCTIONS)      | (FUNCTION | FUNCTIONS) <func_name> [AS <alias>] |
    <table_name> [ PARTITION (...) ] [AS <alias>]

The behavioral changes in Backup/Restore syntax

Expansion of ON clause:
We introduce the key word (TABLE(S)/VIEW(S)/MATERIALIZED VIEW(S)/FUNCTION(S)) to identify different type of Backup/Restore object and use ALL to represent all objects of a certain type which is much more clear the before.

Allow to specify database explicitly and separated from snapshot name:
Backup: User can specify database after DATABASE key word or before snapshot name as before.

Restore:

  1. If user does not specify dbname at all (both before snapshot name or after DATABASE keyword) without ON clause, it will create database with the same name in snapshot file and restore all data into it.
  2. If specify dbName after DATABASE keyword, no dbName can be specified before snapshot name.
  3. The dbName after DATABASE keyword must exactly match in snapshot file. DATABASE <db_name> [AS <db_alias>] means that restore the database named by db_name in snapshot to the database named by db_alias in current cluster. If AS is missing, restore to the database with the same name.
@srlch srlch linked a pull request Nov 8, 2024 that will close this issue
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant