Debian Codegraph @

mysql-test/suite/ndb/t/ndb_restore_schema_subsets.test

raw
1 ######################################################################
2 # Test restoring backups with in- or excluding tables or databases
3 ######################################################################
4
5 -- source include/have_multi_ndb.inc
6 -- source suite/ndb/include/backup_restore_setup.inc
7
8 --echo *************************************
9 --echo Creating various databases and tables
10 --echo *************************************
11 create database db1;
12 create database db2;
13
14 use db1;
15 create table tab1 (a int primary key) engine=ndb;
16 create table tab2 (a int primary key,
17 b varchar(20),
18 c int,
19 d text,
20 unique(c)) engine=ndb;
21 insert into tab1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0);
22 insert into tab2 values (1, "Donnington", 1, repeat("O", 1000)),
23 (2, "Basingstoke", 2, repeat("P", 1000)),
24 (3, "George", 3, repeat("Q", 1000)),
25 (4, "Spottiswoode", 4, repeat("R", 1000)),
26 (5, "Sciennes", 5, repeat("S", 1000)),
27 (6, "Cairns", 6, repeat("T", 1000)),
28 (7, "Highlea", 7, repeat("U", 1000));
29
30 # checksum table tab1;
31 # checksum table tab2;
32 select * from tab1 order by a;
33 select * from tab2 order by a;
34
35 use db2;
36
37 create table tab1 (a int primary key) engine=ndb;
38 create table tab2 (a int primary key, b varchar(20), c int, unique(c), d text) engine=ndb;
39
40 insert into tab1 select * from db1.tab1;
41 insert into tab2 select * from db1.tab2;
42
43 # checksum table tab1;
44 # checksum table tab2;
45 select * from tab1 order by a;
46 select * from tab2 order by a;
47
48 --echo ***********************
49 --echo Backing up created data
50 --echo ***********************
51 --source include/ndb_backup.inc
52
53 drop table db1.tab1, db1.tab2, db2.tab1, db2.tab2;
54
55 # Turn off metadata check so it doesn't intefere with table discovery
56 --connection server2
57 SET @old_ndb_metadata_check_server2 = @@global.ndb_metadata_check;
58 SET GLOBAL ndb_metadata_check = false;
59 --connection server1
60 SET @old_ndb_metadata_check_server1 = @@global.ndb_metadata_check;
61 SET GLOBAL ndb_metadata_check = false;
62
63 --echo **************************************
64 --echo Check various include/exclude variants
65 --echo **************************************
66 --echo Normal full restore
67 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
68 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
69
70 use db1;
71 # checksum table tab1, tab2;
72 select * from tab1 order by a;
73 select * from tab2 order by a;
74
75 use db2;
76 # checksum table tab1, tab2;
77 select * from tab1 order by a;
78 select * from tab2 order by a;
79
80 drop table db1.tab1, db1.tab2, db2.tab1, db2.tab2;
81
82 --echo ****************
83 --echo Include only db2
84 --echo ****************
85 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --include-databases db2>> $NDB_TOOLS_OUTPUT
86 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --include-databases db2 >> $NDB_TOOLS_OUTPUT
87
88 use db1;
89 --error ER_NO_SUCH_TABLE
90 show create table tab1;
91 --error ER_NO_SUCH_TABLE
92 show create table tab2;
93 use db2;
94 # checksum table tab1, tab2;
95 select * from tab1 order by a;
96 select * from tab2 order by a;
97
98 drop table db2.tab1, db2.tab2;
99
100 --echo ****************
101 --echo Exclude only db2
102 --echo ****************
103 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-databases db2>> $NDB_TOOLS_OUTPUT
104 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-databases db2 >> $NDB_TOOLS_OUTPUT
105
106 use db1;
107 # checksum table tab1, tab2;
108 select * from tab1 order by a;
109 select * from tab2 order by a;
110
111 use db2;
112 --error ER_NO_SUCH_TABLE
113 show create table tab1;
114 --error ER_NO_SUCH_TABLE
115 show create table tab2;
116
117 drop table db1.tab1, db1.tab2;
118
119 --echo ************
120 --echo Exclude both
121 --echo ************
122 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-databases db2,db1>> $NDB_TOOLS_OUTPUT
123 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-databases db2,db1 >> $NDB_TOOLS_OUTPUT
124
125 use db1;
126 --error ER_NO_SUCH_TABLE
127 show create table tab1;
128 --error ER_NO_SUCH_TABLE
129 show create table tab2;
130 use db2;
131 --error ER_NO_SUCH_TABLE
132 show create table tab1;
133 --error ER_NO_SUCH_TABLE
134 show create table tab2;
135
136 --echo **********************************
137 --echo Include only db1.tab1 and db2.tab2
138 --echo **********************************
139
140 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT
141 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT
142
143 use db1;
144 --error ER_NO_SUCH_TABLE
145 show create table tab2;
146 # checksum table tab1;
147 select * from tab1 order by a;
148
149 use db2;
150 --error ER_NO_SUCH_TABLE
151 show create table tab1;
152 # checksum table tab2;
153 select * from tab2 order by a;
154
155
156 drop table db1.tab1, db2.tab2;
157
158 --echo *****************************
159 --echo Exclude db1.tab1 and db2.tab2
160 --echo *****************************
161 --echo Should result in db1.tab2 and db2.tab1 being restored
162 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT
163 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1,db2.tab2 >> $NDB_TOOLS_OUTPUT
164
165 use db1;
166 --error ER_NO_SUCH_TABLE
167 show create table tab1;
168 # checksum table tab2;
169 select * from tab2 order by a;
170
171 use db2;
172 --error ER_NO_SUCH_TABLE
173 show create table tab2;
174 # checksum table tab1;
175 select * from tab1 order by a;
176
177 drop table db1.tab2, db2.tab1;
178
179 --echo *********************************
180 --echo Include db1.tab1, but exclude db1
181 --echo *********************************
182
183 --echo Should result in only db1.tab1 being restored
184 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-databases db1 --include-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
185 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-databases db1 --include-tables db1.tab1>> $NDB_TOOLS_OUTPUT
186
187 use db1;
188 --error ER_NO_SUCH_TABLE
189 show create table tab2;
190 # checksum table tab1;
191 select * from tab1 order by a;
192
193 use db2;
194 --error ER_NO_SUCH_TABLE
195 show create table tab1;
196 --error ER_NO_SUCH_TABLE
197 show create table tab2;
198
199 drop table db1.tab1;
200
201 --echo *********************************
202 --echo Exclude db1.tab1, but include db1
203 --echo *********************************
204 --echo Should result in only db1.tab2 being restored
205 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --include-databases db1 --exclude-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
206 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --include-databases db1 --exclude_tables db1.tab1 >> $NDB_TOOLS_OUTPUT
207
208 use db1;
209 --error ER_NO_SUCH_TABLE
210 show create table tab1;
211 # checksum table tab2;
212 select * from tab2 order by a;
213
214 use db2;
215 --error ER_NO_SUCH_TABLE
216 show create table tab1;
217 --error ER_NO_SUCH_TABLE
218 show create table tab2;
219
220 drop table db1.tab2;
221
222 --echo **************************************
223 --echo Exclude db1.tab1, and include db1.tab1
224 --echo **************************************
225 --echo Should result in db1.tab1 only restored.
226 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --include-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
227 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --include-tables db1.tab1 >> $NDB_TOOLS_OUTPUT
228
229 use db1;
230 --error ER_NO_SUCH_TABLE
231 show create table tab2;
232 # checksum table tab1;
233 select * from tab1 order by a;
234
235 use db2;
236 --error ER_NO_SUCH_TABLE
237 show create table tab1;
238 --error ER_NO_SUCH_TABLE
239 show create table tab2;
240
241 drop table db1.tab1;
242
243 --echo ****************************
244 --echo Exclude db2, and include db2
245 --echo ****************************
246 --echo Should result in db2 only restored.
247 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-databases db2 --include-databases db2 >> $NDB_TOOLS_OUTPUT
248 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-databases db2 --include-databases db2 >> $NDB_TOOLS_OUTPUT
249
250 use db1;
251 --error ER_NO_SUCH_TABLE
252 show create table tab1;
253 --error ER_NO_SUCH_TABLE
254 show create table tab2;
255 use db2;
256 # checksum table tab1, tab2;
257 select * from tab1 order by a;
258 select * from tab2 order by a;
259
260 drop table db2.tab1, db2.tab2;
261
262 --echo *********************************
263 --echo Include db1, and include db2.tab1
264 --echo *********************************
265 --echo Should result in all tables in db1 and db2.tab1 being restored.
266 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --include-databases db1 --include-tables db2.tab1 >> $NDB_TOOLS_OUTPUT
267 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --include-databases db1 --include-tables db2.tab1 >> $NDB_TOOLS_OUTPUT
268
269 use db1;
270 show create table tab1;
271 show create table tab2;
272 use db2;
273 --error ER_NO_SUCH_TABLE
274 show create table tab2;
275 # checksum table tab1;
276 select * from tab1 order by a;
277
278 drop table db1.tab1,db1.tab2,db2.tab1;
279
280
281 --echo ************************
282 --echo Include unknown database
283 --echo ************************
284 --echo Should result in nothing restored
285 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --include-databases unhappy_customer >> $NDB_TOOLS_OUTPUT
286 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --include-databases unhappy_customer >> $NDB_TOOLS_OUTPUT
287
288 show databases like "db%";
289 use db1;
290 --error ER_NO_SUCH_TABLE
291 show create table tab1;
292 --error ER_NO_SUCH_TABLE
293 show create table tab2;
294 use db2;
295 --error ER_NO_SUCH_TABLE
296 show create table tab1;
297 --error ER_NO_SUCH_TABLE
298 show create table tab2;
299
300 --echo *********************
301 --echo Exclude unknown table
302 --echo *********************
303 --echo Should result in everything restored
304 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-tables db1.unhappy_customer >> $NDB_TOOLS_OUTPUT
305 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-tables db1.unhappy_customer >> $NDB_TOOLS_OUTPUT
306
307 show databases like "db%";
308
309 use db1;
310 # checksum table tab1, tab2;
311 select * from tab1 order by a;
312 select * from tab2 order by a;
313 use db2;
314 # checksum table tab1, tab2;
315 select * from tab1 order by a;
316 select * from tab2 order by a;
317
318 drop table db1.tab1, db1.tab2;
319 drop table db2.tab1, db2.tab2;
320
321 --echo ************************************
322 --echo Check accumulative include arguments
323 --echo ************************************
324 --echo Should result in both db1.tab1 and db1.tab2 restored.
325 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1 --include-tables db1.tab2 >> $NDB_TOOLS_OUTPUT
326 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --include-tables db1.tab1 --include-tables db1.tab2 >> $NDB_TOOLS_OUTPUT
327
328 use db1;
329 show create table tab1;
330 # checksum table tab2;
331 select * from tab2 order by a;
332
333 use db2;
334 --error ER_NO_SUCH_TABLE
335 show create table tab1;
336 --error ER_NO_SUCH_TABLE
337 show create table tab2;
338
339 drop table db1.tab1, db1.tab2;
340
341 --echo ************************************
342 --echo Check accumulative exclude arguments
343 --echo ************************************
344 --echo Should result in both db2.tab1 and db2.tab2 restored.
345 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r -m $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --exclude-tables db1.tab2 >> $NDB_TOOLS_OUTPUT
346 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id --exclude-tables db1.tab1 --exclude-tables db1.tab2 >> $NDB_TOOLS_OUTPUT
347
348 use db1;
349 --error ER_NO_SUCH_TABLE
350 show create table tab1;
351 --error ER_NO_SUCH_TABLE
352 show create table tab2;
353 use db2;
354 show create table tab1;
355 show create table tab2;
356
357 drop table db2.tab1, db2.tab2;
358
359 drop database db1;
360 drop database db2;
361
362 # Reset metadata check value
363 --connection server2
364 SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check_server2;
365 --connection server1
366 SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check_server1;
367
368 --source suite/ndb/include/backup_restore_cleanup.inc
369 --remove_file $NDB_TOOLS_OUTPUT