Error Restoring Data After Using BR Backup: ErrRestoreNotFreshCluster

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 使用br备份后恢复数据报错ErrRestoreNotFreshCluster

| username: TiDBer_57GSL9zB

TiDB version 7.10, the data in the database is synchronized from MySQL using the DM tool.
Steps: Created 3 databases named in the format han_xxxx, created a table in each database, and inserted a row of data. Used br backup full for backup, but encountered an error during restore: [BR:Restore:ErrRestoreNotFreshCluster] cluster is not fresh.

Backup command:

tiup br backup full --pd “172.16.0.26:2379” --filter “han_.” --storage “local:///tidb/backup/han-date +%Y-%m-%d” --log-file backup.log

Restore command:

tiup br restore full --pd “xxx:2379” --filter ‘han*.*’ --storage “local:///tidb/backup/test-date +%Y-%m-%d” --log-file restore.log

Error:
the target cluster is not fresh, cannot restore.
you can drop existing databases and tables and start restore again

Does anyone know how to solve this?

| username: zhanggame1 | Original post link

BR recovery requires the target database and table to not exist…

| username: TiDBer_vfJBUcxl | Original post link

The table and database are not empty; they already contain data.

| username: Jellybean | Original post link

When the BR tool performs a recovery operation, it requires that the target cluster does not have the related databases and tables to avoid overwriting existing data.

Therefore, when using BR for recovery, the administrator must first ensure that it is a new cluster or sufficiently “clean” so that no identical databases and tables exist.

| username: redgame | Original post link

This needs to be cleaned up and then done again.

| username: ShawnYan | Original post link

Looking at the screenshot, is br 7.3?

A check for an empty cluster has been added before full recovery, and by default, recovery to a non-empty cluster is not supported. If you want to force recovery, you can use --filter to specify the corresponding table name.

| username: ShawnYan | Original post link

It looks like you have already checked the source code repository and raised an issue, BR:Restore:ErrRestoreNotFreshCluster · Issue #1489 · pingcap/br · GitHub

Then, further, you can find where this error logic comes from

| username: TiDBer_57GSL9zB | Original post link

I added -f ‘han_*’ but it still matches other databases that were not backed up :sob:

| username: 有猫万事足 | Original post link

Try changing full to db and see if it works.

| username: TiDBer_57GSL9zB | Original post link

It still doesn’t work, bro.

| username: 有猫万事足 | Original post link

Isn’t this indicating a change? The filter can be removed. :joy:

| username: TiDBer_57GSL9zB | Original post link

Removed it… tried it yesterday as well.

| username: TiDBer_57GSL9zB | Original post link

It works when restoring a single database, but it reports an error when restoring multiple databases at once.

| username: xfworld | Original post link

Backup command:

tiup br backup db --pd “xxx:2379” --db “han*” --storage “local:///tidb/backup/test-date +%Y-%m-%d” --log-file test.log

Can this command back up all databases named han.xxxx? I don’t think so, haha.


Take a good look at the documentation first…

| username: TiDBer_57GSL9zB | Original post link

I made a mistake. The backup command I used is this:
tiup br backup full --pd “172.16.0.26:2379” --filter “han_*.*” --storage “local:///tidb/backup/han-date +%Y-%m-%d” --log-file backup.log
Sorry, sorry.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.