Skip to content

Commit

Permalink
backup: generate backupmeta when backup empty. (pingcap#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuJuncen authored and 3pointer committed Apr 26, 2020
1 parent 8c09bb5 commit a804fc2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
34 changes: 34 additions & 0 deletions tests/br_backup_empty/run.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit a804fc2

Please sign in to comment.