1- // Copyright 2021 Google LLC
1+ // Copyright 2022 Google LLC
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -119,6 +119,27 @@ message Backup {
119119
120120 // Output only. The database dialect information for the backup.
121121 DatabaseDialect database_dialect = 10 [(google.api.field_behavior ) = OUTPUT_ONLY ];
122+
123+ // Output only. The names of the destination backups being created by copying
124+ // this source backup. The backup names are of the form
125+ // `projects/<project>/instances/<instance>/backups/<backup>`.
126+ // Referencing backups may exist in different instances. The existence of
127+ // any referencing backup prevents the backup from being deleted. When the
128+ // copy operation is done (either successfully completed or cancelled or the
129+ // destination backup is deleted), the reference to the backup is removed.
130+ repeated string referencing_backups = 11 [
131+ (google.api.field_behavior ) = OUTPUT_ONLY ,
132+ (google.api.resource_reference ) = {
133+ type : "spanner.googleapis.com/Backup"
134+ }
135+ ];
136+
137+ // Output only. The max allowed expiration time of the backup, with
138+ // microseconds granularity. A backup's expiration time can be configured in
139+ // multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
140+ // copying an existing backup, the expiration time specified must be
141+ // less than `Backup.max_expire_time`.
142+ google.protobuf.Timestamp max_expire_time = 12 [(google.api.field_behavior ) = OUTPUT_ONLY ];
122143}
123144
124145// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
@@ -184,6 +205,86 @@ message CreateBackupMetadata {
184205 google.protobuf.Timestamp cancel_time = 4 ;
185206}
186207
208+ // The request for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
209+ message CopyBackupRequest {
210+ // Required. The name of the destination instance that will contain the backup copy.
211+ // Values are of the form: `projects/<project>/instances/<instance>`.
212+ string parent = 1 [
213+ (google.api.field_behavior ) = REQUIRED ,
214+ (google.api.resource_reference ) = {
215+ type : "spanner.googleapis.com/Instance"
216+ }
217+ ];
218+
219+ // Required. The id of the backup copy.
220+ // The `backup_id` appended to `parent` forms the full backup_uri of the form
221+ // `projects/<project>/instances/<instance>/backups/<backup>`.
222+ string backup_id = 2 [(google.api.field_behavior ) = REQUIRED ];
223+
224+ // Required. The source backup to be copied.
225+ // The source backup needs to be in READY state for it to be copied.
226+ // Once CopyBackup is in progress, the source backup cannot be deleted or
227+ // cleaned up on expiration until CopyBackup is finished.
228+ // Values are of the form:
229+ // `projects/<project>/instances/<instance>/backups/<backup>`.
230+ string source_backup = 3 [
231+ (google.api.field_behavior ) = REQUIRED ,
232+ (google.api.resource_reference ) = {
233+ type : "spanner.googleapis.com/Backup"
234+ }
235+ ];
236+
237+ // Required. The expiration time of the backup in microsecond granularity.
238+ // The expiration time must be at least 6 hours and at most 366 days
239+ // from the `create_time` of the source backup. Once the `expire_time` has
240+ // passed, the backup is eligible to be automatically deleted by Cloud Spanner
241+ // to free the resources used by the backup.
242+ google.protobuf.Timestamp expire_time = 4 [(google.api.field_behavior ) = REQUIRED ];
243+
244+ // Optional. The encryption configuration used to encrypt the backup. If this field is
245+ // not specified, the backup will use the same
246+ // encryption configuration as the source backup by default, namely
247+ // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] =
248+ // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
249+ CopyBackupEncryptionConfig encryption_config = 5 [(google.api.field_behavior ) = OPTIONAL ];
250+ }
251+
252+ // Metadata type for the google.longrunning.Operation returned by
253+ // [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
254+ message CopyBackupMetadata {
255+ // The name of the backup being created through the copy operation.
256+ // Values are of the form
257+ // `projects/<project>/instances/<instance>/backups/<backup>`.
258+ string name = 1 [(google.api.resource_reference ) = {
259+ type : "spanner.googleapis.com/Backup"
260+ }];
261+
262+ // The name of the source backup that is being copied.
263+ // Values are of the form
264+ // `projects/<project>/instances/<instance>/backups/<backup>`.
265+ string source_backup = 2 [(google.api.resource_reference ) = {
266+ type : "spanner.googleapis.com/Backup"
267+ }];
268+
269+ // The progress of the
270+ // [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] operation.
271+ OperationProgress progress = 3 ;
272+
273+ // The time at which cancellation of CopyBackup operation was received.
274+ // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
275+ // starts asynchronous cancellation on a long-running operation. The server
276+ // makes a best effort to cancel the operation, but success is not guaranteed.
277+ // Clients can use
278+ // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
279+ // other methods to check whether the cancellation succeeded or whether the
280+ // operation completed despite cancellation. On successful cancellation,
281+ // the operation is not deleted; instead, it becomes an operation with
282+ // an [Operation.error][google.longrunning.Operation.error] value with a
283+ // [google.rpc.Status.code][google.rpc.Status.code] of 1,
284+ // corresponding to `Code.CANCELLED`.
285+ google.protobuf.Timestamp cancel_time = 4 ;
286+ }
287+
187288// The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
188289message UpdateBackupRequest {
189290 // Required. The backup to update. `backup.name`, and the fields to be updated
@@ -326,6 +427,8 @@ message ListBackupOperationsRequest {
326427 // for [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] is
327428 // `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
328429 // * `metadata.<field_name>` - any field in metadata.value.
430+ // `metadata.@type` must be specified first if filtering on metadata
431+ // fields.
329432 // * `error` - Error associated with the long-running operation.
330433 // * `response.@type` - the type of response.
331434 // * `response.<field_name>` - any field in response.value.
@@ -337,8 +440,11 @@ message ListBackupOperationsRequest {
337440 // Here are a few examples:
338441 //
339442 // * `done:true` - The operation is complete.
340- // * `metadata.database:prod` - The database the backup was taken from has
341- // a name containing the string "prod".
443+ // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
444+ // `metadata.database:prod` - Returns operations where:
445+ // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
446+ // * The database the backup was taken from has a name containing the
447+ // string "prod".
342448 // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
343449 // `(metadata.name:howl) AND` \
344450 // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
@@ -347,6 +453,29 @@ message ListBackupOperationsRequest {
347453 // * The backup name contains the string "howl".
348454 // * The operation started before 2018-03-28T14:50:00Z.
349455 // * The operation resulted in an error.
456+ // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \
457+ // `(metadata.source_backup:test) AND` \
458+ // `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \
459+ // `(error:*)` - Returns operations where:
460+ // * The operation's metadata type is [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
461+ // * The source backup of the copied backup name contains the string
462+ // "test".
463+ // * The operation started before 2022-01-18T14:50:00Z.
464+ // * The operation resulted in an error.
465+ // * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
466+ // `(metadata.database:test_db)) OR` \
467+ // `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata)
468+ // AND` \
469+ // `(metadata.source_backup:test_bkp)) AND` \
470+ // `(error:*)` - Returns operations where:
471+ // * The operation's metadata matches either of criteria:
472+ // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] AND the
473+ // database the backup was taken from has name containing string
474+ // "test_db"
475+ // * The operation's metadata type is [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] AND the
476+ // backup the backup was copied from has name containing string
477+ // "test_bkp"
478+ // * The operation resulted in an error.
350479 string filter = 2 ;
351480
352481 // Number of operations to be returned in the response. If 0 or
@@ -365,11 +494,11 @@ message ListBackupOperationsRequest {
365494message ListBackupOperationsResponse {
366495 // The list of matching backup [long-running
367496 // operations][google.longrunning.Operation]. Each operation's name will be
368- // prefixed by the backup's name and the operation's
369- // [metadata][google.longrunning.Operation.metadata] will be of type
370- // [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. Operations returned include those that are
371- // pending or have completed/failed/canceled within the last 7 days.
372- // Operations returned are ordered by
497+ // prefixed by the backup's name. The operation's
498+ // [metadata][google.longrunning.Operation.metadata] field type
499+ // `metadata.type_url` describes the type of the metadata. Operations returned
500+ // include those that are pending or have completed/failed/canceled within the
501+ // last 7 days. Operations returned are ordered by
373502 // `operation.metadata.value.progress.start_time` in descending order starting
374503 // from the most recently started operation.
375504 repeated google.longrunning.Operation operations = 1 ;
@@ -441,3 +570,40 @@ message CreateBackupEncryptionConfig {
441570 }
442571 ];
443572}
573+
574+ // Encryption configuration for the copied backup.
575+ message CopyBackupEncryptionConfig {
576+ // Encryption types for the backup.
577+ enum EncryptionType {
578+ // Unspecified. Do not use.
579+ ENCRYPTION_TYPE_UNSPECIFIED = 0 ;
580+
581+ // This is the default option for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]
582+ // when [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] is not specified.
583+ // For example, if the source backup is using `Customer_Managed_Encryption`,
584+ // the backup will be using the same Cloud KMS key as the source backup.
585+ USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1 ;
586+
587+ // Use Google default encryption.
588+ GOOGLE_DEFAULT_ENCRYPTION = 2 ;
589+
590+ // Use customer managed encryption. If specified, `kms_key_name`
591+ // must contain a valid Cloud KMS key.
592+ CUSTOMER_MANAGED_ENCRYPTION = 3 ;
593+ }
594+
595+ // Required. The encryption type of the backup.
596+ EncryptionType encryption_type = 1 [(google.api.field_behavior ) = REQUIRED ];
597+
598+ // Optional. The Cloud KMS key that will be used to protect the backup.
599+ // This field should be set only when
600+ // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is
601+ // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
602+ // `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
603+ string kms_key_name = 2 [
604+ (google.api.field_behavior ) = OPTIONAL ,
605+ (google.api.resource_reference ) = {
606+ type : "cloudkms.googleapis.com/CryptoKey"
607+ }
608+ ];
609+ }
0 commit comments