Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

fix: backup will skip empty databases. #560

Merged
merged 7 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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