Skip to content

Commit

Permalink
*: pitr backup and recovery #400
Browse files Browse the repository at this point in the history
acekingke committed Aug 30, 2023
1 parent 5cd8861 commit d170120
Showing 35 changed files with 794 additions and 1,804 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.sidecar
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ RUN set -ex; \
wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
apt-get update; \
apt-get install -y --no-install-recommends ${XTRABACKUP_PKG}; \
apt-get install -y --no-install-recommends ${XTRABACKUP_PKG} mysql-client jq; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /
11 changes: 9 additions & 2 deletions api/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
@@ -86,6 +86,11 @@ type MysqlClusterSpec struct {
// +optional
RestoreFrom string `json:"restoreFrom,omitempty"`

// RestorePoint is the target date and time to restore data.
// The format is "2006-01-02 15:04:05"
// +optional
RestorePoint string `json:"restorePoint"`

// Represents NFS ip address where cluster restore from.
// +optional
NFSServerAddress string `json:"nfsServerAddress,omitempty"`
@@ -470,8 +475,10 @@ type MysqlClusterStatus struct {
// State
State ClusterState `json:"state,omitempty"`
// LastBackup
LastBackup string `json:"lastbackup,omitempty"`
LastBackupGtid string `json:"lastbackupGtid,omitempty"`
LastBackup string `json:"lastbackup,omitempty"`
// LastBackup Create time, just for filter
LastBackupTime metav1.Time `json:"lastBackupTime,omitempty"`
LastBackupGtid string `json:"lastbackupGtid,omitempty"`
// Conditions contains the list of the cluster conditions fulfilled.
Conditions []ClusterCondition `json:"conditions,omitempty"`
// Nodes contains the list of the node status fulfilled.
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions api/v1beta1/backup_types.go
Original file line number Diff line number Diff line change
@@ -84,13 +84,15 @@ type BackupSchedule struct {
}

type BackupStatus struct {
Type BackupInitiator `json:"type,omitempty"`
BackupName string `json:"backupName,omitempty"`
BackupSize string `json:"backupSize,omitempty"`
BackupType string `json:"backupType,omitempty"`
StartTime *metav1.Time `json:"startTime,omitempty"`
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
State BackupConditionType `json:"state,omitempty"`
Type BackupInitiator `json:"type,omitempty"`
BackupName string `json:"backupName,omitempty"`
BackupSize string `json:"backupSize,omitempty"`
BackupType string `json:"backupType,omitempty"`
StartTime *metav1.Time `json:"startTime,omitempty"`
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
State BackupConditionType `json:"state,omitempty"`
// Get the Gtid
Gtid string `json:"gtid,omitempty"`
ManualBackup *ManualBackupStatus `json:"manual,omitempty"`
ScheduledBackups []ScheduledBackupStatus `json:"scheduled,omitempty"`
}
@@ -136,6 +138,8 @@ type ManualBackupStatus struct {
BackupType string `json:"backupType,omitempty"`
// Get the backup Size
BackupSize string `json:"backupSize,omitempty"`
// Get the Gtid
Gtid string `json:"gtid,omitempty"`
// Get current backup status
State BackupConditionType `json:"state,omitempty"`
}
@@ -164,6 +168,8 @@ type ScheduledBackupStatus struct {
Reason string `json:"reason"`
// Get the backup Size
BackupSize string `json:"backupSize,omitempty"`
// Get the Gtid
Gtid string `json:"gtid,omitempty"`
// Get current backup status
State BackupConditionType `json:"state,omitempty"`
}
5 changes: 5 additions & 0 deletions api/v1beta1/mysqlcluster_conversion.go
Original file line number Diff line number Diff line change
@@ -93,9 +93,12 @@ func Convert_v1alpha1_MysqlClusterSpec_To_v1beta1_MysqlClusterSpec(in *v1alpha1.
if len(in.BackupSecretName) != 0 {
out.DataSource.S3Backup.Name = in.RestoreFrom
out.DataSource.S3Backup.SecretName = in.BackupSecretName
out.DataSource.RestorePoint = in.RestorePoint
}

if len(in.NFSServerAddress) != 0 {
ipStr := strings.Split(in.NFSServerAddress, ":")
out.DataSource.RestorePoint = in.RestorePoint
out.DataSource.NFSBackup = &NFSBackupDataSource{
Name: in.RestoreFrom,
Volume: corev1.NFSVolumeSource{
@@ -160,12 +163,14 @@ func Convert_v1beta1_MysqlClusterSpec_To_v1alpha1_MysqlClusterSpec(in *MysqlClus
if len(in.DataSource.S3Backup.Name) != 0 {
out.RestoreFrom = in.DataSource.S3Backup.Name
out.BackupSecretName = in.DataSource.S3Backup.SecretName
out.RestorePoint = in.DataSource.RestorePoint
}

if in.DataSource.NFSBackup != nil {
out.RestoreFrom = in.DataSource.NFSBackup.Name
out.NFSServerAddress = fmt.Sprintf("%s:%s",
in.DataSource.NFSBackup.Volume.Server, in.DataSource.NFSBackup.Volume.Path)
out.RestorePoint = in.DataSource.RestorePoint
}

//TODO in.Log n.Service
10 changes: 10 additions & 0 deletions api/v1beta1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
@@ -197,6 +197,12 @@ type MysqlClusterStatus struct {
ReadyNodes int `json:"readyNodes,omitempty"`
// State
State ClusterState `json:"state,omitempty"`
// LastBackup
LastBackup string `json:"lastbackup,omitempty"`
LastBackupGtid string `json:"lastbackupGtid,omitempty"`

// LastBackup Create time, just for filter
LastBackupTime metav1.Time `json:"lastBackupTime,omitempty"`
// Conditions contains the list of the cluster conditions fulfilled.
Conditions []ClusterCondition `json:"conditions,omitempty"`
// Nodes contains the list of the node status fulfilled.
@@ -422,6 +428,10 @@ type DataSource struct {
// restore from nfs
// +optional
NFSBackup *NFSBackupDataSource `json:"Nfsbackup,omitempty"`
// RestorePoint is the target date and time to restore data.
// The format is "2006-01-02 15:04:05"
// +optional
RestorePoint string `json:"restorePoint"`
}

type RemoteDataSource struct {
9 changes: 9 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 0 additions & 144 deletions charts/mysql-operator/crds/mysql.radondb.com_backups.yaml

This file was deleted.

Loading

0 comments on commit d170120

Please sign in to comment.