Skip to content

Commit

Permalink
fix(backup): fixed api handlers for creating backup policy
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Dec 24, 2024
1 parent 274d2d2 commit 370e13e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api/constants/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ var DestPathPatternMapping = map[types.BackupDestType]*regexp.Regexp{
BackupDestTypeS3Compatible: regexp.MustCompile(`^s3://[^/]+/[^/].*\\?host=.+$`),
BackupDestTypeNFS: regexp.MustCompile(`^\S+$`),
}

var DestPathPrefixMapping = map[types.BackupDestType]string{
BackupDestTypeOSS: "oss://",
BackupDestTypeCOS: "cos://",
BackupDestTypeS3: "s3://",
BackupDestTypeS3Compatible: "s3://",
BackupDestTypeNFS: "file://",
}
4 changes: 4 additions & 0 deletions internal/dashboard/business/oceanbase/obtenantbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"

"github.com/oceanbase/ob-operator/api/constants"
apiconst "github.com/oceanbase/ob-operator/api/constants"
apitypes "github.com/oceanbase/ob-operator/api/types"
"github.com/oceanbase/ob-operator/api/v1alpha1"
Expand Down Expand Up @@ -358,6 +359,9 @@ func CreateTenantBackupPolicy(ctx context.Context, nn types.NamespacedName, p *p
ossSecretName := nn.Name + "-backup-" + strings.ToLower(strings.ReplaceAll(string(p.DestType), "_", "-")) + "-secret-" + rand.String(6)
backupPolicy.Spec.LogArchive.Destination.OSSAccessSecret = ossSecretName
backupPolicy.Spec.DataBackup.Destination.OSSAccessSecret = ossSecretName

backupPolicy.Spec.LogArchive.Destination.Path = constants.DestPathPrefixMapping[apitypes.BackupDestType(p.DestType)] + p.ArchivePath + "?host=" + p.Host
backupPolicy.Spec.DataBackup.Destination.Path = constants.DestPathPrefixMapping[apitypes.BackupDestType(p.DestType)] + p.BakDataPath + "?host=" + p.Host
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: ossSecretName,
Expand Down
4 changes: 2 additions & 2 deletions pkg/oceanbase-sdk/const/sql/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const jobCommonFields = "job_id, executor_tenant_id, job_level, start_timestamp,
const backupJobFields = jobCommonFields + ", backup_set_id, plus_archivelog, backup_type, encryption_mode, passwd"
const backupTaskFields = "job_id, backup_set_id, start_timestamp, end_timestamp, status, result, comment, task_id, incarnation, start_scn, end_scn, user_ls_start_scn, encryption_mode, passwd, input_bytes, output_bytes, output_rate_bytes, extra_meta_bytes, tablet_count, finish_tablet_count, macro_block_count, finish_macro_block_count, file_count, meta_turn_id, data_turn_id, path"
const cleanJobFields = jobCommonFields + ", type, parameter, task_count, success_task_count"
const logArchiveJobFields = "dest_id, round_id, dest_no, status, start_scn, start_scn_display, checkpoint_scn, checkpoint_scn_display, compatible, base_piece_id, used_piece_id, piece_switch_interval, input_bytes, input_bytes_display, output_bytes, output_bytes_display, compression_ratio, deleted_input_bytes, deleted_input_bytes_display, deleted_output_bytes, deleted_output_bytes_display, comment, path"
const logArchivePieceFileFields = "dest_id, round_id, piece_id, incarnation, dest_no, status, start_scn, start_scn_display, checkpoint_scn, checkpoint_scn_display, max_scn, end_scn, end_scn_display, compatible, unit_size, compression, input_bytes, input_bytes_display, output_bytes, output_bytes_display, compression_ratio, file_status, path"
const logArchiveJobFields = "dest_id, round_id, dest_no, status, start_scn, start_scn_display, checkpoint_scn, IFNULL(checkpoint_scn_display, '-') as checkpoint_scn_display, compatible, base_piece_id, used_piece_id, piece_switch_interval, input_bytes, input_bytes_display, output_bytes, output_bytes_display, compression_ratio, deleted_input_bytes, deleted_input_bytes_display, deleted_output_bytes, deleted_output_bytes_display, comment, path"
const logArchivePieceFileFields = "dest_id, round_id, piece_id, incarnation, dest_no, status, start_scn, start_scn_display, checkpoint_scn, IFNULL(checkpoint_scn_display, '-') as checkpoint_scn_display, max_scn, end_scn, end_scn_display, compatible, unit_size, compression, input_bytes, input_bytes_display, output_bytes, output_bytes_display, compression_ratio, file_status, path"

const (
EnableArchiveLog = "ALTER SYSTEM ARCHIVELOG"
Expand Down

0 comments on commit 370e13e

Please sign in to comment.