diff --git a/pkg/task/backup.go b/pkg/task/backup.go index 69e2b619b..b4cdc3cbb 100644 --- a/pkg/task/backup.go +++ b/pkg/task/backup.go @@ -130,7 +130,7 @@ func RunBackup(c context.Context, g glue.Glue, cmdName string, cfg *BackupConfig } // nothing to backup if ranges == nil { - return nil + return client.SaveBackupMeta(ctx, nil) } ddlJobs := make([]*model.Job, 0) diff --git a/pkg/task/restore.go b/pkg/task/restore.go index 850d0d2cd..c27922fcc 100644 --- a/pkg/task/restore.go +++ b/pkg/task/restore.go @@ -161,6 +161,8 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf // nothing to restore, maybe only ddl changes in incremental restore if len(files) == 0 { log.Info("all files are filtered out from the backup archive, nothing to restore") + // even nothing to restore, we show a success message since there is no failure. + summary.SetSuccessStatus(true) return nil } diff --git a/tests/br_backup_empty/run.sh b/tests/br_backup_empty/run.sh new file mode 100644 index 000000000..a7fa1f233 --- /dev/null +++ b/tests/br_backup_empty/run.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Copyright 2020 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +# backup empty. +echo "backup start..." +run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/empty" --ratelimit 5 --concurrency 4 +if [ $? -ne 0 ]; then + echo "TEST: [$TEST_NAME] failed on backup empty cluster!" + exit 1 +fi + +# restore empty. +echo "restore start..." +run_br restore full -s "local://$TEST_DIR/empty" --pd $PD_ADDR --ratelimit 1024 +if [ $? -ne 0 ]; then + echo "TEST: [$TEST_NAME] failed on restore empty cluster!" + exit 1 +fi + +echo "TEST: [$TEST_NAME] successed!"