Skip to content

Commit

Permalink
fix: add Selective backupType (#8553)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnolong authored Dec 2, 2024
1 parent 2d73e55 commit 3d364be
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions apis/dataprotection/v1alpha1/actionset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ type ActionSetSpec struct {
// - `Incremental` back up data that have changed since the last backup (either full or incremental).
// - `Differential` back up data that has changed since the last full backup.
// - `Continuous` back up transaction logs continuously, such as MySQL binlog, PostgreSQL WAL, etc.
// - `Selective` back up data more precisely, use custom parameters, such as specific databases or tables.
//
// Continuous backup is essential for implementing Point-in-Time Recovery (PITR).
//
// +kubebuilder:validation:Enum={Full,Incremental,Differential,Continuous}
// +kubebuilder:validation:Enum={Full,Incremental,Differential,Continuous,Selective}
// +kubebuilder:default=Full
// +kubebuilder:validation:Required
BackupType BackupType `json:"backupType"`
Expand Down Expand Up @@ -91,14 +92,15 @@ type ActionSetStatus struct {

// BackupType the backup type.
// +enum
// +kubebuilder:validation:Enum={Full,Incremental,Differential,Continuous}
// +kubebuilder:validation:Enum={Full,Incremental,Differential,Continuous,Selective}
type BackupType string

const (
BackupTypeFull BackupType = "Full"
BackupTypeIncremental BackupType = "Incremental"
BackupTypeDifferential BackupType = "Differential"
BackupTypeContinuous BackupType = "Continuous"
BackupTypeSelective BackupType = "Selective"
)

type BackupActionSpec struct {
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/dataprotection.kubeblocks.io_actionsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ spec:
- Incremental
- Differential
- Continuous
- Selective
- enum:
- Full
- Incremental
- Differential
- Continuous
- Selective
default: Full
description: |-
Specifies the backup type. Supported values include:
Expand All @@ -296,6 +298,7 @@ spec:
- `Incremental` back up data that have changed since the last backup (either full or incremental).
- `Differential` back up data that has changed since the last full backup.
- `Continuous` back up transaction logs continuously, such as MySQL binlog, PostgreSQL WAL, etc.
- `Selective` back up data more precisely, use custom parameters, such as specific databases or tables.
Continuous backup is essential for implementing Point-in-Time Recovery (PITR).
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/crds/dataprotection.kubeblocks.io_actionsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ spec:
- Incremental
- Differential
- Continuous
- Selective
- enum:
- Full
- Incremental
- Differential
- Continuous
- Selective
default: Full
description: |-
Specifies the backup type. Supported values include:
Expand All @@ -296,6 +298,7 @@ spec:
- `Incremental` back up data that have changed since the last backup (either full or incremental).
- `Differential` back up data that has changed since the last full backup.
- `Continuous` back up transaction logs continuously, such as MySQL binlog, PostgreSQL WAL, etc.
- `Selective` back up data more precisely, use custom parameters, such as specific databases or tables.
Continuous backup is essential for implementing Point-in-Time Recovery (PITR).
Expand Down
4 changes: 4 additions & 0 deletions docs/developer_docs/api-reference/backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ BackupType
<li><code>Incremental</code> back up data that have changed since the last backup (either full or incremental).</li>
<li><code>Differential</code> back up data that has changed since the last full backup.</li>
<li><code>Continuous</code> back up transaction logs continuously, such as MySQL binlog, PostgreSQL WAL, etc.</li>
<li><code>Selective</code> back up data more precisely, use custom parameters, such as specific databases or tables.</li>
</ul>
<p>Continuous backup is essential for implementing Point-in-Time Recovery (PITR).</p>
</td>
Expand Down Expand Up @@ -1348,6 +1349,7 @@ BackupType
<li><code>Incremental</code> back up data that have changed since the last backup (either full or incremental).</li>
<li><code>Differential</code> back up data that has changed since the last full backup.</li>
<li><code>Continuous</code> back up transaction logs continuously, such as MySQL binlog, PostgreSQL WAL, etc.</li>
<li><code>Selective</code> back up data more precisely, use custom parameters, such as specific databases or tables.</li>
</ul>
<p>Continuous backup is essential for implementing Point-in-Time Recovery (PITR).</p>
</td>
Expand Down Expand Up @@ -3773,6 +3775,8 @@ Kubernetes meta/v1.Time
<td></td>
</tr><tr><td><p>&#34;Incremental&#34;</p></td>
<td></td>
</tr><tr><td><p>&#34;Selective&#34;</p></td>
<td></td>
</tr></tbody>
</table>
<h3 id="dataprotection.kubeblocks.io/v1alpha1.BaseJobActionSpec">BaseJobActionSpec
Expand Down
2 changes: 1 addition & 1 deletion pkg/dataprotection/backup/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (r *Request) buildBackupDataAction(targetPod *corev1.Pod, name string) (act

backupDataAct := r.ActionSet.Spec.Backup.BackupData
switch r.ActionSet.Spec.BackupType {
case dpv1alpha1.BackupTypeFull:
case dpv1alpha1.BackupTypeFull, dpv1alpha1.BackupTypeSelective:
podSpec, err := r.BuildJobActionPodSpec(targetPod, BackupDataContainerName, &backupDataAct.JobActionSpec)
if err != nil {
return nil, fmt.Errorf("failed to build job action pod spec: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dataprotection/restore/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func ValidateAndInitRestoreMGR(reqCtx intctrlutil.RequestCtx,

// build backupActionSets of prepareData and postReady stage based on the specified backup's type.
switch backupType {
case dpv1alpha1.BackupTypeFull:
case dpv1alpha1.BackupTypeFull, dpv1alpha1.BackupTypeSelective:
restoreMgr.SetBackupSets(*backupSet)
case dpv1alpha1.BackupTypeIncremental:
err = restoreMgr.BuildIncrementalBackupActionSets(reqCtx, cli, *backupSet)
Expand Down
1 change: 1 addition & 0 deletions pkg/testutil/dataprotection/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func MockActionSetWithSchema(testCtx *testutil.TestContext, actionSet *dpv1alpha
}
as.Spec.Backup.WithParameters = []string{ParameterString, ParameterArray}
as.Spec.Restore.WithParameters = []string{ParameterString, ParameterArray}
as.Spec.BackupType = dpv1alpha1.BackupTypeSelective
})).Should(Succeed())
By("the actionSet should be available")
Eventually(testapps.CheckObj(testCtx, client.ObjectKeyFromObject(actionSet),
Expand Down

0 comments on commit 3d364be

Please sign in to comment.