Giter Site home page Giter Site logo

rustin170506 / br Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pingcap/br

0.0 0.0 0.0 15.35 MB

A command-line tool for distributed backup and restoration of the TiDB cluster data

Home Page: https://pingcap.com/docs/dev/how-to/maintain/backup-and-restore/br/

License: Apache License 2.0

Makefile 0.48% Go 84.20% Shell 12.35% Dockerfile 0.03% Ragel 0.16% HTML 0.02% TypeScript 2.72% JavaScript 0.04%

br's Introduction

BR

Build Status codecov LICENSE Language GoDoc Go Report Card GitHub release GitHub release date

Backup & Restore (BR) is a command-line tool for distributed backup and restoration of the TiDB cluster data.

Architecture

architecture

Documentation

Chinese Document

English Document

Backup SQL Statement

Restore SQL Statement

Building

To build binary and run test:

$ make
$ make test

Notice BR supports building with Go version Go >= 1.16

When BR is built successfully, you can find binary in the bin directory.

Quick start(docker-compose)

# Start TiDB cluster
docker-compose -f docker-compose.yaml rm -s -v && \
docker-compose -f docker-compose.yaml build && \
docker-compose -f docker-compose.yaml up --remove-orphans

# Attach to control container to run BR
docker exec -it br_control_1 bash

# Load testing data to TiDB
go-ycsb load mysql -p workload=core \
    -p mysql.host=tidb -p mysql.port=4000 -p mysql.user=root \
    -p recordcount=100000 -p threadcount=100

# How many rows do we get? 100000 rows.
mysql -uroot -htidb -P4000 -E -e "SELECT COUNT(*) FROM test.usertable"

# Build BR and backup!
make build && \
bin/br backup full --pd pd0:2379 --storage "local:///data/backup/full" \
    --log-file "/logs/br_backup.log"

# Let's drop database.
mysql -uroot -htidb -P4000 -E -e "DROP DATABASE test; SHOW DATABASES;"

# Restore!
bin/br restore full --pd pd0:2379 --storage "local:///data/backup/full" \
    --log-file "/logs/br_restore.log"

# How many rows do we get again? Expected to be 100000 rows.
mysql -uroot -htidb -P4000 -E -e "SELECT COUNT(*) FROM test.usertable"

# Test S3 compatible storage (MinIO).
# Create a bucket to save backup by mc (a MinIO Client).
mc config host add minio $S3_ENDPOINT $MINIO_ACCESS_KEY $MINIO_SECRET_KEY && \
mc mb minio/mybucket

# Backup to S3 compatible storage.
bin/br backup full --pd pd0:2379 --storage "s3://mybucket/full" \
    --s3.endpoint="$S3_ENDPOINT"

# Drop database and restore!
mysql -uroot -htidb -P4000 -E -e "DROP DATABASE test; SHOW DATABASES;" && \
bin/br restore full --pd pd0:2379 --storage "s3://mybucket/full" \
    --s3.endpoint="$S3_ENDPOINT"

Quick Start(tiup)

# Using tiup to start a TiDB cluster
tiup playground --db 2 --pd 3 --kv 3 --monitor

# Using tiup bench to generater test data.
tiup bench tpcc --warehouses 1 prepare

# How many row do we get? 300242 rows.
mysql --host 127.0.0.1 --port 4000 -E -e "SELECT COUNT(*) FROM test.order_line" -u root -p

# Build br.
make build

# Backup TPC-C test data.
bin/br backup table --db test \
	--table order_line \
	-s local:///tmp/backup_test/ \
	--pd ${PD_ADDR}:2379 \
	--log-file backup_test.log \

# Let's drop the table.
mysql -uroot --host 127.0.0.1 -P4000 -E -e "USE test; DROP TABLE order_line; show tables" -u root -p

# Restore from the backup.
bin/br restore table --db test \
	--table order_line \
	-s local:///tmp/backup_test/ \
	--pd ${PD_ADDR}:2379 \
	--log-file restore_test.log

# How many rows do we get after restore? Expected to be 300242 rows.
mysql --host 127.0.0.1 -P4000 -E -e "SELECT COUNT(*) FROM test.order_line" -uroot -p

Compatible test

See COMPATBILE_TEST

Contributing

Contributions are welcomed and greatly appreciated. See CONTRIBUTING for details on submitting patches and the contribution workflow.

License

BR is under the Apache 2.0 license. See the LICENSE file for details.

br's People

Contributors

kennytm avatar glorv avatar overvenus avatar 3pointer avatar yujuncen avatar 5kbpers avatar holys avatar lonng avatar lichunzhu avatar lance6716 avatar silentsai avatar disksing avatar ninglin-p avatar relax4life avatar leavrth avatar andremouche avatar amyangfei avatar huachaohuang avatar ianthereal avatar sleepymole avatar july2993 avatar wangxiangustc avatar tongtongyin avatar jmpotato avatar sunrunaway avatar caitinchen avatar hundundm avatar zhouqiang-cl avatar tangenta avatar lysu avatar

Stargazers

Roman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.