github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/compatibility/prepare_backup.sh (about)

     1  #!/bin/bash
     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 -eux
    17  
    18  . compatibility/get_last_tags.sh
    19  
    20  TAGS="v5.0.0"
    21  getLatestTags
    22  echo "recent version of cluster is $TAGS"
    23  
    24  i=0
    25  
    26  runBackup() {
    27    # generate backup data in /tmp/br/docker/backup_data/$TAG/, we can do restore after all data backuped later.
    28    echo "build $1 cluster"
    29    TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml build
    30    TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml up -d
    31    trap "TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml down" EXIT
    32    # wait for cluster ready
    33    sleep 20
    34    # prepare SQL data
    35    TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml exec -T control /go/bin/go-ycsb load mysql -P /prepare_data/workload -p mysql.host=tidb -p mysql.port=4000 -p mysql.user=root -p mysql.db=test
    36    TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml exec -T control make compatibility_test_prepare
    37  }
    38  
    39  for tag in $TAGS; do
    40     i=$(( i + 1 ))
    41     runBackup $tag $i &
    42  done
    43  
    44  wait
    45  
    46  echo "prepare backup data successfully"