Skip to content

Commit

Permalink
use tidb-lightning in restore instead of loader (#2068)
Browse files Browse the repository at this point in the history
* use tidb-lightning

* Update restore.go

* Update cmd/backup-manager/app/import/restore.go

Co-Authored-By: DanielZhangQD <[email protected]>

* Update images/tidb-backup-manager/Dockerfile

Co-Authored-By: DanielZhangQD <[email protected]>

Co-authored-by: DanielZhangQD <[email protected]>
Co-authored-by: pingcap-github-bot <[email protected]>
  • Loading branch information
3 people authored Mar 31, 2020
1 parent d8b0e11 commit c5efed5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cmd/backup-manager/app/import/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ func (ro *Options) loadTidbClusterData(restorePath string) error {
return fmt.Errorf("dir %s does not exist or is not a dir", restorePath)
}
args := []string{
fmt.Sprintf("-d=%s", restorePath),
fmt.Sprintf("-h=%s", ro.Host),
fmt.Sprintf("-P=%d", ro.Port),
fmt.Sprintf("-u=%s", ro.User),
fmt.Sprintf("-p=%s", ro.Password),
"--status-addr=0.0.0.0:8289",
"--backend=tidb",
"--server-mode=false",
"–-log-file=",
fmt.Sprintf("--tidb-user=%s", ro.User),
fmt.Sprintf("--tidb-password=%s", ro.Password),
fmt.Sprintf("--tidb-host=%s", ro.Host),
fmt.Sprintf("--d=%s", restorePath),
}

output, err := exec.Command("/loader", args...).CombinedOutput()
output, err := exec.Command("/tidb-lightning", args...).CombinedOutput()
if err != nil {
return fmt.Errorf("cluster %s, execute loader command %v failed, output: %s, err: %v", ro, args, string(output), err)
}
Expand Down
11 changes: 11 additions & 0 deletions images/tidb-backup-manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM pingcap/tidb-enterprise-tools:latest
ARG VERSION=v1.51.0
ARG SHUSH_VERSION=v1.4.0
ARG TOOLKIT_VERSION=v3.0.12
RUN apk update && apk add ca-certificates

RUN wget -nv https://github.com/ncw/rclone/releases/download/${VERSION}/rclone-${VERSION}-linux-amd64.zip \
Expand All @@ -19,7 +20,17 @@ RUN wget -nv https://github.com/realestate-com-au/shush/releases/download/${SHUS
&& mv shush_linux_amd64 /usr/local/bin/shush \
&& chmod 755 /usr/local/bin/shush

RUN \
wget -nv https://download.pingcap.org/tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64.tar.gz \
&& tar -xzf tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64.tar.gz \
&& mv tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64/bin/tidb-lightning /tidb-lightning \
&& mv tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64/bin/tidb-lightning-ctl /tidb-lightning-ctl \
&& chmod 755 /tidb-lightning /tidb-lightning-ctl \
&& rm -rf tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64.tar.gz \
&& rm -rf tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64

COPY bin/tidb-backup-manager /tidb-backup-manager
COPY entrypoint.sh /entrypoint.sh


ENTRYPOINT ["/entrypoint.sh"]

0 comments on commit c5efed5

Please sign in to comment.