Skip to content

Commit d170120

Browse files
committed
*: pitr backup and recovery #400
1 parent 5cd8861 commit d170120

35 files changed

+794
-1804
lines changed

Dockerfile.sidecar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ RUN set -ex; \
5151
wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
5252
dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
5353
apt-get update; \
54-
apt-get install -y --no-install-recommends ${XTRABACKUP_PKG}; \
54+
apt-get install -y --no-install-recommends ${XTRABACKUP_PKG} mysql-client jq; \
5555
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
5656

5757
WORKDIR /

api/v1alpha1/mysqlcluster_types.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ type MysqlClusterSpec struct {
8686
// +optional
8787
RestoreFrom string `json:"restoreFrom,omitempty"`
8888

89+
// RestorePoint is the target date and time to restore data.
90+
// The format is "2006-01-02 15:04:05"
91+
// +optional
92+
RestorePoint string `json:"restorePoint"`
93+
8994
// Represents NFS ip address where cluster restore from.
9095
// +optional
9196
NFSServerAddress string `json:"nfsServerAddress,omitempty"`
@@ -470,8 +475,10 @@ type MysqlClusterStatus struct {
470475
// State
471476
State ClusterState `json:"state,omitempty"`
472477
// LastBackup
473-
LastBackup string `json:"lastbackup,omitempty"`
474-
LastBackupGtid string `json:"lastbackupGtid,omitempty"`
478+
LastBackup string `json:"lastbackup,omitempty"`
479+
// LastBackup Create time, just for filter
480+
LastBackupTime metav1.Time `json:"lastBackupTime,omitempty"`
481+
LastBackupGtid string `json:"lastbackupGtid,omitempty"`
475482
// Conditions contains the list of the cluster conditions fulfilled.
476483
Conditions []ClusterCondition `json:"conditions,omitempty"`
477484
// Nodes contains the list of the node status fulfilled.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/backup_types.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ type BackupSchedule struct {
8484
}
8585

8686
type BackupStatus struct {
87-
Type BackupInitiator `json:"type,omitempty"`
88-
BackupName string `json:"backupName,omitempty"`
89-
BackupSize string `json:"backupSize,omitempty"`
90-
BackupType string `json:"backupType,omitempty"`
91-
StartTime *metav1.Time `json:"startTime,omitempty"`
92-
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
93-
State BackupConditionType `json:"state,omitempty"`
87+
Type BackupInitiator `json:"type,omitempty"`
88+
BackupName string `json:"backupName,omitempty"`
89+
BackupSize string `json:"backupSize,omitempty"`
90+
BackupType string `json:"backupType,omitempty"`
91+
StartTime *metav1.Time `json:"startTime,omitempty"`
92+
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
93+
State BackupConditionType `json:"state,omitempty"`
94+
// Get the Gtid
95+
Gtid string `json:"gtid,omitempty"`
9496
ManualBackup *ManualBackupStatus `json:"manual,omitempty"`
9597
ScheduledBackups []ScheduledBackupStatus `json:"scheduled,omitempty"`
9698
}
@@ -136,6 +138,8 @@ type ManualBackupStatus struct {
136138
BackupType string `json:"backupType,omitempty"`
137139
// Get the backup Size
138140
BackupSize string `json:"backupSize,omitempty"`
141+
// Get the Gtid
142+
Gtid string `json:"gtid,omitempty"`
139143
// Get current backup status
140144
State BackupConditionType `json:"state,omitempty"`
141145
}
@@ -164,6 +168,8 @@ type ScheduledBackupStatus struct {
164168
Reason string `json:"reason"`
165169
// Get the backup Size
166170
BackupSize string `json:"backupSize,omitempty"`
171+
// Get the Gtid
172+
Gtid string `json:"gtid,omitempty"`
167173
// Get current backup status
168174
State BackupConditionType `json:"state,omitempty"`
169175
}

api/v1beta1/mysqlcluster_conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ func Convert_v1alpha1_MysqlClusterSpec_To_v1beta1_MysqlClusterSpec(in *v1alpha1.
9393
if len(in.BackupSecretName) != 0 {
9494
out.DataSource.S3Backup.Name = in.RestoreFrom
9595
out.DataSource.S3Backup.SecretName = in.BackupSecretName
96+
out.DataSource.RestorePoint = in.RestorePoint
9697
}
98+
9799
if len(in.NFSServerAddress) != 0 {
98100
ipStr := strings.Split(in.NFSServerAddress, ":")
101+
out.DataSource.RestorePoint = in.RestorePoint
99102
out.DataSource.NFSBackup = &NFSBackupDataSource{
100103
Name: in.RestoreFrom,
101104
Volume: corev1.NFSVolumeSource{
@@ -160,12 +163,14 @@ func Convert_v1beta1_MysqlClusterSpec_To_v1alpha1_MysqlClusterSpec(in *MysqlClus
160163
if len(in.DataSource.S3Backup.Name) != 0 {
161164
out.RestoreFrom = in.DataSource.S3Backup.Name
162165
out.BackupSecretName = in.DataSource.S3Backup.SecretName
166+
out.RestorePoint = in.DataSource.RestorePoint
163167
}
164168

165169
if in.DataSource.NFSBackup != nil {
166170
out.RestoreFrom = in.DataSource.NFSBackup.Name
167171
out.NFSServerAddress = fmt.Sprintf("%s:%s",
168172
in.DataSource.NFSBackup.Volume.Server, in.DataSource.NFSBackup.Volume.Path)
173+
out.RestorePoint = in.DataSource.RestorePoint
169174
}
170175

171176
//TODO in.Log n.Service

api/v1beta1/mysqlcluster_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ type MysqlClusterStatus struct {
197197
ReadyNodes int `json:"readyNodes,omitempty"`
198198
// State
199199
State ClusterState `json:"state,omitempty"`
200+
// LastBackup
201+
LastBackup string `json:"lastbackup,omitempty"`
202+
LastBackupGtid string `json:"lastbackupGtid,omitempty"`
203+
204+
// LastBackup Create time, just for filter
205+
LastBackupTime metav1.Time `json:"lastBackupTime,omitempty"`
200206
// Conditions contains the list of the cluster conditions fulfilled.
201207
Conditions []ClusterCondition `json:"conditions,omitempty"`
202208
// Nodes contains the list of the node status fulfilled.
@@ -422,6 +428,10 @@ type DataSource struct {
422428
// restore from nfs
423429
// +optional
424430
NFSBackup *NFSBackupDataSource `json:"Nfsbackup,omitempty"`
431+
// RestorePoint is the target date and time to restore data.
432+
// The format is "2006-01-02 15:04:05"
433+
// +optional
434+
RestorePoint string `json:"restorePoint"`
425435
}
426436

427437
type RemoteDataSource struct {

api/v1beta1/zz_generated.conversion.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/mysql-operator/crds/mysql.radondb.com_backups.yaml

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)