Skip to content

Commit fd7efa2

Browse files
Google APIscopybara-github
Google APIs
authored andcommitted
feat(spanner): Add support for Cloud Spanner Scheduled Backups
PiperOrigin-RevId: 649277844
1 parent 7fe35b0 commit fd7efa2

File tree

5 files changed

+326
-0
lines changed

5 files changed

+326
-0
lines changed

google/spanner/admin/database/v1/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ proto_library(
5151
name = "database_proto",
5252
srcs = [
5353
"backup.proto",
54+
"backup_schedule.proto",
5455
"common.proto",
5556
"spanner_database_admin.proto",
5657
],
@@ -63,6 +64,7 @@ proto_library(
6364
"//google/iam/v1:policy_proto",
6465
"//google/longrunning:operations_proto",
6566
"//google/rpc:status_proto",
67+
"@com_google_protobuf//:duration_proto",
6668
"@com_google_protobuf//:empty_proto",
6769
"@com_google_protobuf//:field_mask_proto",
6870
"@com_google_protobuf//:timestamp_proto",

google/spanner/admin/database/v1/backup.proto

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ message Backup {
156156
// less than `Backup.max_expire_time`.
157157
google.protobuf.Timestamp max_expire_time = 12
158158
[(google.api.field_behavior) = OUTPUT_ONLY];
159+
160+
// Output only. List of backup schedule URIs that are associated with
161+
// creating this backup. This is only applicable for scheduled backups, and
162+
// is empty for on-demand backups.
163+
//
164+
// To optimize for storage, whenever possible, multiple schedules are
165+
// collapsed together to create one backup. In such cases, this field captures
166+
// the list of all backup schedule URIs that are associated with creating
167+
// this backup. If collapsing is not done, then this field captures the
168+
// single backup schedule URI associated with creating this backup.
169+
repeated string backup_schedules = 14
170+
[(google.api.field_behavior) = OUTPUT_ONLY];
159171
}
160172

161173
// The request for
@@ -688,3 +700,8 @@ message CopyBackupEncryptionConfig {
688700
}
689701
];
690702
}
703+
704+
// The specification for full backups.
705+
// A full backup stores the entire contents of the database at a given
706+
// version time.
707+
message FullBackupSpec {}
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.spanner.admin.database.v1;
18+
19+
import "google/api/field_behavior.proto";
20+
import "google/api/resource.proto";
21+
import "google/protobuf/duration.proto";
22+
import "google/protobuf/field_mask.proto";
23+
import "google/protobuf/timestamp.proto";
24+
import "google/spanner/admin/database/v1/backup.proto";
25+
26+
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
27+
option go_package = "cloud.google.com/go/spanner/admin/database/apiv1/databasepb;databasepb";
28+
option java_multiple_files = true;
29+
option java_outer_classname = "BackupScheduleProto";
30+
option java_package = "com.google.spanner.admin.database.v1";
31+
option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
32+
option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1";
33+
34+
// Defines specifications of the backup schedule.
35+
message BackupScheduleSpec {
36+
// Required.
37+
oneof schedule_spec {
38+
// Cron style schedule specification.
39+
CrontabSpec cron_spec = 1;
40+
}
41+
}
42+
43+
// BackupSchedule expresses the automated backup creation specification for a
44+
// Spanner database.
45+
// Next ID: 10
46+
message BackupSchedule {
47+
option (google.api.resource) = {
48+
type: "spanner.googleapis.com/BackupSchedule"
49+
pattern: "projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule}"
50+
plural: "backupSchedules"
51+
singular: "backupSchedule"
52+
};
53+
54+
// Identifier. Output only for the
55+
// [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
56+
// Required for the
57+
// [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
58+
// operation. A globally unique identifier for the backup schedule which
59+
// cannot be changed. Values are of the form
60+
// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
61+
// The final segment of the name must be between 2 and 60 characters in
62+
// length.
63+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
64+
65+
// Optional. The schedule specification based on which the backup creations
66+
// are triggered.
67+
BackupScheduleSpec spec = 6 [(google.api.field_behavior) = OPTIONAL];
68+
69+
// Optional. The retention duration of a backup that must be at least 6 hours
70+
// and at most 366 days. The backup is eligible to be automatically deleted
71+
// once the retention period has elapsed.
72+
google.protobuf.Duration retention_duration = 3
73+
[(google.api.field_behavior) = OPTIONAL];
74+
75+
// Optional. The encryption configuration that will be used to encrypt the
76+
// backup. If this field is not specified, the backup will use the same
77+
// encryption configuration as the database.
78+
CreateBackupEncryptionConfig encryption_config = 4
79+
[(google.api.field_behavior) = OPTIONAL];
80+
81+
// Required. Backup type spec determines the type of backup that is created by
82+
// the backup schedule. Currently, only full backups are supported.
83+
oneof backup_type_spec {
84+
// The schedule creates only full backups.
85+
FullBackupSpec full_backup_spec = 7;
86+
}
87+
88+
// Output only. The timestamp at which the schedule was last updated.
89+
// If the schedule has never been updated, this field contains the timestamp
90+
// when the schedule was first created.
91+
google.protobuf.Timestamp update_time = 9
92+
[(google.api.field_behavior) = OUTPUT_ONLY];
93+
}
94+
95+
// CrontabSpec can be used to specify the version time and frequency at
96+
// which the backup should be created.
97+
message CrontabSpec {
98+
// Required. Textual representation of the crontab. User can customize the
99+
// backup frequency and the backup version time using the cron
100+
// expression. The version time must be in UTC timzeone.
101+
//
102+
// The backup will contain an externally consistent copy of the
103+
// database at the version time. Allowed frequencies are 12 hour, 1 day,
104+
// 1 week and 1 month. Examples of valid cron specifications:
105+
// * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
106+
// * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
107+
// * `0 2 * * * ` : once a day at 2 past midnight in UTC.
108+
// * `0 2 * * 0 ` : once a week every Sunday at 2 past midnight in UTC.
109+
// * `0 2 8 * * ` : once a month on 8th day at 2 past midnight in UTC.
110+
string text = 1 [(google.api.field_behavior) = REQUIRED];
111+
112+
// Output only. The time zone of the times in `CrontabSpec.text`. Currently
113+
// only UTC is supported.
114+
string time_zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
115+
116+
// Output only. Schedule backups will contain an externally consistent copy
117+
// of the database at the version time specified in
118+
// `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
119+
// of the scheduled backups at that version time. Spanner will initiate
120+
// the creation of scheduled backups within the time window bounded by the
121+
// version_time specified in `schedule_spec.cron_spec` and version_time +
122+
// `creation_window`.
123+
google.protobuf.Duration creation_window = 3
124+
[(google.api.field_behavior) = OUTPUT_ONLY];
125+
}
126+
127+
// The request for
128+
// [CreateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule].
129+
message CreateBackupScheduleRequest {
130+
// Required. The name of the database that this backup schedule applies to.
131+
string parent = 1 [
132+
(google.api.field_behavior) = REQUIRED,
133+
(google.api.resource_reference) = {
134+
type: "spanner.googleapis.com/Database"
135+
}
136+
];
137+
138+
// Required. The Id to use for the backup schedule. The `backup_schedule_id`
139+
// appended to `parent` forms the full backup schedule name of the form
140+
// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
141+
string backup_schedule_id = 2 [(google.api.field_behavior) = REQUIRED];
142+
143+
// Required. The backup schedule to create.
144+
BackupSchedule backup_schedule = 3 [(google.api.field_behavior) = REQUIRED];
145+
}
146+
147+
// The request for
148+
// [GetBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule].
149+
message GetBackupScheduleRequest {
150+
// Required. The name of the schedule to retrieve.
151+
// Values are of the form
152+
// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
153+
string name = 1 [
154+
(google.api.field_behavior) = REQUIRED,
155+
(google.api.resource_reference) = {
156+
type: "spanner.googleapis.com/BackupSchedule"
157+
}
158+
];
159+
}
160+
161+
// The request for
162+
// [DeleteBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule].
163+
message DeleteBackupScheduleRequest {
164+
// Required. The name of the schedule to delete.
165+
// Values are of the form
166+
// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
167+
string name = 1 [
168+
(google.api.field_behavior) = REQUIRED,
169+
(google.api.resource_reference) = {
170+
type: "spanner.googleapis.com/BackupSchedule"
171+
}
172+
];
173+
}
174+
175+
// The request for
176+
// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
177+
message ListBackupSchedulesRequest {
178+
// Required. Database is the parent resource whose backup schedules should be
179+
// listed. Values are of the form
180+
// projects/<project>/instances/<instance>/databases/<database>
181+
string parent = 1 [
182+
(google.api.field_behavior) = REQUIRED,
183+
(google.api.resource_reference) = {
184+
type: "spanner.googleapis.com/Database"
185+
}
186+
];
187+
188+
// Optional. Number of backup schedules to be returned in the response. If 0
189+
// or less, defaults to the server's maximum allowed page size.
190+
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
191+
192+
// Optional. If non-empty, `page_token` should contain a
193+
// [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
194+
// from a previous
195+
// [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
196+
// to the same `parent`.
197+
string page_token = 4 [(google.api.field_behavior) = OPTIONAL];
198+
}
199+
200+
// The response for
201+
// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
202+
message ListBackupSchedulesResponse {
203+
// The list of backup schedules for a database.
204+
repeated BackupSchedule backup_schedules = 1;
205+
206+
// `next_page_token` can be sent in a subsequent
207+
// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
208+
// call to fetch more of the schedules.
209+
string next_page_token = 2;
210+
}
211+
212+
// The request for
213+
// [UpdateBackupScheduleRequest][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule].
214+
message UpdateBackupScheduleRequest {
215+
// Required. The backup schedule to update. `backup_schedule.name`, and the
216+
// fields to be updated as specified by `update_mask` are required. Other
217+
// fields are ignored.
218+
BackupSchedule backup_schedule = 1 [(google.api.field_behavior) = REQUIRED];
219+
220+
// Required. A mask specifying which fields in the BackupSchedule resource
221+
// should be updated. This mask is relative to the BackupSchedule resource,
222+
// not to the request message. The field mask must always be
223+
// specified; this prevents any future fields from being erased
224+
// accidentally.
225+
google.protobuf.FieldMask update_mask = 2
226+
[(google.api.field_behavior) = REQUIRED];
227+
}

