Skip to content

Commit

Permalink
fix: backup will skip empty databases. (pingcap#560)
Browse files Browse the repository at this point in the history
* fix: backup will skip empty databases.

* fix typo.

Co-authored-by: 山岚 <36239017+YuJuncen@users.noreply.github.com>
Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: kennytm <kennytm@gmail.com>
  • Loading branch information
4 people committed Nov 6, 2020
1 parent af96fb8 commit f23ffaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ func BuildBackupRangeAndSchema(
seqAlloc := autoid.NewAllocator(storage, dbInfo.ID, false, autoid.SequenceType)
randAlloc := autoid.NewAllocator(storage, dbInfo.ID, false, autoid.AutoRandomType)

if len(dbInfo.Tables) == 0 {
log.Warn("It's not necessary for backing up empty database",
zap.Stringer("db", dbInfo.Name))
continue
}
for _, tableInfo := range dbInfo.Tables {
if !tableFilter.MatchTable(dbInfo.Name.O, tableInfo.Name.O) {
// Skip tables other than the given table.
Expand Down
4 changes: 4 additions & 0 deletions pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package task
import (
"context"
"strconv"
"strings"
"time"

"github.com/pingcap/br/pkg/utils"
Expand Down Expand Up @@ -254,6 +255,9 @@ func RunBackup(c context.Context, g glue.Glue, cmdName string, cfg *BackupConfig
if err2 != nil {
return err2
}
pdAddress := strings.Join(cfg.PD, ",")
log.Warn("Nothing to backup, maybe connected to cluster for restoring",
zap.String("PD address", pdAddress))
return client.SaveBackupMeta(ctx, &backupMeta)
}

Expand Down

0 comments on commit f23ffaf

Please sign in to comment.