github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_move_backup/run.sh (about) 1 #!/bin/sh 2 # 3 # Copyright 2019 PingCAP, Inc. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -eu 17 DB="$TEST_NAME" 18 TABLE="usertable" 19 20 run_sql "CREATE DATABASE $DB;" 21 22 go-ycsb load mysql -P tests/$TEST_NAME/workload -p mysql.host=$TIDB_IP -p mysql.port=$TIDB_PORT -p mysql.user=root -p mysql.db=$DB 23 24 row_count_ori=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') 25 26 # backup table 27 echo "backup start..." 28 run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB" --db $DB -t $TABLE 29 30 run_sql "DROP TABLE $DB.$TABLE;" 31 32 # change backup path 33 mv $TEST_DIR/$DB $TEST_DIR/another$DB 34 35 # restore table with old path 36 echo "restore with old path start..." 37 run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/$DB" --pd $PD_ADDR || restore_old_fail=1 38 39 if [ "$restore_old_fail" -ne "1" ];then 40 echo "TEST: [$TEST_NAME] test restore with old path failed!" 41 exit 1 42 fi 43 44 # restore table 45 echo "restore start..." 46 run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/another$DB" --pd $PD_ADDR 47 48 row_count_new=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') 49 50 echo "[original] row count: $row_count_ori, [after br] row count: $row_count_new" 51 52 if [ "$row_count_ori" -ne "$row_count_new" ];then 53 echo "TEST: [$TEST_NAME] failed!" 54 exit 1 55 fi 56 57 run_sql "DROP DATABASE $DB;"