pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.2k stars 490 forks source link

Adding support for logRestoreStartTs option in PITR restore spec (#5667) #5669

Closed ti-chi-bot closed 1 week ago

ti-chi-bot commented 1 week ago

This is an automated cherry-pick of #5667

What problem does this PR solve?

This PR is addressing the issue issue-5657

Adding support for the logRestoreStartTs option in the PITR restore spec.

What is changed and how does it work?

With this update, the Point-in-Time Recovery (PITR) restore mode allows users to apply PITR logs within a specified time range. Specifically, users can define the start and end timestamps using the logRestoreStartTs(start timestamp) and pitrRestoredTs(end timestamp) options in the restore spec, respectively. This enhancement enables more precise control over the restoration process, allowing users to restore data to an exact point in time by specifying the interval of PITR logs to be applied.

After this change the user can use a combination of pitrFullBackupStorageProvider and pitrRestoredTs, to restore the full backup snapshot and apply PITR logs. or else a combination of the logRestoreStartTs and pitrRestoredTs options in the restore spec to apply PITR logs within a specified time.

If the user fails to specify either the pitrFullBackupStorageProvider or logRestoreStartTs option in the restore specification, the restore job will result in an error.

Code changes

Tests

Apply PITR logs within a specified time range.

  1. Create a restore-pitr.yaml file as follows, then use kubectl apply to apply the yaml.

    `

    restore-pitr.yaml

     ---
     apiVersion: pingcap.com/v1alpha1
     kind: Restore
     metadata:
        name: demo3-restore-gcs
        namespace: restore-test
    spec:
      restoreMode: pitr
     br:
         cluster: demo3
         clusterNamespace: test3
     gcs:
         projectId: ${project_id}
         secretName: gcs-secret
         bucket: my-bucket
         prefix: my-log-backup-folder-pitr
      logRestoreStartTs: "2022-10-10T16:21:00+08:00"
      pitrRestoredTs: "2022-10-10T17:21:00+08:00"

    `

Side effects

Related changes

Release Notes

NONE

ti-chi-bot[bot] commented 1 week ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign wizardxiao for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/pingcap/tidb-operator/blob/release-1.6/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment