pingcap/tidb-operator

Support PITR restore using --start-ts only

kennytm opened this issue · 0 comments

Feature Request

Is your feature request related to a problem? Please describe:

Currently TiDB Operator's PITR required a complete data backup as the starting point, i.e. the Restore CR required a valid spec.pitrFullBackupStorageProvider.

---
apiVersion: pingcap.com/v1alpha1
kind: Restore
spec:
  restoreMode: pitr
  pitrFullBackupStorageProvider:  # this item is required
    s3:
      ...
  ...

This is statically checked in

if fullBackupArgs, err := pkgutil.GenStorageArgsForFlag(restore.Spec.PitrFullBackupStorageProvider, "full-backup-storage"); err != nil {
return err
} else {
// parse full backup path
args = append(args, fullBackupArgs...)
}

Describe the feature you'd like:

In our scenario, the "starting point" is not a single Full backup, but also followed by a series of Incremental backups. The kernel br command supports this PITR scenario via the --start-ts option:

br restore full -s 's3://bucket/full-backup/2024/01'
br restore full -s 's3://bucket/incr-backup/2024/01/01'
br restore full -s 's3://bucket/incr-backup/2024/01/02'
br restore full -s 's3://bucket/incr-backup/2024/01/03'
br restore point -s 's3://bucket/log-backup' --start-ts=446748741183209472 --restored-ts='2024-01-03 13:15:00'

We would like the Restore CR to expose the --start-ts option, making the validation required either --start-ts or --full-backup-storage (but not both).

---
apiVersion: pingcap.com/v1alpha1
kind: Restore
spec:
  restoreMode: pitr
  pitrStartTs: '446748741183209472'   # <- new option
  ...

Describe alternatives you've considered:

Rather than exposing --start-ts, we can make the Restore CR perform the (Full + Incremental × N) steps like

---
apiVersion: pingcap.com/v1alpha1
kind: Restore
spec:
  restoreMode: pitr
  pitrFullBackupStorageProvider: ...
  pitrIncrementalBackupStorageProviders:
  - s3: ...
  - s3: ...

But this is considerably more complex and is not suitable for our need (which we have performed the snapshot restore by other means already)

Teachability, Documentation, Adoption, Migration Strategy: