| 1 |
source include/have_ndb.inc; |
| 2 |
|
| 3 |
# Use $MYSQLTEST_VARDIR for temporary password files since that is allowed for |
| 4 |
# SELECT INTO DUMPFILE by secure-file-priv. |
| 5 |
let $NDB_PASSWORD_DIR = $MYSQLTEST_VARDIR/tmp; |
| 6 |
|
| 7 |
--echo # backup_password.txt will contain password and os dependent line ending. |
| 8 |
exec echo TOPSECRET > $NDB_PASSWORD_DIR/backup_password.txt; |
| 9 |
|
| 10 |
let $NDB_SAVED_BACKUPS = $MYSQL_TEST_DIR/suite/ndb/backups; |
| 11 |
|
| 12 |
--echo |
| 13 |
--echo # --decrypt-password=SECRET will not be used since input file is not |
| 14 |
--echo # encrypted, but will cause warning. |
| 15 |
--echo # Command will create a file encrypted with password from stdin without |
| 16 |
--echo # line ending. |
| 17 |
exec $NDBXFRM 2>&1 |
| 18 |
--decrypt-password=SECRET |
| 19 |
--encrypt-password-from-stdin < $NDB_PASSWORD_DIR/backup_password.txt |
| 20 |
$NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.ctl |
| 21 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl; |
| 22 |
|
| 23 |
--echo |
| 24 |
--echo # Encrypt also a backup data file - to be able to do restore later |
| 25 |
--echo # With same password given in different way, also compress just for |
| 26 |
--echo # some variation, will show up in ndbxfrm --info later. |
| 27 |
exec $NDBXFRM 2>&1 |
| 28 |
--decrypt-password=SECRET |
| 29 |
--compress |
| 30 |
--encrypt-password=TOPSECRET |
| 31 |
$NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1-0.1.Data |
| 32 |
$MYSQL_TMP_DIR/BACKUP-1-0.1.Data; |
| 33 |
|
| 34 |
--echo |
| 35 |
--echo # Encrypt also a backup log file - to be able to do restore later |
| 36 |
exec $NDBXFRM 2>&1 |
| 37 |
--encrypt-password-from-stdin < $NDB_PASSWORD_DIR/backup_password.txt |
| 38 |
$NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.log |
| 39 |
$MYSQL_TMP_DIR/BACKUP-1.1.log; |
| 40 |
|
| 41 |
--echo |
| 42 |
--echo # Check that new files are encrypted, and old files are not. |
| 43 |
--echo # One can note that of the new files only data file is compressed. |
| 44 |
--echo # Later restore will handle both compressed and uncompressed files. |
| 45 |
replace_result $NDB_SAVED_BACKUPS NDB_SAVED_BACKUPS $MYSQL_TMP_DIR MYSQL_TMP_DIR ; |
| 46 |
exec $NDBXFRM 2>&1 |
| 47 |
--info |
| 48 |
$NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.ctl |
| 49 |
$NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1-0.1.Data |
| 50 |
$NDB_SAVED_BACKUPS/undo_backup/BACKUP-1-PART-1-OF-4/BACKUP-1.1.log |
| 51 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 52 |
$MYSQL_TMP_DIR/BACKUP-1-0.1.Data |
| 53 |
$MYSQL_TMP_DIR/BACKUP-1.1.log; |
| 54 |
|
| 55 |
--echo |
| 56 |
--echo # Verify that ndb_print_backup_file can decrypt file using the TOPSECRET |
| 57 |
--echo # password, given on command line to ensure no line ending. This also |
| 58 |
--echo # verifies that reading password from stdin do not include the line |
| 59 |
--echo # endings in password. |
| 60 |
exec $NDB_PRINT_BACKUP_FILE 2>&1 >> $NDB_TOOLS_OUTPUT |
| 61 |
--backup-password=TOPSECRET |
| 62 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl; |
| 63 |
|
| 64 |
--echo |
| 65 |
--echo # Do restore using the new encrypted files. |
| 66 |
--echo # extra_encrypted_backup.cnf specifies backup-password for ndb_restore, |
| 67 |
--echo # need to skip that for --backup-password not conflict with |
| 68 |
--echo # --backup-password-from-stdin. |
| 69 |
exec $NDB_RESTORE >> $NDB_TOOLS_OUTPUT |
| 70 |
--decrypt |
| 71 |
--backup-password-from-stdin < $NDB_PASSWORD_DIR/backup_password.txt |
| 72 |
--skip-backup-password |
| 73 |
--restore-meta |
| 74 |
--restore-data |
| 75 |
--nodeid=1 |
| 76 |
--backupid=1 |
| 77 |
$MYSQL_TMP_DIR/; |
| 78 |
|
| 79 |
--echo # Trigger sync of created logfile group, tablespace, and, tables to be |
| 80 |
--echo # recognized by MySQL server. |
| 81 |
SET GLOBAL ndb_metadata_sync=ON; |
| 82 |
|
| 83 |
--echo |
| 84 |
--echo # Pass two passwords via stdin. |
| 85 |
--echo # Passing file with one password. |
| 86 |
error 2; |
| 87 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password.txt |
| 88 |
--decrypt-password-from-stdin |
| 89 |
--encrypt-password-from-stdin |
| 90 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 91 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-1; |
| 92 |
|
| 93 |
exec echo TOPSECRET > $NDB_PASSWORD_DIR/backup_password_twice.txt; |
| 94 |
exec echo TOPSECRET-2 >> $NDB_PASSWORD_DIR/backup_password_twice.txt; |
| 95 |
|
| 96 |
--echo |
| 97 |
--echo # Pass two passwords via stdin. |
| 98 |
--echo # Passing file with two passwords. |
| 99 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_twice.txt |
| 100 |
--decrypt-password-from-stdin |
| 101 |
--encrypt-password-from-stdin |
| 102 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 103 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.ENC; |
| 104 |
remove_file $MYSQL_TMP_DIR/BACKUP-1.1.ctl.ENC; |
| 105 |
|
| 106 |
--echo |
| 107 |
--echo # Pass one passwords via stdin. |
| 108 |
--echo # Passing file with one password without any new line character. |
| 109 |
replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; |
| 110 |
eval select "TOPSECRET-NO-NL" into dumpfile "$NDB_PASSWORD_DIR/backup_password_no_nl.txt"; |
| 111 |
error 2; |
| 112 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_no_nl.txt |
| 113 |
--decrypt-password-from-stdin |
| 114 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 115 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-2; |
| 116 |
|
| 117 |
--echo |
| 118 |
--echo # Pass a too long passwords via stdin. |
| 119 |
replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; |
| 120 |
eval select repeat("TOPSECRET", 60) into outfile "$NDB_PASSWORD_DIR/backup_password_long.txt"; |
| 121 |
replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ; |
| 122 |
error 2; |
| 123 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_long.txt |
| 124 |
--decrypt-password-from-stdin |
| 125 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 126 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-3; |
| 127 |
|
| 128 |
--echo |
| 129 |
--echo # Pass a too long passwords via stdin. |
| 130 |
replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; |
| 131 |
eval select repeat("TOPSECRET", 120) into outfile "$NDB_PASSWORD_DIR/backup_password_long2.txt"; |
| 132 |
error 2; |
| 133 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_long2.txt |
| 134 |
--decrypt-password-from-stdin |
| 135 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 136 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-4; |
| 137 |
|
| 138 |
--echo |
| 139 |
--echo # Pass a passwords with control character (ctrl-V) via stdin. |
| 140 |
replace_result $NDB_PASSWORD_DIR NDB_PASSWORD_DIR ; |
| 141 |
eval select char(22) into outfile "$NDB_PASSWORD_DIR/backup_password_ctrl.txt"; |
| 142 |
error 2; |
| 143 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password_ctrl.txt |
| 144 |
--decrypt-password=TOPSECRET |
| 145 |
--encrypt-password-from-stdin |
| 146 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 147 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-5; |
| 148 |
|
| 149 |
--echo |
| 150 |
--echo # Pass wrong passwords |
| 151 |
replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ; |
| 152 |
error 2; |
| 153 |
exec $NDBXFRM 2>&1 < $NDB_PASSWORD_DIR/backup_password.txt |
| 154 |
--decrypt-password=WRONGSECRET |
| 155 |
--encrypt-password-from-stdin |
| 156 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl |
| 157 |
$MYSQL_TMP_DIR/BACKUP-1.1.ctl.NONE-6; |
| 158 |
|
| 159 |
--echo |
| 160 |
--echo # Wait for schema synchronization to finish. |
| 161 |
let $wait_condition = select @@ndb_metadata_sync = 0; |
| 162 |
source include/wait_condition.inc; |
| 163 |
|
| 164 |
--echo |
| 165 |
--echo # Drop tables, tablespace and logfile group created by restore. |
| 166 |
DROP TABLE test . t_gis; |
| 167 |
DROP TABLE test . t_num; |
| 168 |
DROP TABLE test . t_string_1; |
| 169 |
DROP TABLE test . t_string_2; |
| 170 |
DROP TABLE test . t_string_3; |
| 171 |
DROP TABLE test . t_string_4; |
| 172 |
DROP TABLE test . t_string_5; |
| 173 |
DROP TABLE test . t_datetime; |
| 174 |
|
| 175 |
ALTER TABLESPACE ts1 DROP DATAFILE 'datafile.dat'; |
| 176 |
DROP TABLESPACE ts1; |
| 177 |
DROP LOGFILE GROUP lg1 ENGINE NDBCLUSTER; |
| 178 |
|
| 179 |
--echo |
| 180 |
--echo # Test ended, cleanup files. |
| 181 |
remove_file $NDB_PASSWORD_DIR/backup_password.txt; |
| 182 |
remove_file $NDB_PASSWORD_DIR/backup_password_twice.txt; |
| 183 |
remove_file $NDB_PASSWORD_DIR/backup_password_no_nl.txt; |
| 184 |
remove_file $NDB_PASSWORD_DIR/backup_password_long.txt; |
| 185 |
remove_file $NDB_PASSWORD_DIR/backup_password_long2.txt; |
| 186 |
remove_file $NDB_PASSWORD_DIR/backup_password_ctrl.txt; |
| 187 |
remove_file $MYSQL_TMP_DIR/BACKUP-1.1.ctl; |
| 188 |
remove_file $MYSQL_TMP_DIR/BACKUP-1-0.1.Data; |
| 189 |
remove_file $MYSQL_TMP_DIR/BACKUP-1.1.log; |
| 190 |
remove_file $NDB_TOOLS_OUTPUT; |