File: dump.rst

package info (click to toggle)
groonga 9.0.0-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 101,496 kB
  • sloc: ansic: 608,707; ruby: 35,042; xml: 23,643; cpp: 10,319; sh: 7,453; yacc: 5,968; python: 3,033; makefile: 2,609; perl: 133
file content (241 lines) | stat: -rw-r--r-- 6,244 bytes parent folder | download
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
.. -*- rst -*-

.. highlightlang:: none

.. groonga-command
.. database: commands_dump

``dump``
========

Summary
-------

dump - データベースのスキーマとデータを出力する

Groonga組込コマンドの一つであるdumpについて説明します。組込コマンドは、groonga実行ファイルの引数、標準入力、
またはソケット経由でgroongaサーバにリクエストを送信することによって実行します。

dumpはデータベースのスキーマとデータを後から読み込めるフォーマットで出力します。dumpの結果は大きくなるため、
主にコマンドラインから使うことを想定しています。データベースのバックアップが主な利用方法です。

dumpが出力するフォーマットは直接Groongaが解釈できるフォーマットです。そのため、以下のようにしてデータベースをコピーすることができます。::

  % groonga original/db dump > dump.grn
  % mkdir backup
  % groonga -n backup/db < dump.grn

Syntax
------
::

   dump [tables=null]
        [dump_plugins=yes]
        [dump_schema=yes]
        [dump_records=yes]
        [dump_indexes=yes]
        [dump_configs=yes]
        [sort_hash_table=no]

Usage
-----

Here is the sample schema and data to check dump behaviour::

  plugin_register token_filters/stop_word
  table_create Bookmarks TABLE_HASH_KEY ShortText
  column_create Bookmarks title COLUMN_SCALAR ShortText
  table_create Lexicon TABLE_PAT_KEY ShortText
  table_create Sites TABLE_NO_KEY
  column_create Sites url COLUMN_SCALAR ShortText
  column_create Lexicon bookmark_title COLUMN_INDEX Bookmarks title
  load --table Bookmarks
  [
  {"_key":"Groonga", "title":"Introduction to Groonga"},
  {"_key":"PGroonga", "title":"Introduction to PGroonga"},
  {"_key":"Mroonga", "title":"Introduction to Mroonga"}
  ]
  load --table Sites
  [
  {"_id": 1, "url":"http://groonga.org"},
  {"_id": 2, "url":"http://mroonga.org"}
  ]

Dump all data in database::

  > dump
  plugin_register token_filters/stop_word

  table_create Sites TABLE_NO_KEY
  column_create Sites url COLUMN_SCALAR ShortText

  table_create Bookmarks TABLE_HASH_KEY ShortText
  column_create Bookmarks title COLUMN_SCALAR ShortText

  table_create Lexicon TABLE_PAT_KEY ShortText

  load --table Sites
  [
  ["_id","url"],
  [1,"http://groonga.org"],
  [2,"http://mroonga.org"]
  ]

  load --table Bookmarks
  [
  ["_key","title"],
  ["Groonga","Introduction to Groonga"],
  ["PGroonga","Introduction to PGroonga"],
  ["Mroonga","Introduction to Mroonga"]
  ]

  create Lexicon bookmark_title COLUMN_INDEX Bookmarks title

Dump schema and specific table data::

  > dump Bookmarks
  plugin_register token_filters/stop_word

  table_create Sites TABLE_NO_KEY
  column_create Sites url COLUMN_SCALAR ShortText

  table_create Bookmarks TABLE_HASH_KEY ShortText
  column_create Bookmarks title COLUMN_SCALAR ShortText

  table_create Lexicon TABLE_PAT_KEY ShortText

  load --table Bookmarks
  [
  ["_key","title"],
  ["Groonga","Introduction to Groonga"],
  ["PGroonga","Introduction to PGroonga"],
  ["Mroonga","Introduction to Mroonga"]
  ]

  column_create Lexicon bookmark_title COLUMN_INDEX Bookmarks title

Dump plugin only::

  > dump --dump_schema no --dump_records no --dump_indexes no
  plugin_register token_filters/stop_word

Dump records only::

  > dump --dump_schema no --dump_plugins no --dump_indexes no
  load --table Sites
  [
  ["_id","url"],
  [1,"http://groonga.org"],
  [2,"http://mroonga.org"]
  ]

  load --table Bookmarks
  [
  ["_key","title"],
  ["Groonga","Introduction to Groonga"],
  ["PGroonga","Introduction to PGroonga"],
  ["Mroonga","Introduction to Mroonga"]
  ]

Dump schema only::

  > dump --dump_records no --dump_plugins no --dump_indexes no
  table_create Sites TABLE_NO_KEY
  column_create Sites url COLUMN_SCALAR ShortText

  table_create Bookmarks TABLE_HASH_KEY ShortText
  column_create Bookmarks title COLUMN_SCALAR ShortText

  table_create Lexicon TABLE_PAT_KEY ShortText

Dump sorted hash table data::

  > dump Bookmarks --sort_hash_table yes
  plugin_register token_filters/stop_word

  table_create Sites TABLE_NO_KEY
  column_create Sites url COLUMN_SCALAR ShortText

  table_create Bookmarks TABLE_HASH_KEY ShortText
  column_create Bookmarks title COLUMN_SCALAR ShortText

  table_create Lexicon TABLE_PAT_KEY ShortText

  load --table Bookmarks
  [
  ["_key","title"],
  ["Groonga","Introduction to Groonga"],
  ["Mroonga","Introduction to Mroonga"],
  ["PGroonga","Introduction to PGroonga"]
  ]

  column_create Lexicon bookmark_title COLUMN_INDEX Bookmarks title

Parameters
----------

There are optional parameters.

Optional parameters
^^^^^^^^^^^^^^^^^^^

``tables``
""""""""""

出力対象のテーブルを「,」(カンマ)区切りで指定します。存在しないテーブルを指定した場合は無視されます。

``dump_plugins``
""""""""""""""""

.. versionadded:: 5.0.3

You can customize the output whether it contains registered plugins or not.
To exclude registered plugins from the output, specify ``no``.

The default value is ``yes``.

``dump_schema``
"""""""""""""""

.. versionadded:: 5.0.3

You can customize the output whether it contains database schema or not.
To exclude database schema from the output, specify ``no``.

The default value is ``yes``.

``dump_records``
""""""""""""""""

.. versionadded:: 5.0.3

You can customize the output whether it contains records or not.
To exclude records from the output, specify ``no``.

The default value is ``yes``.

``dump_indexes``
""""""""""""""""

.. versionadded:: 5.0.3

You can customize the output whether it contains indexes or not.
To exclude indexes from the output, specify ``no``.

The default value is ``yes``.

``sort_hash_table``
"""""""""""""""""""

.. versionadded:: 7.0.5

You can ascending sort by ``_key`` the output of hash table when it contains hash table.
To sort the output of hash table, specify ``yes``.

The default value is ``no``.

Return value
------------

データベースのスキーマとデータをGroongaの組み込みコマンド呼び出し形式で出力します。output_type指定は無視されます。