-
Notifications
You must be signed in to change notification settings - Fork 734
docs: view backup restore #15687
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
Closed
Closed
docs: view backup restore #15687
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
99ef8b6
docs: view backup restore
jepett0 9fd5df2
docs build fix
jepett0 b3f84f9
Apply suggestions from code review
jepett0 664788f
indentation in ru and eng bullet points
jepett0 b8d5335
review fixes
jepett0 507e306
docs compilation fixes
jepett0 cd65af0
style fixes
jepett0 4a20634
ru version + minor style fixes in en
jepett0 cbd2e3b
minor fixes
jepett0 fa988a3
fix links
jepett0 1793bfd
fix ru local links
jepett0 b8292da
review fixes
jepett0 48b461c
docs build fix + bullet points punctuation in ru version
jepett0 012aaa5
completely new text
jepett0 350317b
better style in en version
jepett0 3835a92
ru file structure review fixes
jepett0 1ee65f7
new ru version + minor fixes in the en
jepett0 6e68fa8
docs compilation fix
jepett0 d97246f
fix
jepett0 f7eb47b
Apply suggestions from code review
jepett0 84e56a2
объекты схемы, а не просто объекты
jepett0 bd246c6
review fixes
jepett0 04fd185
toc_i fixes
jepett0 198d7bc
articles in en
jepett0 4179550
fix link error
jepett0 4226abd
review fixes
jepett0 47b4ef9
Update ydb/docs/ru/core/reference/ydb-cli/export-import/_includes/fil…
jepett0 0949b69
remove intrigue
jepett0 9f0862b
Update ydb/docs/ru/core/reference/ydb-cli/export-import/_includes/fil…
jepett0 179be64
fix a link in file structure file
jepett0 2d47451
Apply suggestions from code review
blinkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
139 changes: 139 additions & 0 deletions
139
ydb/docs/en/core/reference/ydb-cli/export-import/view-backup.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| # Considerations for restoring views from backups | ||
|
|
||
| During the restoration of [views](../../../concepts/datamodel/view.md) from a backup, the system may automatically adjust the underlying query to ensure object references remain valid. Restored views will reference the restored tables rather than the previously existing tables in the target environment, preserving the relative positioning between views and their referenced objects as they existed at backup time. | ||
|
|
||
| ## Examples | ||
|
|
||
jepett0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### Restoring the database root to the same path | ||
|
|
||
| Let's consider the following scenario: | ||
|
|
||
| 1. A view is created using the following query: | ||
|
|
||
| ```sql | ||
| CREATE VIEW root_view WITH security_invoker = TRUE AS | ||
| SELECT * FROM root_table; | ||
| ``` | ||
|
|
||
| 2. The database is backed up: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path . --output ./my_backup | ||
| ``` | ||
|
|
||
| 3. The database is cleared: | ||
|
|
||
| ```bash | ||
| ydb scheme rmdir --force --recursive . | ||
| ``` | ||
|
|
||
| 4. The database is restored: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path . --input ./my_backup | ||
| ``` | ||
|
|
||
| As the result of the steps described above, the `root_view` view is restored and selects from the `root_table` table: | ||
|
|
||
| ```bash | ||
| ydb sql --script 'SELECT * FROM root_view' --explain | ||
| ``` | ||
|
|
||
| The output of the command includes: `TableFullScan (Table: root_table, ...` | ||
|
|
||
| ### Restoring the database root to a subfolder | ||
|
|
||
| Let's consider the following scenario: | ||
|
|
||
| 1. A view is created using the following query: | ||
|
|
||
| ```sql | ||
| CREATE VIEW my_view WITH security_invoker = TRUE AS | ||
| SELECT * FROM my_table; | ||
| ``` | ||
|
|
||
| 2. The database is backed up: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path . --output ./my_backup | ||
| ``` | ||
|
|
||
| 3. The database is restored to the `a/b/c` subfolder: | ||
|
|
||
| ```bash | ||
| ydb tools restore --path a/b/c --input ./my_backup | ||
| ``` | ||
|
|
||
| As the result of the steps described above, the `a/b/c/my_view` view is restored and selects from the `a/b/c/my_table` table: | ||
|
|
||
| ```bash | ||
| ydb sql --script 'SELECT * FROM `a/b/c/my_view`' --explain | ||
| ``` | ||
|
|
||
| The output of the command includes: `TableFullScan (Table: a/b/c/my_table, ...` | ||
|
|
||
| ### Restoring a subfolder to the database root | ||
|
|
||
| Let's consider the following scenario: | ||
|
|
||
| 1. The steps 1 to 3 of the previous scenario [{#T}](#restoring-the-database-root-to-a-subfolder) are repeated. | ||
| 2. The `a/b/c` subfolder of the database is backed up: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path a/b/c --output ./subfolder_backup | ||
| ``` | ||
|
|
||
| 3. The database is cleared: | ||
|
|
||
| ```bash | ||
| ydb scheme rmdir --force --recursive . | ||
| ``` | ||
|
|
||
| 4. The subfolder backup is restored to the root of the database: | ||
|
|
||
| ```bash | ||
| ydb tools restore --path . --input ./subfolder_backup | ||
| ``` | ||
|
|
||
| As the result of the steps described above, the `my_view` view is restored and selects from the `my_table` table: | ||
|
|
||
| ```bash | ||
| ydb sql --script 'SELECT * FROM my_view' --explain | ||
| ``` | ||
|
|
||
| The output of the command includes: `TableFullScan (Table: my_table, ...` | ||
|
|
||
| ### Restoring the database root to the root of a different database | ||
|
|
||
| Let's consider the following scenario: | ||
|
|
||
| 1. A view is created using the following query: | ||
|
|
||
| ```sql | ||
| CREATE VIEW root_view WITH security_invoker = TRUE AS | ||
| SELECT * FROM root_table; | ||
| ``` | ||
|
|
||
| 2. The database is backed up: | ||
|
|
||
| ```bash | ||
| ydb --endpoint <endpoint> --database /my_database tools dump --path . --output ./my_backup | ||
| ``` | ||
|
|
||
| Note the `--database /my_database` option in the connection string. | ||
|
|
||
| 3. The database backup is restored to a different database: | ||
|
|
||
| ```bash | ||
| ydb --endpoint <endpoint> --database /restored_database tools dump --path . --input ./my_backup | ||
| ``` | ||
|
|
||
| Note the `--database /restored_database` option in the connection string. | ||
|
|
||
| As the result of the steps described above, the `root_view` view is restored and selects from the `root_table` table located in the `/restored_database`: | ||
|
|
||
| ```bash | ||
| ydb --endpoint <endpoint> --database /restored_database sql --script 'SELECT * FROM root_view' --explain | ||
| ``` | ||
|
|
||
| The output of the command includes: `TableFullScan (Table: root_table, ...` | ||
This file contains hidden or 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 hidden or 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
139 changes: 139 additions & 0 deletions
139
ydb/docs/ru/core/reference/ydb-cli/export-import/view-backup.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| # Особенности восстановления представлений из резервных копий | ||
|
|
||
| При восстановлении [представлений](../../../concepts/datamodel/view.md) из резервной копии запрос представления может быть автоматически изменён для сохранения корректности ссылок на объекты схемы. Восстановленные из резервной копии представления будут ссылаться на восстановленные таблицы, а не на ранее существовавшие в целевой базе таблицы. Взаимное расположение представлений и объектов, на которые они ссылаются, сохраняется таким, каким оно было во время создания резервной копии. | ||
|
|
||
| ## Примеры | ||
|
|
||
| ### Восстановление корня базы данных по тому же пути {#example-root-root} | ||
|
|
||
| Рассмотрим следующий сценарий: | ||
|
|
||
| 1. Создаётся представление: | ||
|
|
||
| ```sql | ||
| CREATE VIEW root_view WITH security_invoker = TRUE AS | ||
| SELECT * FROM root_table; | ||
| ``` | ||
|
|
||
| 2. Создаётся резервная копия базы: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path . --output ./my_backup | ||
| ``` | ||
|
|
||
| 3. Выполняется очистка базы данных: | ||
|
|
||
| ```bash | ||
| ydb scheme rmdir --force --recursive . | ||
| ``` | ||
|
|
||
| 4. База данных восстанавливается: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path . --input ./my_backup | ||
| ``` | ||
|
|
||
| В результате описанных выше шагов представление `root_view` восстанавливается и читает из таблицы `root_table`: | ||
|
|
||
| ```bash | ||
| ydb sql --script 'SELECT * FROM root_view' --explain | ||
| ``` | ||
|
|
||
| В выводе выполненной команды отображается: `TableFullScan (Table: root_table, ...` | ||
|
|
||
| ### Восстановление корня базы данных в подпапку {#example-root-subfolder} | ||
|
|
||
| Рассмотрим следующий сценарий: | ||
|
|
||
| 1. Создаётся представление: | ||
|
|
||
jepett0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ```sql | ||
| CREATE VIEW my_view WITH security_invoker = TRUE AS | ||
| SELECT * FROM my_table; | ||
| ``` | ||
|
|
||
| 2. Создаётся резервная копия базы: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path . --output ./my_backup | ||
| ``` | ||
|
|
||
| 3. База данных восстанавливается в подпапку `a/b/c`: | ||
|
|
||
| ```bash | ||
| ydb tools restore --path a/b/c --input ./my_backup | ||
| ``` | ||
|
|
||
| В результате описанных выше шагов представление `a/b/c/my_view` восстанавливается и читает из таблицы `a/b/c/my_table`: | ||
|
|
||
| ```bash | ||
| ydb sql --script 'SELECT * FROM `a/b/c/my_view`' --explain | ||
| ``` | ||
|
|
||
| В выводе выполненной команды отображается: `TableFullScan (Table: a/b/c/my_table, ...` | ||
|
|
||
| ### Восстановление подпапки в корень базы данных {#example-subfolder-root} | ||
|
|
||
| Рассмотрим следующий сценарий: | ||
|
|
||
| 1. Повторяются шаги 1-3 предыдущего сценария [{#T}](#example-root-subfolder). | ||
| 2. Создаётся резервная копия подпапки `a/b/c` базы данных: | ||
|
|
||
| ```bash | ||
| ydb tools dump --path a/b/c --output ./subfolder_backup | ||
| ``` | ||
|
|
||
| 3. Выполняется очистка базы данных: | ||
|
|
||
| ```bash | ||
| ydb scheme rmdir --force --recursive . | ||
| ``` | ||
|
|
||
| 4. Резервная копия подпапки восстанавливается в корень базы данных: | ||
|
|
||
| ```bash | ||
| ydb tools restore --path . --input ./subfolder_backup | ||
| ``` | ||
|
|
||
| В результате описанных выше шагов представление `my_view` восстанавливается и читает из таблицы `my_table`: | ||
|
|
||
| ```bash | ||
| ydb sql --script 'SELECT * FROM my_view' --explain | ||
| ``` | ||
|
|
||
| В выводе выполненной команды отображается: `TableFullScan (Table: my_table, ...` | ||
|
|
||
| ### Восстановление корня базы данных в корень другой базы данных {#example-root-different-root} | ||
|
|
||
| Рассмотрим следующий сценарий: | ||
|
|
||
| 1. Создаётся представление: | ||
|
|
||
| ```sql | ||
| CREATE VIEW root_view WITH security_invoker = TRUE AS | ||
| SELECT * FROM root_table; | ||
| ``` | ||
|
|
||
| 2. Создаётся резервная копия базы: | ||
|
|
||
| ```bash | ||
| ydb --endpoint <endpoint> --database /my_database tools dump --path . --output ./my_backup | ||
| ``` | ||
|
|
||
| Обратите внимание на `--database /my_database` в строке подключения. | ||
|
|
||
| 3. Резервная копия базы данных восстанавливается в другую базу данных: | ||
|
|
||
| ```bash | ||
| ydb --endpoint <endpoint> --database /restored_database tools dump --path . --input ./my_backup | ||
| ``` | ||
|
|
||
| Обратите внимание на `--database /restored_database` в строке подключения. | ||
|
|
||
| В результате описанных выше шагов представление `root_view` восстанавливается и читает из таблицы `root_table`, расположенной в `/restored_database`: | ||
|
|
||
| ```bash | ||
| ydb --endpoint <endpoint> --database /restored_database sql --script 'SELECT * FROM root_view' --explain | ||
| ``` | ||
|
|
||
| В выводе выполненной команды отображается: `TableFullScan (Table: root_table, ...` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.