github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_backup_empty/run.sh (about) 1 #!/bin/sh 2 # 3 # Copyright 2020 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 19 # backup empty. 20 echo "backup start..." 21 run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/empty_db" 22 if [ $? -ne 0 ]; then 23 echo "TEST: [$TEST_NAME] failed on backup empty cluster!" 24 exit 1 25 fi 26 27 # restore empty. 28 echo "restore start..." 29 run_br restore full -s "local://$TEST_DIR/empty_db" --pd $PD_ADDR --ratelimit 1024 30 if [ $? -ne 0 ]; then 31 echo "TEST: [$TEST_NAME] failed on restore empty cluster!" 32 exit 1 33 fi 34 35 # backup and restore empty tables. 36 run_sql "CREATE DATABASE $DB;" 37 run_sql "CREATE TABLE $DB.usertable1 ( \ 38 YCSB_KEY varchar(64) NOT NULL, \ 39 FIELD0 varchar(1) DEFAULT NULL, \ 40 PRIMARY KEY (YCSB_KEY) \ 41 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" 42 43 echo "backup start..." 44 run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/empty_table" 45 46 run_sql "DROP DATABASE $DB;" 47 echo "restore start..." 48 run_br --pd $PD_ADDR restore full -s "local://$TEST_DIR/empty_table" 49 50 # insert one row to make sure table is restored. 51 run_sql "INSERT INTO $DB.usertable1 VALUES (\"a\", \"b\");" 52 53 run_sql "DROP DATABASE $DB"