diff --git a/Makefile b/Makefile index 9866fd92..b386893c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ TOPTARGETS := all +FILES ?= $(shell find . -type f -name '*.go') +PACKAGES ?= $(shell go list ./...) SUBDIRS := pkg/proto @@ -7,3 +9,16 @@ $(SUBDIRS): $(MAKE) -C $@ $(MAKECMDGOALS) .PHONY: $(TOPTARGETS) $(SUBDIRS) + +test: + go test -v ./... -short + +fmt: + go fmt ./... + goimports -w $(FILES) + +lint: + golint $(PACKAGES) + +vet: + go vet ./... diff --git a/cmd/ydbcp/config.yaml b/cmd/ydbcp/config.yaml index dfb16345..17a749ea 100644 --- a/cmd/ydbcp/config.yaml +++ b/cmd/ydbcp/config.yaml @@ -1,2 +1,14 @@ -ydbcp_db_connection_string: "grpc://localhost:2136/local" operation_ttl_seconds: 86400 # 24 hours + +db_connection: + connection_string: "grpcs://localhost:2135/domain/database" + insecure: true + discovery: false + +s3: + endpoint: s3.endpoint.com + region: s3-region + bucket: s3-bucket + path_prefix: cluster-domain + access_key_id_path: path-to-s3-key + secret_access_key_path: path-to-s3-sec diff --git a/cmd/ydbcp/main.go b/cmd/ydbcp/main.go index e6da997b..9829a421 100644 --- a/cmd/ydbcp/main.go +++ b/cmd/ydbcp/main.go @@ -5,13 +5,14 @@ import ( "errors" "flag" "fmt" - table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" "net" "os" "os/signal" "strconv" + "strings" "sync" "syscall" + "time" "ydbcp/internal/config" configInit "ydbcp/internal/config" "ydbcp/internal/connectors/client" @@ -22,6 +23,9 @@ import ( "ydbcp/internal/types" "ydbcp/internal/util/xlog" + "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Export" + table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" + _ "go.uber.org/automaxprocs" "go.uber.org/zap" @@ -39,8 +43,9 @@ var ( type server struct { pb.UnimplementedBackupServiceServer pb.UnimplementedOperationServiceServer - driver db.DBConnector - s3 config.S3Config + driver db.DBConnector + clientConn client.ClientConnector + s3 config.S3Config } func (s *server) GetBackup(ctx context.Context, request *pb.GetBackupRequest) (*pb.Backup, error) { @@ -75,13 +80,68 @@ func (s *server) GetBackup(ctx context.Context, request *pb.GetBackupRequest) (* func (s *server) MakeBackup(ctx context.Context, req *pb.MakeBackupRequest) (*pb.Operation, error) { xlog.Info(ctx, "MakeBackup", zap.String("request", req.String())) + clientConnectionParams := types.YdbConnectionParams{ + Endpoint: req.GetDatabaseEndpoint(), + DatabaseName: req.GetDatabaseName(), + } + dsn := types.MakeYdbConnectionString(clientConnectionParams) + client, err := s.clientConn.Open(ctx, dsn) + if err != nil { + // xlog.Error(ctx, "can't open client connection", zap.Error(err), zap.String("dsn", dsn)) + return nil, fmt.Errorf("can't open client connection, dsn %s: %w", dsn, err) + } + defer func() { + if err := s.clientConn.Close(ctx, client); err != nil { + xlog.Error(ctx, "can't close client connection", zap.Error(err)) + } + }() + + accessKey, err := s.s3.AccessKey() + if err != nil { + xlog.Error(ctx, "can't get S3AccessKey", zap.Error(err)) + return nil, fmt.Errorf("can't get S3AccessKey: %w", err) + } + secretKey, err := s.s3.SecretKey() + if err != nil { + xlog.Error(ctx, "can't get S3SecretKey", zap.Error(err)) + return nil, fmt.Errorf("can't get S3SecretKey: %w", err) + } + exportItems := make([]*Ydb_Export.ExportToS3Settings_Item, 0, len(s.s3.PathPrefix)) + databaseName := strings.Replace(req.DatabaseName, "/", "_", -1) // TODO: checking user imput + databaseName = strings.Trim(databaseName, "_") + dstPrefix := fmt.Sprintf("%s/%s/%s", s.s3.PathPrefix, databaseName, time.Now().Format("20060102_150405")) + for _, path := range req.GetSourcePaths() { + exportItems = append(exportItems, &Ydb_Export.ExportToS3Settings_Item{ + SourcePath: path, + DestinationPrefix: dstPrefix, // TODO: check if we need different destination prefixes? + }) + } + + s3Settings := &Ydb_Export.ExportToS3Settings{ + Endpoint: s.s3.Endpoint, + Region: s.s3.Region, + Bucket: s.s3.Bucket, + AccessKey: accessKey, + SecretKey: secretKey, + Description: "ydbcp backup", // TODO: the description shoud be better + NumberOfRetries: 10, // TODO: get it from configuration + Items: exportItems, + } + + clientOperationID, err := s.clientConn.ExportToS3(ctx, client, s3Settings) + if err != nil { + xlog.Error(ctx, "can't start export operation", zap.Error(err), zap.String("dns", dsn)) + return nil, fmt.Errorf("can't start export operation, dsn %s: %w", dsn, err) + } + xlog.Debug(ctx, "export operation started", zap.String("clientOperationID", clientOperationID), zap.String("dsn", dsn)) + backup := types.Backup{ ContainerID: req.GetContainerId(), DatabaseName: req.GetDatabaseName(), S3Endpoint: s.s3.Endpoint, S3Region: s.s3.Region, S3Bucket: s.s3.Bucket, - S3PathPrefix: s.s3.PathPrefix, + S3PathPrefix: dstPrefix, Status: types.BackupStatePending, } backupID, err := s.driver.CreateBackup(ctx, backup) @@ -99,11 +159,13 @@ func (s *server) MakeBackup(ctx context.Context, req *pb.MakeBackupRequest) (*pb ContainerID: req.ContainerId, State: types.OperationStatePending, YdbConnectionParams: types.YdbConnectionParams{ - Endpoint: req.GetEndpoint(), + Endpoint: req.GetDatabaseEndpoint(), DatabaseName: req.GetDatabaseName(), }, SourcePaths: req.GetSourcePaths(), SourcePathToExclude: req.GetSourcePathsToExclude(), + CreatedAt: time.Now(), + YdbOperationId: clientOperationID, } operationID, err := s.driver.CreateOperation(ctx, op) @@ -249,10 +311,18 @@ func main() { s := grpc.NewServer() reflection.Register(s) - dbConnector := db.NewYdbConnector(configInstance) + dbConnector, err := db.NewYdbConnector(ctx, configInstance.DBConnection) + if err != nil { + xlog.Error(ctx, "Error init DBConnector", zap.Error(err)) + os.Exit(1) + } - server := server{driver: dbConnector} - defer server.driver.Close() + server := server{ + driver: dbConnector, + clientConn: client.NewClientYdbConnector(), + s3: configInstance.S3, + } + defer server.driver.Close(ctx) pb.RegisterBackupServiceServer(s, &server) pb.RegisterOperationServiceServer(s, &server) diff --git a/internal/config/config.go b/internal/config/config.go index bbd457a4..e8a59f57 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,7 +3,9 @@ package config import ( "context" "errors" + "fmt" "os" + "strings" "ydbcp/internal/util/xlog" "go.uber.org/zap" @@ -19,10 +21,17 @@ type S3Config struct { SecretAccessKeyPath string `yaml:"secret_access_key_path"` } +type YDBConnectionConfig struct { + ConnectionString string `yaml:"connection_string"` + Insecure bool `yaml:"insecure"` + Discovery bool `yaml:"discovery" default:"true"` + DialTimeoutSeconds uint32 `yaml:"dial_timeout_seconds" default:"5"` +} + type Config struct { - YdbcpDbConnectionString string `yaml:"ydbcp_db_connection_string"` - S3 S3Config `yaml:"s3"` - OperationTtlSeconds int64 `yaml:"operation_ttl_seconds"` + DBConnection YDBConnectionConfig `yaml:"db_connection"` + S3 S3Config `yaml:"s3"` + OperationTtlSeconds int64 `yaml:"operation_ttl_seconds"` } func (config Config) ToString() (string, error) { @@ -54,3 +63,20 @@ func InitConfig(ctx context.Context, confPath string) (Config, error) { } return Config{}, errors.New("configuration file path is empty") } + +func readSecret(filename string) (string, error) { + rawSecret, err := os.ReadFile(filename) + if err != nil { + return "", fmt.Errorf("can't read file %s: %w", filename, err) + } + return strings.TrimSpace(string(rawSecret)), nil +} + +func (c *S3Config) AccessKey() (string, error) { + return readSecret(c.AccessKeyIDPath) +} + +func (c *S3Config) SecretKey() (string, error) { + return readSecret(c.SecretAccessKeyPath) + +} diff --git a/internal/connectors/client/connector.go b/internal/connectors/client/connector.go index 8d9f65e9..2b7275c1 100644 --- a/internal/connectors/client/connector.go +++ b/internal/connectors/client/connector.go @@ -14,6 +14,7 @@ import ( "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Import" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Operations" "github.com/ydb-platform/ydb-go-sdk/v3" + "github.com/ydb-platform/ydb-go-sdk/v3/balancers" "go.uber.org/zap" "google.golang.org/protobuf/types/known/durationpb" ) @@ -38,7 +39,14 @@ func NewClientYdbConnector() *ClientYdbConnector { func (d *ClientYdbConnector) Open(ctx context.Context, dsn string) (*ydb.Driver, error) { xlog.Info(ctx, "Connecting to client db", zap.String("dsn", dsn)) - db, connErr := ydb.Open(ctx, dsn, ydb.WithAnonymousCredentials()) + opts := []ydb.Option{ + ydb.WithAnonymousCredentials(), + ydb.WithTLSSInsecureSkipVerify(), + ydb.WithDialTimeout(time.Second * 10), + ydb.WithBalancer(balancers.SingleConn()), + } + + db, connErr := ydb.Open(ctx, dsn, opts...) if connErr != nil { return nil, fmt.Errorf("error connecting to client db: %s", connErr.Error()) diff --git a/internal/connectors/db/connector.go b/internal/connectors/db/connector.go index 84d0f638..ae32b4fb 100644 --- a/internal/connectors/db/connector.go +++ b/internal/connectors/db/connector.go @@ -3,12 +3,16 @@ package db import ( "context" "errors" - table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" + "fmt" + "time" "ydbcp/internal/config" "ydbcp/internal/connectors/db/yql/queries" "ydbcp/internal/types" + table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" + "github.com/ydb-platform/ydb-go-sdk/v3" + "github.com/ydb-platform/ydb-go-sdk/v3/balancers" "github.com/ydb-platform/ydb-go-sdk/v3/table" "github.com/ydb-platform/ydb-go-sdk/v3/table/result" "go.uber.org/zap" @@ -47,45 +51,38 @@ type DBConnector interface { CreateOperation(context.Context, types.Operation) (types.ObjectID, error) CreateBackup(context.Context, types.Backup) (types.ObjectID, error) UpdateBackup(context context.Context, id types.ObjectID, backupState string) error - Close() + Close(context.Context) } type YdbConnector struct { driver *ydb.Driver } -func NewYdbConnector(config config.Config) *YdbConnector { - p := new(YdbConnector) - p.driver = InitDriver(config.YdbcpDbConnectionString) - return p -} - -func InitDriver(dsn string) *ydb.Driver { - ctx := context.Background() - +func NewYdbConnector(ctx context.Context, config config.YDBConnectionConfig) (*YdbConnector, error) { opts := []ydb.Option{ ydb.WithAnonymousCredentials(), + ydb.WithDialTimeout(time.Second * time.Duration(config.DialTimeoutSeconds)), + } + if config.Insecure { + opts = append(opts, ydb.WithTLSSInsecureSkipVerify()) + } + if !config.Discovery { + opts = append(opts, ydb.WithBalancer(balancers.SingleConn())) } - xlog.Info(ctx, "connecting to ydb", zap.String("dsn", dsn)) - db, err := ydb.Open(ctx, dsn, opts...) + xlog.Info(ctx, "connecting to ydb", zap.String("dsn", config.ConnectionString)) + driver, err := ydb.Open(ctx, config.ConnectionString, opts...) if err != nil { - // handle a connection error - xlog.Error( - ctx, "Error connecting to YDB", zap.String("message", err.Error()), - ) - return nil + return nil, fmt.Errorf("can't connect to YDB, dsn %s: %w", config.ConnectionString, err) } - - return db + return &YdbConnector{driver: driver}, nil } func (d *YdbConnector) GetTableClient() table.Client { return d.driver.Table() } -func (d *YdbConnector) Close() { - ctx := context.Background() +func (d *YdbConnector) Close(ctx context.Context) { err := d.driver.Close(ctx) if err != nil { xlog.Error(ctx, "Error closing YDB driver") @@ -287,8 +284,8 @@ func (d *YdbConnector) ActiveOperations(ctx context.Context) ( queries.QueryFilter{ Field: "status", Values: []table_types.Value{ - table_types.StringValueFromString(string(types.OperationStatePending)), - table_types.StringValueFromString(string(types.OperationStateCancelling)), + table_types.StringValueFromString(types.OperationStatePending.String()), + table_types.StringValueFromString(types.OperationStateCancelling.String()), }, }, ), @@ -300,7 +297,8 @@ func (d *YdbConnector) ActiveOperations(ctx context.Context) ( func (d *YdbConnector) UpdateOperation( ctx context.Context, operation types.Operation, ) error { - return d.ExecuteUpsert(ctx, queries.MakeWriteTableQuery(queries.WithUpdateOperation(operation))) + // return d.ExecuteUpsert(ctx, queries.MakeWriteTableQuery(queries.WithUpdateOperation(operation))) + return d.ExecuteUpsert(ctx, queries.MakeWriteTableQuery(queries.WithCreateOperation(operation))) } func (d *YdbConnector) CreateOperation( @@ -327,11 +325,30 @@ func (d *YdbConnector) CreateBackup( } func (d *YdbConnector) UpdateBackup( - context context.Context, id types.ObjectID, backupStatus string, + ctx context.Context, id types.ObjectID, backupStatus string, ) error { - backup := types.Backup{ - ID: id, - Status: backupStatus, + // TODO: We must't select here + backups, err := d.SelectBackups( + ctx, queries.MakeReadTableQuery( + queries.WithTableName("Backups"), + queries.WithSelectFields(queries.AllBackupFields...), + queries.WithQueryFilters( + queries.QueryFilter{ + Field: "id", + Values: []table_types.Value{table_types.UUIDValue(id)}, + }, + ), + ), + ) + if err != nil { + xlog.Error(ctx, "can't select backups", zap.Error(err)) + return err } - return d.ExecuteUpsert(context, queries.MakeWriteTableQuery(queries.WithCreateBackup(backup))) + if len(backups) != 1 { + return errors.New("No backup with such Id") + } + backup := backups[0] + backup.Status = backupStatus + + return d.ExecuteUpsert(ctx, queries.MakeWriteTableQuery(queries.WithCreateBackup(*backup))) } diff --git a/internal/connectors/db/mock.go b/internal/connectors/db/mock.go index dc9f73ea..1e1e4de1 100644 --- a/internal/connectors/db/mock.go +++ b/internal/connectors/db/mock.go @@ -72,7 +72,7 @@ func (c *MockDBConnector) UpdateBackup( return nil } -func (c *MockDBConnector) Close() {} +func (c *MockDBConnector) Close(_ context.Context) {} func (c *MockDBConnector) GetTableClient() table.Client { return nil } diff --git a/internal/connectors/db/process_result_set.go b/internal/connectors/db/process_result_set.go index a6a6c12b..ce66366e 100644 --- a/internal/connectors/db/process_result_set.go +++ b/internal/connectors/db/process_result_set.go @@ -2,10 +2,12 @@ package db import ( "fmt" + "time" + "ydbcp/internal/types" + "github.com/google/uuid" "github.com/ydb-platform/ydb-go-sdk/v3/table/result" "github.com/ydb-platform/ydb-go-sdk/v3/table/result/named" - "ydbcp/internal/types" ) type StructFromResultSet[T any] func(result result.Result) (*T, error) @@ -25,23 +27,29 @@ func StringOrEmpty(str *string) string { func ReadBackupFromResultSet(res result.Result) (*types.Backup, error) { var ( - backupId [16]byte - containerId string - databaseName string - s3endpoint *string - s3region *string - s3pathprefix *string - status *string + backupId [16]byte + containerId string + databaseName string + databaseEndpoint string + s3endpoint *string + s3region *string + s3bucket *string + s3pathprefix *string + status *string + message *string ) err := res.ScanNamed( named.Required("id", &backupId), named.Required("container_id", &containerId), named.Required("database", &databaseName), + named.Required("endpoint", &databaseEndpoint), named.Optional("s3_endpoint", &s3endpoint), named.Optional("s3_region", &s3region), + named.Optional("s3_bucket", &s3bucket), named.Optional("s3_path_prefix", &s3pathprefix), named.Optional("status", &status), + named.Optional("message", &message), ) if err != nil { return nil, err @@ -54,14 +62,16 @@ func ReadBackupFromResultSet(res result.Result) (*types.Backup, error) { } return &types.Backup{ - ID: types.ObjectID(id), - ContainerID: containerId, - DatabaseName: databaseName, - S3Endpoint: StringOrEmpty(s3endpoint), - S3Region: StringOrEmpty(s3region), - S3Bucket: "", - S3PathPrefix: StringOrEmpty(s3pathprefix), - Status: StringOrDefault(status, types.BackupStateUnknown), + ID: types.ObjectID(id), + ContainerID: containerId, + DatabaseName: databaseName, + DatabaseEndpoint: databaseEndpoint, + S3Endpoint: StringOrEmpty(s3endpoint), + S3Region: StringOrEmpty(s3region), + S3Bucket: StringOrEmpty(s3bucket), + S3PathPrefix: StringOrEmpty(s3pathprefix), + Status: StringOrDefault(status, types.BackupStateUnknown), + Message: StringOrEmpty(message), }, nil } @@ -74,7 +84,10 @@ func ReadOperationFromResultSet(res result.Result) (types.Operation, error) { operationStateBuf *string backupId *types.ObjectID ydbOperationId *string - database *string + databaseName *string + databaseEndpoint *string + message *string + createdAt *time.Time ) err := res.ScanNamed( named.Required("id", &operationId), @@ -84,7 +97,10 @@ func ReadOperationFromResultSet(res result.Result) (types.Operation, error) { named.Optional("status", &operationStateBuf), named.Optional("backup_id", &backupId), named.Optional("operation_id", &ydbOperationId), - named.Optional("database", &database), + named.Optional("database", &databaseName), + named.Optional("endpoint", &databaseEndpoint), + named.Optional("message", &message), + named.Optional("created_at", &createdAt), ) if err != nil { return nil, err @@ -94,30 +110,37 @@ func ReadOperationFromResultSet(res result.Result) (types.Operation, error) { operationState = types.OperationState(*operationStateBuf) } if operationType == string(types.OperationTypeTB) { - if backupId == nil || database == nil || ydbOperationId == nil { + if backupId == nil || databaseName == nil || databaseEndpoint == nil || ydbOperationId == nil { return nil, fmt.Errorf("failed to read required fields of operation %s", operationId.String()) } return &types.TakeBackupOperation{ - Id: operationId, - BackupId: types.ObjectID(*backupId), - ContainerID: containerId, - State: operationState, - Message: "", - YdbConnectionParams: types.GetYdbConnectionParams(*database), - YdbOperationId: *ydbOperationId, + Id: operationId, + BackupId: types.ObjectID(*backupId), + ContainerID: containerId, + State: operationState, + Message: StringOrEmpty(message), + YdbConnectionParams: types.YdbConnectionParams{ + Endpoint: *databaseEndpoint, + DatabaseName: *databaseName, + }, + YdbOperationId: *ydbOperationId, + CreatedAt: *createdAt, }, nil } else if operationType == string(types.OperationTypeRB) { - if backupId == nil || database == nil || ydbOperationId == nil { + if backupId == nil || databaseName == nil || databaseEndpoint == nil || ydbOperationId == nil { return nil, fmt.Errorf("failed to read required fields of operation %s", operationId.String()) } return &types.RestoreBackupOperation{ - Id: operationId, - BackupId: types.ObjectID(*backupId), - ContainerID: containerId, - State: operationState, - Message: "", - YdbConnectionParams: types.GetYdbConnectionParams(*database), - YdbOperationId: *ydbOperationId, + Id: operationId, + BackupId: types.ObjectID(*backupId), + ContainerID: containerId, + State: operationState, + Message: StringOrEmpty(message), + YdbConnectionParams: types.YdbConnectionParams{ + Endpoint: *databaseEndpoint, + DatabaseName: *databaseName, + }, + YdbOperationId: *ydbOperationId, }, nil } diff --git a/internal/connectors/db/yql/queries/read.go b/internal/connectors/db/yql/queries/read.go index 97c047fb..f8c8a971 100644 --- a/internal/connectors/db/yql/queries/read.go +++ b/internal/connectors/db/yql/queries/read.go @@ -4,23 +4,24 @@ import ( "context" "errors" "fmt" + "strings" + "ydbcp/internal/util/xlog" + "github.com/ydb-platform/ydb-go-sdk/v3/table" table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" "go.uber.org/zap" - "strings" - "ydbcp/internal/util/xlog" ) var ( AllBackupFields = []string{ - "id", "container_id", "database", + "id", "container_id", "database", "endpoint", "initiated", "created_at", "completed_at", "s3_endpoint", "s3_region", "s3_bucket", - "s3_path_prefix", "status", "paths", + "s3_path_prefix", "status", "paths", "message", } AllOperationFields = []string{ - "id", "type", "container_id", "database", "backup_id", - "initiated", "created_at", "completed_at", "status", + "id", "type", "container_id", "database", "endpoint", "backup_id", + "initiated", "created_at", "completed_at", "status", "message", "paths", "operation_id", } ) diff --git a/internal/connectors/db/yql/queries/write.go b/internal/connectors/db/yql/queries/write.go index da83cb79..35065fc0 100644 --- a/internal/connectors/db/yql/queries/write.go +++ b/internal/connectors/db/yql/queries/write.go @@ -4,12 +4,13 @@ import ( "context" "errors" "fmt" - "github.com/ydb-platform/ydb-go-sdk/v3/table" - table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" - "go.uber.org/zap" "strings" "ydbcp/internal/types" "ydbcp/internal/util/xlog" + + "github.com/ydb-platform/ydb-go-sdk/v3/table" + table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types" + "go.uber.org/zap" ) type WriteTableQuery interface { @@ -47,9 +48,7 @@ func BuildCreateOperationQuery(operation types.Operation, index int) WriteSingle } d.AddValueParam("$id", table_types.UUIDValue(operation.GetId())) d.AddValueParam("$type", table_types.StringValueFromString(string(operation.GetType()))) - d.AddValueParam( - "$status", table_types.StringValueFromString(operation.GetState().String()), - ) + d.AddValueParam("$status", table_types.StringValueFromString(operation.GetState().String())) if operation.GetType() == types.OperationType("TB") { tb := operation.(*types.TakeBackupOperation) d.AddValueParam( @@ -59,6 +58,10 @@ func BuildCreateOperationQuery(operation types.Operation, index int) WriteSingle "$database", table_types.StringValueFromString(tb.YdbConnectionParams.DatabaseName), ) + d.AddValueParam( + "$endpoint", + table_types.StringValueFromString(tb.YdbConnectionParams.Endpoint), + ) d.AddValueParam( "$backup_id", table_types.UUIDValue(tb.BackupId), @@ -69,12 +72,13 @@ func BuildCreateOperationQuery(operation types.Operation, index int) WriteSingle ) d.AddValueParam( "$created_at", - table_types.StringValueFromString(""), //TODO + table_types.TimestampValueFromTime(tb.CreatedAt), //TODO ) d.AddValueParam( "$operation_id", table_types.StringValueFromString(tb.YdbOperationId), ) + d.AddValueParam("$message", table_types.StringValueFromString(tb.Message)) } return d @@ -86,13 +90,8 @@ func BuildUpdateOperationQuery(operation types.Operation, index int) WriteSingle tableName: "Operations", } d.AddValueParam("$id", table_types.UUIDValue(operation.GetId())) - d.AddValueParam( - "$status", table_types.StringValueFromString(operation.GetState().String()), - ) - d.AddValueParam( - "$message", - table_types.StringValueFromString(operation.GetMessage()), - ) + d.AddValueParam("$status", table_types.StringValueFromString(operation.GetState().String())) + d.AddValueParam("$message", table_types.StringValueFromString(operation.GetMessage())) return d } @@ -114,12 +113,14 @@ func BuildCreateBackupQuery(b types.Backup, index int) WriteSingleTableQueryImpl d.AddValueParam("$id", table_types.UUIDValue(b.ID)) d.AddValueParam("$container_id", table_types.StringValueFromString(b.ContainerID)) d.AddValueParam("$database", table_types.StringValueFromString(b.DatabaseName)) + d.AddValueParam("$endpoint", table_types.StringValueFromString(b.DatabaseEndpoint)) d.AddValueParam("$initiated", table_types.StringValueFromString("")) // TODO d.AddValueParam("$s3_endpoint", table_types.StringValueFromString(b.S3Endpoint)) d.AddValueParam("$s3_region", table_types.StringValueFromString(b.S3Region)) d.AddValueParam("$s3_bucket", table_types.StringValueFromString(b.S3Bucket)) d.AddValueParam("$s3_path_prefix", table_types.StringValueFromString(b.S3PathPrefix)) d.AddValueParam("$status", table_types.StringValueFromString(b.Status)) + d.AddValueParam("$message", table_types.StringValueFromString(b.Message)) return d } diff --git a/internal/connectors/db/yql/schema/create_tables.yql b/internal/connectors/db/yql/schema/create_tables.yql index d0f75cb8..067a047c 100644 --- a/internal/connectors/db/yql/schema/create_tables.yql +++ b/internal/connectors/db/yql/schema/create_tables.yql @@ -6,6 +6,7 @@ CREATE TABLE Backups ( id UUID NOT NULL, container_id String NOT NULL, database String NOT NULL, + endpoint String NOT NULL, initiated String, created_at Timestamp, @@ -17,6 +18,7 @@ CREATE TABLE Backups ( s3_path_prefix String, status String, + message String, paths String, @@ -37,6 +39,7 @@ CREATE TABLE Operations ( type String NOT NULL, container_id String NOT NULL, database String NOT NULL, + endpoint String NOT NULL, backup_id UUID, initiated String, @@ -44,6 +47,7 @@ CREATE TABLE Operations ( completed_at Timestamp, status String, + message String, paths String, operation_id String, diff --git a/internal/processor/processor.go b/internal/processor/processor.go index afc17cb7..753d916f 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -14,10 +14,10 @@ import ( ) type OperationProcessorImpl struct { - ctx context.Context - wg *sync.WaitGroup - period time.Duration - handleOperationResultTimeout time.Duration + ctx context.Context + wg *sync.WaitGroup + period time.Duration + handleOperationTimeout time.Duration tickerProvider ticker.TickerProvider handlers OperationHandlerRegistry @@ -39,9 +39,9 @@ func WithTickerProvider(ticketProvider ticker.TickerProvider) Option { o.tickerProvider = ticketProvider } } -func WithHandleOperationResultTimeout(timeout time.Duration) Option { +func WithHandleOperationTimeout(timeout time.Duration) Option { return func(o *OperationProcessorImpl) { - o.handleOperationResultTimeout = timeout + o.handleOperationTimeout = timeout } } @@ -53,15 +53,15 @@ func NewOperationProcessor( options ...Option, ) *OperationProcessorImpl { op := &OperationProcessorImpl{ - ctx: ctx, - period: time.Second * 10, - handleOperationResultTimeout: time.Second * 10, - wg: wg, - handlers: handlers, - db: db, - tickerProvider: ticker.NewRealTicker, - runningOperations: make(map[types.ObjectID]bool), - results: make(chan types.ObjectID), + ctx: ctx, + period: time.Second * 10, + handleOperationTimeout: time.Second * 600, + wg: wg, + handlers: handlers, + db: db, + tickerProvider: ticker.NewRealTicker, + runningOperations: make(map[types.ObjectID]bool), + results: make(chan types.ObjectID), } for _, opt := range options { opt(op) @@ -99,14 +99,14 @@ func (o *OperationProcessorImpl) processOperations() { return } for _, op := range operations { - o.processOperation(ctx, op) + o.processOperation(op) } } -func (o *OperationProcessorImpl) processOperation(ctx context.Context, op types.Operation) { +func (o *OperationProcessorImpl) processOperation(op types.Operation) { if _, exist := o.runningOperations[op.GetId()]; exist { xlog.Debug( - ctx, "operation already running", + o.ctx, "operation already running", zap.String("operation", types.OperationToString(op)), ) return @@ -115,6 +115,8 @@ func (o *OperationProcessorImpl) processOperation(ctx context.Context, op types. o.wg.Add(1) go func() { defer o.wg.Done() + ctx, cancel := context.WithTimeout(o.ctx, o.handleOperationTimeout) + defer cancel() xlog.Debug( ctx, "start operation handler", zap.String("operation", types.OperationToString(op)), @@ -124,6 +126,7 @@ func (o *OperationProcessorImpl) processOperation(ctx context.Context, op types. xlog.Error( ctx, "operation handler failed", zap.String("operation", types.OperationToString(op)), + zap.Error(err), ) } o.results <- op.GetId() @@ -131,47 +134,13 @@ func (o *OperationProcessorImpl) processOperation(ctx context.Context, op types. } func (o *OperationProcessorImpl) handleOperationResult(operationID types.ObjectID) { - ctx, cancel := context.WithTimeout(o.ctx, o.handleOperationResultTimeout) - defer cancel() - - xlog.Debug(ctx, "operation handler is finished", zap.String("operationID", operationID.String())) + xlog.Debug(o.ctx, "operation handler is finished", zap.String("operationID", operationID.String())) if _, exist := o.runningOperations[operationID]; !exist { xlog.Error( - ctx, "got result from not running operation", + o.ctx, "got result from not running operation", zap.String("operationID", operationID.String()), ) return } delete(o.runningOperations, operationID) } - -func (o *OperationProcessorImpl) updateOperationState( - ctx context.Context, - old types.Operation, - new types.Operation, -) error { - changed := false - if old.GetState() != new.GetState() { - xlog.Debug( - ctx, - "operation state changed", - zap.String("OperationId", old.GetId().String()), - zap.String("oldState", old.GetState().String()), - zap.String("newState", new.GetState().String()), - ) - changed = true - } - if old.GetMessage() != new.GetMessage() { - xlog.Debug( - ctx, - "operation message changed", - zap.String("OperationId", old.GetId().String()), - zap.String("Message", new.GetMessage()), - ) - changed = true - } - if !changed { - return nil - } - return o.db.UpdateOperation(ctx, new) -} diff --git a/internal/types/backup.go b/internal/types/backup.go index e63ea567..83e22095 100644 --- a/internal/types/backup.go +++ b/internal/types/backup.go @@ -3,14 +3,16 @@ package types import ( "context" "fmt" - "google.golang.org/protobuf/types/known/timestamppb" "log" "strings" + "google.golang.org/protobuf/types/known/timestamppb" + + "time" + "github.com/google/uuid" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Issue" "go.uber.org/zap" - "time" "ydbcp/internal/util/xlog" pb "ydbcp/pkg/proto" @@ -51,21 +53,24 @@ func ParseObjectId(objectId string) (ObjectID, error) { } type Backup struct { - ID ObjectID - ContainerID string - DatabaseName string - S3Endpoint string - S3Region string - S3Bucket string - S3PathPrefix string - Status string + ID ObjectID + ContainerID string + DatabaseName string + DatabaseEndpoint string + S3Endpoint string + S3Region string + S3Bucket string + S3PathPrefix string + Status string + Message string } func (o *Backup) String() string { return fmt.Sprintf( - "ID: %s, ContainerID: %s, DatabaseName: %s, Status %s", + "ID: %s, ContainerID: %s, DatabaseEndpoint: %s, DatabaseName: %s, Status %s", o.ID, o.ContainerID, + o.DatabaseEndpoint, o.DatabaseName, o.Status, ) @@ -73,15 +78,21 @@ func (o *Backup) String() string { func (o *Backup) Proto() *pb.Backup { return &pb.Backup{ - Id: o.ID.String(), - ContainerId: o.ContainerID, - DatabaseName: o.DatabaseName, - Location: nil, - Audit: nil, - Size: 0, - Status: pb.Backup_Status(pb.Backup_Status_value[o.Status]), - Message: "", - ExpireAt: nil, + Id: o.ID.String(), + ContainerId: o.ContainerID, + DatabaseName: o.DatabaseName, + DatabaseEndpoint: o.DatabaseEndpoint, + Location: &pb.S3Location{ + Endpoint: o.S3Endpoint, + Region: o.S3Region, + Bucket: o.S3Bucket, + PathPrefix: o.S3PathPrefix, + }, + Audit: nil, + Size: 0, + Status: pb.Backup_Status(pb.Backup_Status_value[o.Status]), + Message: o.Message, + ExpireAt: nil, } } @@ -110,6 +121,7 @@ type TakeBackupOperation struct { YdbOperationId string SourcePaths []string SourcePathToExclude []string + CreatedAt time.Time } func (o *TakeBackupOperation) GetId() ObjectID { @@ -142,6 +154,7 @@ func (o *TakeBackupOperation) Proto() *pb.Operation { ContainerId: o.ContainerID, Type: string(OperationTypeTB), DatabaseName: o.YdbConnectionParams.DatabaseName, + DatabaseEndpoint: o.YdbConnectionParams.Endpoint, YdbServerOperationId: o.YdbOperationId, BackupId: o.BackupId.String(), SourcePaths: o.SourcePaths, @@ -195,6 +208,7 @@ func (o *RestoreBackupOperation) Proto() *pb.Operation { ContainerId: o.ContainerID, Type: string(OperationTypeTB), DatabaseName: o.YdbConnectionParams.DatabaseName, + DatabaseEndpoint: o.YdbConnectionParams.Endpoint, YdbServerOperationId: o.YdbOperationId, BackupId: o.BackupId.String(), SourcePaths: nil, @@ -254,17 +268,18 @@ var ( OperationStateError = OperationState(pb.Operation_ERROR.String()) OperationStateCancelling = OperationState(pb.Operation_CANCELLING.String()) OperationStateCancelled = OperationState(pb.Operation_CANCELED.String()) + + BackupStateUnknown = pb.Backup_STATUS_UNSPECIFIED.String() + BackupStatePending = pb.Backup_PENDING.String() + BackupStateAvailable = pb.Backup_AVAILABLE.String() + BackupStateError = pb.Backup_ERROR.String() + BackupStateCancelled = pb.Backup_CANCELLED.String() + BackupStateDeleted = pb.Backup_DELETED.String() ) const ( OperationTypeTB = OperationType("TB") OperationTypeRB = OperationType("RB") - - BackupStateUnknown = "Unknown" - BackupStatePending = "Pending" - BackupStateAvailable = "Available" - BackupStateError = "Error" - BackupStateCancelled = "Cancelled" ) func OperationToString(o Operation) string { @@ -305,13 +320,6 @@ func IssuesToString(issues []*Ydb_Issue.IssueMessage) string { return strings.Join(str, ", ") } -func GetYdbConnectionParams(dbname string) YdbConnectionParams { - return YdbConnectionParams{ - Endpoint: "grpc://localhost:2136", // TODO - DatabaseName: dbname, - } -} - type YdbConnectionParams struct { Endpoint string DatabaseName string diff --git a/pkg/proto/backup.pb.go b/pkg/proto/backup.pb.go index c221541d..7f871998 100644 --- a/pkg/proto/backup.pb.go +++ b/pkg/proto/backup.pb.go @@ -28,7 +28,7 @@ const ( Backup_PENDING Backup_Status = 1 Backup_AVAILABLE Backup_Status = 2 Backup_ERROR Backup_Status = 3 - Backup_CANCELED Backup_Status = 4 + Backup_CANCELLED Backup_Status = 4 Backup_DELETED Backup_Status = 5 ) @@ -39,7 +39,7 @@ var ( 1: "PENDING", 2: "AVAILABLE", 3: "ERROR", - 4: "CANCELED", + 4: "CANCELLED", 5: "DELETED", } Backup_Status_value = map[string]int32{ @@ -47,7 +47,7 @@ var ( "PENDING": 1, "AVAILABLE": 2, "ERROR": 3, - "CANCELED": 4, + "CANCELLED": 4, "DELETED": 5, } ) @@ -84,15 +84,16 @@ type Backup struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - ContainerId string `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` - DatabaseName string `protobuf:"bytes,3,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"` - Location *S3Location `protobuf:"bytes,4,opt,name=location,proto3" json:"location,omitempty"` - Audit *AuditInfo `protobuf:"bytes,5,opt,name=audit,proto3" json:"audit,omitempty"` - Size int64 `protobuf:"varint,6,opt,name=size,proto3" json:"size,omitempty"` - Status Backup_Status `protobuf:"varint,7,opt,name=status,proto3,enum=ydbcp.Backup_Status" json:"status,omitempty"` - Message string `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"` - ExpireAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=expire_at,json=expireAt,proto3" json:"expire_at,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + ContainerId string `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + DatabaseName string `protobuf:"bytes,3,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"` + DatabaseEndpoint string `protobuf:"bytes,4,opt,name=database_endpoint,json=databaseEndpoint,proto3" json:"database_endpoint,omitempty"` + Location *S3Location `protobuf:"bytes,5,opt,name=location,proto3" json:"location,omitempty"` + Audit *AuditInfo `protobuf:"bytes,6,opt,name=audit,proto3" json:"audit,omitempty"` + Size int64 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"` + Status Backup_Status `protobuf:"varint,8,opt,name=status,proto3,enum=ydbcp.Backup_Status" json:"status,omitempty"` + Message string `protobuf:"bytes,9,opt,name=message,proto3" json:"message,omitempty"` + ExpireAt *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=expire_at,json=expireAt,proto3" json:"expire_at,omitempty"` } func (x *Backup) Reset() { @@ -148,6 +149,13 @@ func (x *Backup) GetDatabaseName() string { return "" } +func (x *Backup) GetDatabaseEndpoint() string { + if x != nil { + return x.DatabaseEndpoint + } + return "" +} + func (x *Backup) GetLocation() *S3Location { if x != nil { return x.Location @@ -330,55 +338,58 @@ var file_backup_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x79, 0x64, 0x62, 0x63, 0x70, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb0, 0x03, 0x0a, 0x06, 0x42, 0x61, 0x63, 0x6b, 0x75, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xde, 0x03, 0x0a, 0x06, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x08, 0x6c, 0x6f, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x79, 0x64, - 0x62, 0x63, 0x70, 0x2e, 0x53, 0x33, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, - 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x05, 0x61, 0x75, 0x64, 0x69, - 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, - 0x41, 0x75, 0x64, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, - 0x73, 0x69, 0x7a, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x42, 0x61, 0x63, - 0x6b, 0x75, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x09, - 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x5f, 0x61, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x65, 0x78, 0x70, - 0x69, 0x72, 0x65, 0x41, 0x74, 0x22, 0x62, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x45, 0x4e, 0x44, 0x49, - 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, - 0x45, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x0c, - 0x0a, 0x08, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, - 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x05, 0x22, 0x79, 0x0a, 0x0a, 0x53, 0x33, 0x4c, - 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, - 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, - 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, - 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, - 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x65, 0x66, - 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x74, 0x68, 0x50, 0x72, - 0x65, 0x66, 0x69, 0x78, 0x22, 0x9f, 0x01, 0x0a, 0x09, 0x41, 0x75, 0x64, 0x69, 0x74, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x39, 0x0a, 0x0a, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, - 0x65, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6c, - 0x65, 0x74, 0x65, 0x64, 0x41, 0x74, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x3b, 0x79, 0x64, 0x62, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x61, 0x74, + 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x45, 0x6e, + 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x2d, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, + 0x2e, 0x53, 0x33, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x41, 0x75, 0x64, + 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, + 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x14, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x65, 0x78, 0x70, + 0x69, 0x72, 0x65, 0x5f, 0x61, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, + 0x41, 0x74, 0x22, 0x63, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, + 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x02, + 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x43, + 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, + 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x05, 0x22, 0x79, 0x0a, 0x0a, 0x53, 0x33, 0x4c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, + 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x74, 0x68, 0x50, 0x72, 0x65, 0x66, + 0x69, 0x78, 0x22, 0x9f, 0x01, 0x0a, 0x09, 0x41, 0x75, 0x64, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, + 0x79, 0x64, 0x62, 0x63, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, + 0x79, 0x64, 0x62, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/backup.proto b/pkg/proto/backup.proto index 14cee30e..57522895 100644 --- a/pkg/proto/backup.proto +++ b/pkg/proto/backup.proto @@ -11,18 +11,19 @@ message Backup { PENDING = 1; AVAILABLE = 2; ERROR = 3; - CANCELED = 4; + CANCELLED = 4; DELETED = 5; } string id = 1; string container_id = 2; string database_name = 3; - S3Location location = 4; - AuditInfo audit = 5; - int64 size = 6; - Status status = 7; - string message = 8; - google.protobuf.Timestamp expire_at = 9; + string database_endpoint = 4; + S3Location location = 5; + AuditInfo audit = 6; + int64 size = 7; + Status status = 8; + string message = 9; + google.protobuf.Timestamp expire_at = 10; } message S3Location { diff --git a/pkg/proto/backup_service.pb.go b/pkg/proto/backup_service.pb.go index 181fa2bb..cb99e821 100644 --- a/pkg/proto/backup_service.pb.go +++ b/pkg/proto/backup_service.pb.go @@ -206,7 +206,7 @@ type MakeBackupRequest struct { ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` DatabaseName string `protobuf:"bytes,2,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"` - Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + DatabaseEndpoint string `protobuf:"bytes,3,opt,name=database_endpoint,json=databaseEndpoint,proto3" json:"database_endpoint,omitempty"` SourcePaths []string `protobuf:"bytes,4,rep,name=source_paths,json=sourcePaths,proto3" json:"source_paths,omitempty"` // [(size) = "<=256"]; SourcePathsToExclude []string `protobuf:"bytes,5,rep,name=source_paths_to_exclude,json=sourcePathsToExclude,proto3" json:"source_paths_to_exclude,omitempty"` // [(size) = "<=256"]; } @@ -257,9 +257,9 @@ func (x *MakeBackupRequest) GetDatabaseName() string { return "" } -func (x *MakeBackupRequest) GetEndpoint() string { +func (x *MakeBackupRequest) GetDatabaseEndpoint() string { if x != nil { - return x.Endpoint + return x.DatabaseEndpoint } return "" } @@ -333,7 +333,8 @@ type MakeRestoreRequest struct { ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` BackupId string `protobuf:"bytes,2,opt,name=backup_id,json=backupId,proto3" json:"backup_id,omitempty"` DatabaseName string `protobuf:"bytes,3,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"` - DestinationPrefix string `protobuf:"bytes,4,opt,name=destination_prefix,json=destinationPrefix,proto3" json:"destination_prefix,omitempty"` + DatabaseEndpoint string `protobuf:"bytes,4,opt,name=database_endpoint,json=databaseEndpoint,proto3" json:"database_endpoint,omitempty"` + DestinationPrefix string `protobuf:"bytes,5,opt,name=destination_prefix,json=destinationPrefix,proto3" json:"destination_prefix,omitempty"` } func (x *MakeRestoreRequest) Reset() { @@ -389,6 +390,13 @@ func (x *MakeRestoreRequest) GetDatabaseName() string { return "" } +func (x *MakeRestoreRequest) GetDatabaseEndpoint() string { + if x != nil { + return x.DatabaseEndpoint + } + return "" +} + func (x *MakeRestoreRequest) GetDestinationPrefix() string { if x != nil { return x.DestinationPrefix @@ -421,58 +429,62 @@ var file_backup_service_proto_rawDesc = []byte{ 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x22, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xd1, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xe2, 0x01, 0x0a, 0x11, 0x4d, 0x61, 0x6b, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x35, 0x0a, 0x17, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x65, - 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x14, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, 0x54, 0x6f, 0x45, 0x78, 0x63, 0x6c, 0x75, - 0x64, 0x65, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, - 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x63, - 0x6b, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, - 0x63, 0x6b, 0x75, 0x70, 0x49, 0x64, 0x22, 0xa8, 0x01, 0x0a, 0x12, 0x4d, 0x61, 0x6b, 0x65, 0x52, - 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, - 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x64, - 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x49, 0x64, 0x12, 0x23, 0x0a, - 0x0d, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, - 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x65, 0x66, 0x69, - 0x78, 0x32, 0xbe, 0x02, 0x0a, 0x0d, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x75, - 0x70, 0x73, 0x12, 0x19, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, - 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, - 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x09, 0x47, 0x65, 0x74, - 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x17, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x47, - 0x65, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0d, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x38, - 0x0a, 0x0a, 0x4d, 0x61, 0x6b, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x18, 0x2e, 0x79, - 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4d, 0x61, 0x6b, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4f, - 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x1a, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x11, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, + 0x65, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x35, 0x0a, 0x17, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x5f, 0x74, 0x6f, 0x5f, + 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x14, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, 0x54, 0x6f, 0x45, 0x78, 0x63, 0x6c, + 0x75, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x63, + 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, + 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, + 0x61, 0x63, 0x6b, 0x75, 0x70, 0x49, 0x64, 0x22, 0xd5, 0x01, 0x0a, 0x12, 0x4d, 0x61, 0x6b, 0x65, + 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, + 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, + 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x49, 0x64, 0x12, 0x23, + 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, + 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x32, + 0xbe, 0x02, 0x0a, 0x0d, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, + 0x12, 0x19, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x63, + 0x6b, 0x75, 0x70, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x79, 0x64, + 0x62, 0x63, 0x70, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x42, 0x61, + 0x63, 0x6b, 0x75, 0x70, 0x12, 0x17, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x47, 0x65, 0x74, + 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, + 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x38, 0x0a, 0x0a, + 0x4d, 0x61, 0x6b, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x18, 0x2e, 0x79, 0x64, 0x62, + 0x63, 0x70, 0x2e, 0x4d, 0x61, 0x6b, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x0b, 0x4d, 0x61, 0x6b, 0x65, 0x52, 0x65, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x19, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4d, 0x61, - 0x6b, 0x65, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x79, 0x64, 0x62, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x79, 0x64, - 0x62, 0x63, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x79, 0x64, - 0x62, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x12, 0x1a, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x0b, 0x4d, 0x61, 0x6b, 0x65, 0x52, 0x65, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x12, 0x19, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4d, 0x61, 0x6b, 0x65, + 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, + 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, + 0x64, 0x62, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x63, + 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x79, 0x64, 0x62, 0x63, + 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/backup_service.proto b/pkg/proto/backup_service.proto index 057b2cd0..9a2e1291 100644 --- a/pkg/proto/backup_service.proto +++ b/pkg/proto/backup_service.proto @@ -47,7 +47,7 @@ message GetBackupRequest { message MakeBackupRequest { string container_id = 1; string database_name = 2; - string endpoint = 3; + string database_endpoint = 3; repeated string source_paths = 4; // [(size) = "<=256"]; repeated string source_paths_to_exclude = 5; // [(size) = "<=256"]; } @@ -60,5 +60,6 @@ message MakeRestoreRequest { string container_id = 1; string backup_id = 2; string database_name = 3; - string destination_prefix = 4; + string database_endpoint = 4; + string destination_prefix = 5; } diff --git a/pkg/proto/operation.pb.go b/pkg/proto/operation.pb.go index c5834cb6..313d6a00 100644 --- a/pkg/proto/operation.pb.go +++ b/pkg/proto/operation.pb.go @@ -87,14 +87,15 @@ type Operation struct { ContainerId string `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` DatabaseName string `protobuf:"bytes,4,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"` - YdbServerOperationId string `protobuf:"bytes,5,opt,name=ydb_server_operation_id,json=ydbServerOperationId,proto3" json:"ydb_server_operation_id,omitempty"` - BackupId string `protobuf:"bytes,6,opt,name=backup_id,json=backupId,proto3" json:"backup_id,omitempty"` - SourcePaths []string `protobuf:"bytes,7,rep,name=source_paths,json=sourcePaths,proto3" json:"source_paths,omitempty"` // [(size) = "<=256"]; - SourcePathsToExclude []string `protobuf:"bytes,8,rep,name=source_paths_to_exclude,json=sourcePathsToExclude,proto3" json:"source_paths_to_exclude,omitempty"` // [(size) = "<=256"]; - RestorePaths []string `protobuf:"bytes,9,rep,name=restore_paths,json=restorePaths,proto3" json:"restore_paths,omitempty"` // [(size) = "<=256"]; - Audit *AuditInfo `protobuf:"bytes,10,opt,name=audit,proto3" json:"audit,omitempty"` - Status Operation_Status `protobuf:"varint,11,opt,name=status,proto3,enum=ydbcp.Operation_Status" json:"status,omitempty"` - Message string `protobuf:"bytes,12,opt,name=message,proto3" json:"message,omitempty"` + DatabaseEndpoint string `protobuf:"bytes,5,opt,name=database_endpoint,json=databaseEndpoint,proto3" json:"database_endpoint,omitempty"` + YdbServerOperationId string `protobuf:"bytes,6,opt,name=ydb_server_operation_id,json=ydbServerOperationId,proto3" json:"ydb_server_operation_id,omitempty"` + BackupId string `protobuf:"bytes,7,opt,name=backup_id,json=backupId,proto3" json:"backup_id,omitempty"` + SourcePaths []string `protobuf:"bytes,8,rep,name=source_paths,json=sourcePaths,proto3" json:"source_paths,omitempty"` // [(size) = "<=256"]; + SourcePathsToExclude []string `protobuf:"bytes,9,rep,name=source_paths_to_exclude,json=sourcePathsToExclude,proto3" json:"source_paths_to_exclude,omitempty"` // [(size) = "<=256"]; + RestorePaths []string `protobuf:"bytes,10,rep,name=restore_paths,json=restorePaths,proto3" json:"restore_paths,omitempty"` // [(size) = "<=256"]; + Audit *AuditInfo `protobuf:"bytes,11,opt,name=audit,proto3" json:"audit,omitempty"` + Status Operation_Status `protobuf:"varint,12,opt,name=status,proto3,enum=ydbcp.Operation_Status" json:"status,omitempty"` + Message string `protobuf:"bytes,13,opt,name=message,proto3" json:"message,omitempty"` } func (x *Operation) Reset() { @@ -157,6 +158,13 @@ func (x *Operation) GetDatabaseName() string { return "" } +func (x *Operation) GetDatabaseEndpoint() string { + if x != nil { + return x.DatabaseEndpoint + } + return "" +} + func (x *Operation) GetYdbServerOperationId() string { if x != nil { return x.YdbServerOperationId @@ -218,7 +226,7 @@ var File_operation_proto protoreflect.FileDescriptor var file_operation_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x79, 0x64, 0x62, 0x63, 0x70, 0x1a, 0x0c, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9f, 0x04, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcc, 0x04, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, @@ -226,37 +234,39 @@ var file_operation_proto_rawDesc = []byte{ 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x35, 0x0a, 0x17, 0x79, 0x64, 0x62, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6f, - 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x14, 0x79, 0x64, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x65, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x63, 0x6b, 0x75, - 0x70, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x63, 0x6b, - 0x75, 0x70, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, - 0x61, 0x74, 0x68, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x35, 0x0a, 0x17, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x65, 0x78, 0x63, 0x6c, 0x75, - 0x64, 0x65, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x14, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x50, 0x61, 0x74, 0x68, 0x73, 0x54, 0x6f, 0x45, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x12, 0x23, - 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, - 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x50, 0x61, - 0x74, 0x68, 0x73, 0x12, 0x26, 0x0a, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x74, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x79, 0x64, - 0x62, 0x63, 0x70, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x60, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x45, 0x4e, 0x44, - 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x4f, 0x4e, 0x45, 0x10, 0x02, 0x12, - 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x41, - 0x4e, 0x43, 0x45, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x41, - 0x4e, 0x43, 0x45, 0x4c, 0x45, 0x44, 0x10, 0x05, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, - 0x6f, 0x72, 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x3b, 0x79, 0x64, 0x62, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x65, 0x6e, 0x64, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x64, 0x61, 0x74, + 0x61, 0x62, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x35, 0x0a, + 0x17, 0x79, 0x64, 0x62, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, + 0x79, 0x64, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x69, + 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x49, + 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, + 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, + 0x61, 0x74, 0x68, 0x73, 0x12, 0x35, 0x0a, 0x17, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, + 0x61, 0x74, 0x68, 0x73, 0x5f, 0x74, 0x6f, 0x5f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x14, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, + 0x68, 0x73, 0x54, 0x6f, 0x45, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x72, + 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, + 0x12, 0x26, 0x0a, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x74, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x05, 0x61, 0x75, 0x64, 0x69, 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x79, 0x64, 0x62, 0x63, 0x70, + 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x22, 0x60, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, + 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, + 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x4f, 0x4e, 0x45, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, + 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x41, 0x4e, 0x43, 0x45, + 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x41, 0x4e, 0x43, 0x45, + 0x4c, 0x45, 0x44, 0x10, 0x05, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x64, 0x62, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, + 0x2f, 0x79, 0x64, 0x62, 0x63, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x3b, 0x79, 0x64, 0x62, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/operation.proto b/pkg/proto/operation.proto index b55faa54..97c3193a 100644 --- a/pkg/proto/operation.proto +++ b/pkg/proto/operation.proto @@ -18,12 +18,13 @@ message Operation { string container_id = 2; string type = 3; string database_name = 4; - string ydb_server_operation_id = 5; - string backup_id = 6; - repeated string source_paths = 7; // [(size) = "<=256"]; - repeated string source_paths_to_exclude = 8; // [(size) = "<=256"]; - repeated string restore_paths = 9; // [(size) = "<=256"]; - AuditInfo audit = 10; - Status status = 11; - string message = 12; + string database_endpoint = 5; + string ydb_server_operation_id = 6; + string backup_id = 7; + repeated string source_paths = 8; // [(size) = "<=256"]; + repeated string source_paths_to_exclude = 9; // [(size) = "<=256"]; + repeated string restore_paths = 10; // [(size) = "<=256"]; + AuditInfo audit = 11; + Status status = 12; + string message = 13; } diff --git a/test.sh b/test.sh index 09760bf8..1f630903 100755 --- a/test.sh +++ b/test.sh @@ -7,11 +7,15 @@ if [[ "GetBackup" == "$1" ]]; then doneflag=1 fi if [[ "ListBackups" == "$1" ]]; then - grpcurl -plaintext -d '{"databaseNameMask": "", "containerId": ""}' localhost:50051 ydbcp.BackupService.ListBackups + grpcurl -plaintext -d '{"databaseNameMask": "%", "containerId": ""}' localhost:50051 ydbcp.BackupService.ListBackups doneflag=1 fi if [[ "ListOperations" == "$1" ]]; then - grpcurl -plaintext -d '{"databaseNameMask": "", "containerId": ""}' localhost:50051 ydbcp.OperationService.ListOperations + grpcurl -plaintext -d '{"databaseNameMask": "%", "containerId": ""}' localhost:50051 ydbcp.OperationService.ListOperations + doneflag=1 +fi +if [[ "TakeBackup" == "$1" ]]; then + grpcurl -plaintext -d '{"database_name": "/testing-global/ydbc", "database_endpoint": "grpcs://localhost:2135", "source_paths": ["/testing-global/ydbc/orders"]}' localhost:50051 ydbcp.BackupService.MakeBackup doneflag=1 fi if [[ 0 == $doneflag ]]; then