/
restore-snapshot.rst
208 lines (145 loc) · 6.31 KB
/
restore-snapshot.rst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
.. highlight:: psql
.. _sql-restore-snapshot:
====================
``RESTORE SNAPSHOT``
====================
Restore a snapshot into the cluster.
.. rubric:: Table of contents
.. contents::
:local:
.. _sql-restore-snapshot-synopsis:
Synopsis
========
::
RESTORE SNAPSHOT repository_name.snapshot_name
{ ALL |
METADATA |
TABLE table_ident [ PARTITION (partition_column = value [, ...])] [, ...] |
data_section [, ...] }
[ WITH (restore_parameter [= value], [, ...]) ]
where ``data_section``::
{ TABLES |
VIEWS |
USERS | -- Deprecated, use USERMANAGEMENT instead
PRIVILEGES | -- Deprecated, use USERMANAGEMENT instead
USERMANAGEMENT |
ANALYZERS |
UDFS }
.. _sql-restore-snapshot-description:
Description
===========
Restore one or more tables, partitions, or metadata from an existing snapshot
into the cluster. The snapshot must be given as fully qualified reference with
``repository_name`` and ``snapshot_name``.
To restore everything, use the ``ALL`` keyword.
Single tables (or table partitions) can be restored by using ``TABLE`` together
with a ``table_ident`` and a optional partition reference given the
``partition_column`` values.
It is possible to restore all tables using the ``TABLES`` keyword. This will
restore all tables but will not restore metadata.
To restore only the metadata (including views, users, roles, privileges,
analyzers, user-defined-functions, and all cluster settings), instead use the
``METADATA`` keyword.
A single metadata group can be restored by using the related ``data_section``
keyword.
Additionally, multiple ``data_section`` keywords can be used to restore
multiple concrete sections at once.
To cancel a restore operation simply drop the tables that are being restored.
.. CAUTION::
If you try to restore a table that already exists, CrateDB will return an
error. However, if you try to restore metadata or cluster settings that
already exist, they will be overwritten.
.. _sql-restore-snapshot-parameters:
Parameters
==========
:repository_name:
The name of the repository of the snapshot to restore as ident.
:snapshot_name:
The name of the snapshot as ident.
:table_ident:
The name (optionally schema-qualified) of an existing table that is to be
restored from the snapshot.
:data_section:
The section name of the data to be restored. Multiple sections can be
selected. A section cannot be combined with the ``ALL``, ``METADATA``, or
``TABLE`` keywords.
.. _sql-restore-snapshot-clauses:
Clauses
=======
.. _sql-restore-snapshot-partition:
``PARTITION``
-------------
.. EDITORIAL NOTE
##############
Multiple files (in this directory) use the same standard text for
documenting the ``PARTITION`` clause. (Minor verb changes are made to
accomodate the specifics of the parent statement.)
For consistency, if you make changes here, please be sure to make a
corresponding change to the other files.
If the table is :ref:`partitioned <partitioned-tables>`, the optional
``PARTITION`` clause can be used to restore a snapshot from one partition
exclusively.
::
[ PARTITION ( partition_column = value [, ...] ) ]
:partition_column:
Column name used for table partitioning.
:value:
The respective column value.
All :ref:`partition columns <gloss-partition-column>` (specified by the
:ref:`sql-create-table-partitioned-by` clause) must be listed inside the
parentheses in the order matching the ``PARTITION BY`` definition along with
their respective values using the ``partition_column = value`` syntax (separated
by commas).
Because each partition corresponds to a unique set of :ref:`partition column
<gloss-partition-column>` row values, this clause uniquely identifies a single
partition to restore.
.. TIP::
The :ref:`ref-show-create-table` statement will show you the complete list
of partition columns specified by the
:ref:`sql-create-table-partitioned-by` clause.
.. _sql-restore-snapshot-with:
``WITH``
--------
::
[ WITH (restore_parameter [= value], [, ...]) ]
The following configuration parameters can be used to modify how the snapshot
is restored to the cluster:
:ignore_unavailable:
(Default ``false``) Per default the restore command fails if a table
is given that does not exist in the snapshot. If set to ``true`` those
missing tables are ignored.
:wait_for_completion:
(Default: ``false``) By default the request returns once the restore
operation started. If set to ``true`` the request returns after all
selected tables from the snapshot are restored or an error occurred.
In order to monitor the restore operation the * :ref:`sys.shards
<sys-shards>` table can be queried.
:schema_rename_pattern:
(Default ``(.+)``) Regular expression matching schemas of restored tables.
Used to restore table into a different schema. Capture groups ``()`` can be
used to reuse portions of the table schema and then used in
``schema_rename_replacement``. Default value matches the entire schema name.
:schema_rename_replacement:
(Default ``$1``) Replacement pattern used to restore table into a different
schema. Can include groups, captured in ``schema_rename_pattern``. By default
no replacement is happening and tables are restored into their original
schemas.
Example: ``prefix_$1`` combined with default ``schema_rename_pattern`` adds
'prefix' to all restored table schemas.
Example: ``target`` combined with default ``schema_rename_pattern``
restores all tables into the ``target`` schema.
:table_rename_pattern:
(Default ``(.+)``) Regular expression matching names of restored tables.
Used to rename tables on restoring. Capture groups ``()`` can be used to
reuse portions of the table name and then used in
``table_rename_replacement``. Default value matches the entire table name.
:table_rename_replacement:
(Default ``$1``) Replacement pattern used to rename tables on restoring.
Can include groups, captured in ``table_rename_pattern``. By default no
replacement is happening and tables are restored with their original names.
Example: ``prefix_$1`` combined with default ``table_rename_pattern`` adds
'prefix' to all restored table names.
.. CAUTION::
Restore will abort with a failure if there is a name collision after
evaluating the rename operations, or if a table with the same name as the
rename target already exists.