Debian Codegraph @

doc/source/reference/commands/dump.rst

raw
1 .. -*- rst -*-
2
3 .. groonga-command
4 .. database: commands_dump
5
6 ``dump``
7 ========
8
9 Summary
10 -------
11
12 dump - Output a schema and data of a database.
13
14 We explain about dump that one of built-in command of Groonga.
15 Built-in commands of Groonga execute by sending a request to groonga server via argument of groonga execution file, standard input, and socket.
16
17 The dump command outputs schemas and data of a database as a format that can read from after.
18
19 The dump command mainly uses from a command line. Because a dump result is big.
20 The dump command mainly uses for the backup of databases.
21
22 Groonga can directly understand the format of the dump command. Therefore, we can copy databases as below. ::
23
24 % groonga original/db dump > dump.grn
25 % mkdir backup
26 % groonga -n backup/db < dump.grn
27
28 Syntax
29 ------
30 ::
31
32 dump [tables=null]
33 [dump_plugins=yes]
34 [dump_schema=yes]
35 [dump_records=yes]
36 [dump_indexes=yes]
37 [dump_configs=yes]
38 [sort_hash_table=no]
39
40 Usage
41 -----
42
43 Here is the sample schema and data to check dump behaviour::
44
45 plugin_register token_filters/stop_word
46 table_create Bookmarks TABLE_HASH_KEY ShortText
47 column_create Bookmarks title COLUMN_SCALAR ShortText
48 table_create Lexicon TABLE_PAT_KEY ShortText
49 table_create Sites TABLE_NO_KEY
50 column_create Sites url COLUMN_SCALAR ShortText
51 column_create Lexicon bookmark_title COLUMN_INDEX Bookmarks title
52 load --table Bookmarks
53 [
54 {"_key":"Groonga", "title":"Introduction to Groonga"},
55 {"_key":"PGroonga", "title":"Introduction to PGroonga"},
56 {"_key":"Mroonga", "title":"Introduction to Mroonga"}
57 ]
58 load --table Sites
59 [
60 {"_id": 1, "url":"http://groonga.org"},
61 {"_id": 2, "url":"http://mroonga.org"}
62 ]
63
64 Dump all data in database::
65
66 > dump
67 plugin_register token_filters/stop_word
68
69 table_create Sites TABLE_NO_KEY
70 column_create Sites url COLUMN_SCALAR ShortText
71
72 table_create Bookmarks TABLE_HASH_KEY ShortText
73 column_create Bookmarks title COLUMN_SCALAR ShortText
74
75 table_create Lexicon TABLE_PAT_KEY ShortText
76
77 load --table Sites
78 [
79 ["_id","url"],
80 [1,"http://groonga.org"],
81 [2,"http://mroonga.org"]
82 ]
83
84 load --table Bookmarks
85 [
86 ["_key","title"],
87 ["Groonga","Introduction to Groonga"],
88 ["PGroonga","Introduction to PGroonga"],
89 ["Mroonga","Introduction to Mroonga"]
90 ]
91
92 create Lexicon bookmark_title COLUMN_INDEX Bookmarks title
93
94 Dump schema and specific table data::
95
96 > dump Bookmarks
97 plugin_register token_filters/stop_word
98
99 table_create Sites TABLE_NO_KEY
100 column_create Sites url COLUMN_SCALAR ShortText
101
102 table_create Bookmarks TABLE_HASH_KEY ShortText
103 column_create Bookmarks title COLUMN_SCALAR ShortText
104
105 table_create Lexicon TABLE_PAT_KEY ShortText
106
107 load --table Bookmarks
108 [
109 ["_key","title"],
110 ["Groonga","Introduction to Groonga"],
111 ["PGroonga","Introduction to PGroonga"],
112 ["Mroonga","Introduction to Mroonga"]
113 ]
114
115 column_create Lexicon bookmark_title COLUMN_INDEX Bookmarks title
116
117 Dump plugin only::
118
119 > dump --dump_schema no --dump_records no --dump_indexes no
120 plugin_register token_filters/stop_word
121
122 Dump records only::
123
124 > dump --dump_schema no --dump_plugins no --dump_indexes no
125 load --table Sites
126 [
127 ["_id","url"],
128 [1,"http://groonga.org"],
129 [2,"http://mroonga.org"]
130 ]
131
132 load --table Bookmarks
133 [
134 ["_key","title"],
135 ["Groonga","Introduction to Groonga"],
136 ["PGroonga","Introduction to PGroonga"],
137 ["Mroonga","Introduction to Mroonga"]
138 ]
139
140 Dump schema only::
141
142 > dump --dump_records no --dump_plugins no --dump_indexes no
143 table_create Sites TABLE_NO_KEY
144 column_create Sites url COLUMN_SCALAR ShortText
145
146 table_create Bookmarks TABLE_HASH_KEY ShortText
147 column_create Bookmarks title COLUMN_SCALAR ShortText
148
149 table_create Lexicon TABLE_PAT_KEY ShortText
150
151 Dump sorted hash table data::
152
153 > dump Bookmarks --sort_hash_table yes
154 plugin_register token_filters/stop_word
155
156 table_create Sites TABLE_NO_KEY
157 column_create Sites url COLUMN_SCALAR ShortText
158
159 table_create Bookmarks TABLE_HASH_KEY ShortText
160 column_create Bookmarks title COLUMN_SCALAR ShortText
161
162 table_create Lexicon TABLE_PAT_KEY ShortText
163
164 load --table Bookmarks
165 [
166 ["_key","title"],
167 ["Groonga","Introduction to Groonga"],
168 ["Mroonga","Introduction to Mroonga"],
169 ["PGroonga","Introduction to PGroonga"]
170 ]
171
172 column_create Lexicon bookmark_title COLUMN_INDEX Bookmarks title
173
174 Parameters
175 ----------
176
177 There are optional parameters.
178
179 Optional parameters
180 ^^^^^^^^^^^^^^^^^^^
181
182 ``tables``
183 """"""""""
184
185 出力対象のテーブルを「,」(カンマ)区切りで指定します。存在しないテーブルを指定した場合は無視されます。
186
187 ``dump_plugins``
188 """"""""""""""""
189
190 .. versionadded:: 5.0.3
191
192 You can customize the output whether it contains registered plugins or not.
193 To exclude registered plugins from the output, specify ``no``.
194
195 The default value is ``yes``.
196
197 ``dump_schema``
198 """""""""""""""
199
200 .. versionadded:: 5.0.3
201
202 You can customize the output whether it contains database schema or not.
203 To exclude database schema from the output, specify ``no``.
204
205 The default value is ``yes``.
206
207 ``dump_records``
208 """"""""""""""""
209
210 .. versionadded:: 5.0.3
211
212 You can customize the output whether it contains records or not.
213 To exclude records from the output, specify ``no``.
214
215 The default value is ``yes``.
216
217 ``dump_indexes``
218 """"""""""""""""
219
220 .. versionadded:: 5.0.3
221
222 You can customize the output whether it contains indexes or not.
223 To exclude indexes from the output, specify ``no``.
224
225 The default value is ``yes``.
226
227 ``sort_hash_table``
228 """""""""""""""""""
229
230 .. versionadded:: 7.0.5
231
232 You can ascending sort by ``_key`` the output of hash table when it contains hash table.
233 To sort the output of hash table, specify ``yes``.
234
235 The default value is ``no``.
236
237 Return value
238 ------------
239
240 データベースのスキーマとデータをGroongaの組み込みコマンド呼び出し形式で出力します。output_type指定は無視されます。
241