google/spanner/admin/database/v1/spanner_admin_database_grpc_service_config.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@
5353
{
5454
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
5555
"method": "ListDatabaseRoles"
56+
},
57+
{
58+
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
59+
"method": "CreateBackupSchedule"
60+
},
61+
{
62+
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
63+
"method": "GetBackupSchedule"
64+
},
65+
{
66+
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
67+
"method": "UpdateBackupSchedule"
68+
},
69+
{
70+
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
71+
"method": "DeleteBackupSchedule"
72+
},
73+
{
74+
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
75+
"method": "ListBackupSchedules"
5676
}
5777
],
5878
"timeout": "3600s",

google/spanner/admin/database/v1/spanner_database_admin.proto

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import "google/protobuf/empty.proto";
2727
import "google/protobuf/field_mask.proto";
2828
import "google/protobuf/timestamp.proto";
2929
import "google/spanner/admin/database/v1/backup.proto";
30+
import "google/spanner/admin/database/v1/backup_schedule.proto";
3031
import "google/spanner/admin/database/v1/common.proto";
3132

3233
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
@@ -199,6 +200,10 @@ service DatabaseAdmin {
199200
post: "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy"
200201
body: "*"
201202
}
203+
additional_bindings {
204+
post: "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:setIamPolicy"
205+
body: "*"
206+
}
202207
};
203208
option (google.api.method_signature) = "resource,policy";
204209
}
@@ -220,6 +225,10 @@ service DatabaseAdmin {
220225
post: "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy"
221226
body: "*"
222227
}
228+
additional_bindings {
229+
post: "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:getIamPolicy"
230+
body: "*"
231+
}
223232
};
224233
option (google.api.method_signature) = "resource";
225234
}
@@ -243,6 +252,10 @@ service DatabaseAdmin {
243252
post: "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions"
244253
body: "*"
245254
}
255+
additional_bindings {
256+
post: "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:testIamPermissions"
257+
body: "*"
258+
}
246259
additional_bindings {
247260
post: "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions"
248261
body: "*"
@@ -411,6 +424,53 @@ service DatabaseAdmin {
411424
};
412425
option (google.api.method_signature) = "parent";
413426
}
427+
428+
// Creates a new backup schedule.
429+
rpc CreateBackupSchedule(CreateBackupScheduleRequest)
430+
returns (BackupSchedule) {
431+
option (google.api.http) = {
432+
post: "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules"
433+
body: "backup_schedule"
434+
};
435+
option (google.api.method_signature) =
436+
"parent,backup_schedule,backup_schedule_id";
437+
}
438+
439+
// Gets backup schedule for the input schedule name.
440+
rpc GetBackupSchedule(GetBackupScheduleRequest) returns (BackupSchedule) {
441+
option (google.api.http) = {
442+
get: "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}"
443+
};
444+
option (google.api.method_signature) = "name";
445+
}
446+
447+
// Updates a backup schedule.
448+
rpc UpdateBackupSchedule(UpdateBackupScheduleRequest)
449+
returns (BackupSchedule) {
450+
option (google.api.http) = {
451+
patch: "/v1/{backup_schedule.name=projects/*/instances/*/databases/*/backupSchedules/*}"
452+
body: "backup_schedule"
453+
};
454+
option (google.api.method_signature) = "backup_schedule,update_mask";
455+
}
456+
457+
// Deletes a backup schedule.
458+
rpc DeleteBackupSchedule(DeleteBackupScheduleRequest)
459+
returns (google.protobuf.Empty) {
460+
option (google.api.http) = {
461+
delete: "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}"
462+
};
463+
option (google.api.method_signature) = "name";
464+
}
465+
466+
// Lists all the backup schedules for the database.
467+
rpc ListBackupSchedules(ListBackupSchedulesRequest)
468+
returns (ListBackupSchedulesResponse) {
469+
option (google.api.http) = {
470+
get: "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules"
471+
};
472+
option (google.api.method_signature) = "parent";
473+
}
414474
}
415475

416476
// Information about the database restore.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy