File: ndb_restore_schema_subsets.test

package info (click to toggle)
percona-xtrabackup 2.2.3-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 293,260 kB
  • ctags: 146,881
  • sloc: cpp: 1,051,960; ansic: 570,217; java: 54,595; perl: 53,495; pascal: 44,194; sh: 27,826; yacc: 15,314; python: 12,142; xml: 7,848; sql: 4,125; makefile: 1,459; awk: 785; lex: 758
file content (350 lines) | stat: -rw-r--r-- 11,236 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
######################################################################
# Test restoring backups with in- or excluding tables or databases
######################################################################

-- source include/have_ndb.inc
-- source include/ndb_default_cluster.inc

--echo *************************************
--echo Creating various databases and tables
--echo *************************************
create database db1;
create database db2;

use db1;
create table tab1 (a int primary key) engine=ndb;
create table tab2 (a int primary key,
        b varchar(20),
        c int,
        d text,
        unique(c)) engine=ndb;
insert into tab1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0);
insert into tab2 values (1, "Donnington", 1, repeat("O", 1000)),
(2, "Basingstoke", 2, repeat("P", 1000)),
(3, "George", 3, repeat("Q", 1000)),
(4, "Spottiswoode", 4, repeat("R", 1000)),
(5, "Sciennes", 5, repeat("S", 1000)),
(6, "Cairns", 6, repeat("T", 1000)),
(7, "Highlea", 7, repeat("U", 1000));

# checksum table tab1;
# checksum table tab2;
select * from tab1 order by a;
select * from tab2 order by a;

use db2;

create table tab1 (a int primary key) engine=ndb;
create table tab2 (a int primary key, b varchar(20), c int, unique(c), d text) engine=ndb;

insert into tab1 select * from db1.tab1;
insert into tab2 select * from db1.tab2;

# checksum table tab1;
# checksum table tab2;
select * from tab1 order by a;
select * from tab2 order by a;

--echo ***********************
--echo Backing up created data
--echo ***********************
--source include/ndb_backup.inc

drop table db1.tab1, db1.tab2, db2.tab1, db2.tab2;

--echo **************************************
--echo Check various include/exclude variants
--echo **************************************
--echo Normal full restore
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT

use db1;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;

use db2;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;

drop table db1.tab1, db1.tab2, db2.tab1, db2.tab2;

--echo ****************
--echo Include only db2
--echo ****************
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --include-databases db2>> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --include-databases db2 >> $NDB_TOOLS_OUTPUT

use db1;
--sorted_result
show tables;
use db2;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;

drop table db2.tab1, db2.tab2;

--echo ****************
--echo Exclude only db2
--echo ****************
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-databases db2>> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-databases db2 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;

use db2;
--sorted_result
show tables;

drop table db1.tab1, db1.tab2;

--echo ************
--echo Exclude both
--echo ************
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-databases db2,db1>> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-databases db2,db1 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
use db2;
--sorted_result
show tables;

--echo **********************************
--echo Include only db1.tab1 and db2.tab2
--echo **********************************

--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
# checksum table tab1;
select * from tab1 order by a;

use db2;
--sorted_result
show tables;
# checksum table tab2;
select * from tab2 order by a;


drop table db1.tab1, db2.tab2;

--echo *****************************
--echo Exclude db1.tab1 and db2.tab2
--echo *****************************
--echo Should result in db1.tab2 and db2.tab1 being restored
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
# checksum table tab2;
select * from tab2 order by a;

use db2;
--sorted_result
show tables;
# checksum table tab1;
select * from tab1 order by a;

drop table db1.tab2, db2.tab1;

--echo *********************************
--echo Include db1.tab1, but exclude db1
--echo *********************************

--echo Should result in only db1.tab1 being restored
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-databases db1 --include-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id  --exclude-databases db1 --include-tables db1.tab1>> $NDB_TOOLS_OUTPUT

use db1;
--sorted_result
show tables;
# checksum table tab1;
select * from tab1 order by a;

use db2;
--sorted_result
show tables;

drop table db1.tab1;

--echo *********************************
--echo Exclude db1.tab1, but include db1
--echo *********************************
--echo Should result in only db1.tab2 being restored
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id  --include-databases db1 --exclude-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id  --include-databases db1 --exclude_tables db1.tab1 >> $NDB_TOOLS_OUTPUT

use db1;
--sorted_result
show tables;
# checksum table tab2;
select * from tab2 order by a;

use db2;
--sorted_result
show tables;

drop table db1.tab2;

--echo **************************************
--echo Exclude db1.tab1, and include db1.tab1
--echo **************************************
--echo Should result in db1.tab1 only restored.
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --include-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --include-tables db1.tab1 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
# checksum table tab1;
select * from tab1 order by a;

use db2;
--sorted_result
show tables;

drop table db1.tab1;

--echo ****************************
--echo Exclude db2, and include db2
--echo ****************************
--echo Should result in db2 only restored.
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-databases db2 --include-databases db2 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-databases db2 --include-databases db2 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
use db2;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;

drop table db2.tab1, db2.tab2;

--echo *********************************
--echo Include db1, and include db2.tab1
--echo *********************************
--echo Should result in all tables in db1 and db2.tab1 being restored.
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --include-databases db1 --include-tables db2.tab1 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --include-databases db1 --include-tables db2.tab1 >> $NDB_TOOLS_OUTPUT


use db1;
--sorted_result
show tables;
use db2;
--sorted_result
show tables;
# checksum table tab1;
select * from tab1 order by a;

drop table db1.tab1,db1.tab2,db2.tab1;


--echo ************************
--echo Include unknown database
--echo ************************
--echo Should result in nothing restored
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --include-databases unhappy_customer >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --include-databases unhappy_customer >> $NDB_TOOLS_OUTPUT

show databases like "db%";
use db1;
--sorted_result
show tables;
use db2;
--sorted_result
show tables;

--echo *********************
--echo Exclude unknown table
--echo *********************
--echo Should result in everything restored
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-tables db1.unhappy_customer >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-tables db1.unhappy_customer >> $NDB_TOOLS_OUTPUT

show databases like "db%";

use db1;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;
use db2;
--sorted_result
show tables;
# checksum table tab1, tab2;
select * from tab1 order by a;
select * from tab2 order by a;

drop table db1.tab1, db1.tab2;
drop table db2.tab1, db2.tab2;

--echo ************************************
--echo Check accumulative include arguments
--echo ************************************
--echo Should result in both db1.tab1 and db1.tab2 restored.
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1 --include-tables db1.tab2 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1 --include-tables db1.tab2 >> $NDB_TOOLS_OUTPUT

use db1;
--sorted_result
show tables;
# checksum table tab2;
select * from tab2 order by a;

use db2;
--sorted_result
show tables;

drop table db1.tab1, db1.tab2;

--echo ************************************
--echo Check accumulative exclude arguments
--echo ************************************
--echo Should result in both db2.tab1 and db2.tab2 restored.
--exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -r -m  $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --exclude-tables db1.tab2 >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE  --no-defaults -b $the_backup_id -n 2 -r     $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --exclude-tables db1.tab2 >> $NDB_TOOLS_OUTPUT

use db1;
--sorted_result
show tables;
use db2;
--sorted_result
show tables;

drop table db2.tab1, db2.tab2;

drop database db1;
drop database db2;