Class: Google::Cloud::Bigtable::Backup
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::Backup
- Defined in:
- lib/google/cloud/bigtable/backup.rb,
lib/google/cloud/bigtable/backup/job.rb,
lib/google/cloud/bigtable/backup/list.rb
Overview
Backup
A backup of a Cloud Bigtable table. See Cluster#create_backup, Cluster#backup and Cluster#backups.
Defined Under Namespace
Instance Method Summary collapse
-
#backup_id ⇒ String
The unique identifier for the backup.
-
#cluster_id ⇒ String
The unique identifier for the cluster to which the backup belongs.
-
#copy(dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:, expire_time:) ⇒ Google::Cloud::Bigtable::Backup::Job
Creates a copy of the backup at the desired location.
-
#creating? ⇒ Boolean
The backup is currently being created, and may be destroyed if the creation process encounters an error.
-
#delete ⇒ Boolean
Permanently deletes the backup.
-
#encryption_info ⇒ Google::Cloud::Bigtable::EncryptionInfo
The encryption information for the backup.
-
#end_time ⇒ Time
The time that the backup was finished.
-
#expire_time ⇒ Time
The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 30 days from the time the request is received.
-
#expire_time=(new_expire_time) ⇒ Object
Sets the expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 30 days from the time the request is received.
-
#instance_id ⇒ String
The unique identifier for the instance to which the backup belongs.
-
#path ⇒ String
The unique name of the backup.
-
#policy {|policy| ... } ⇒ Policy
Gets the Cloud IAM access control policy for the backup.
-
#project_id ⇒ String
The unique identifier for the project to which the backup belongs.
-
#ready? ⇒ Boolean
The backup has been successfully created and is ready to serve requests.
-
#reload! ⇒ Google::Cloud::Bigtable::Backup
Reloads backup data.
-
#restore(table_id, instance: nil) ⇒ Google::Cloud::Bigtable::Table::RestoreJob
Creates a new table by restoring data from a completed backup.
-
#save ⇒ Boolean
(also: #update)
Updates the backup.
-
#size_bytes ⇒ Integer
The size of the backup in bytes.
-
#source_backup ⇒ String
The name of the backup from which this backup is copied.
-
#source_table(perform_lookup: nil, view: nil) ⇒ Table
The table from which this backup was created.
-
#start_time ⇒ Time
The time that the backup was started (i.e. approximately the time the
CreateBackup
request is received). -
#state ⇒ Symbol
The current state of the backup.
-
#test_iam_permissions(*permissions) ⇒ Array<String>
Tests the specified permissions against the Cloud IAM access control policy.
-
#update_policy(new_policy) ⇒ Policy
(also: #policy=)
Updates the Cloud IAM access control policy for the backup.
Instance Method Details
#backup_id ⇒ String
The unique identifier for the backup.
98 99 100 |
# File 'lib/google/cloud/bigtable/backup.rb', line 98 def backup_id @grpc.name.split("/")[7] end |
#cluster_id ⇒ String
The unique identifier for the cluster to which the backup belongs.
89 90 91 |
# File 'lib/google/cloud/bigtable/backup.rb', line 89 def cluster_id @grpc.name.split("/")[5] end |
#copy(dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:, expire_time:) ⇒ Google::Cloud::Bigtable::Backup::Job
Creates a copy of the backup at the desired location. Copy of the backup won't be created if the backup is already a copied one.
472 473 474 475 476 477 478 479 480 |
# File 'lib/google/cloud/bigtable/backup.rb', line 472 def copy dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:, expire_time: grpc = service.copy_backup project_id: dest_project_id, instance_id: dest_instance_id, cluster_id: dest_cluster_id, backup_id: new_backup_id, source_backup: service.backup_path(instance_id, cluster_id, backup_id), expire_time: expire_time Backup::Job.from_grpc grpc, service end |
#creating? ⇒ Boolean
The backup is currently being created, and may be destroyed if the creation process encounters an error.
209 210 211 |
# File 'lib/google/cloud/bigtable/backup.rb', line 209 def creating? state == :CREATING end |
#delete ⇒ Boolean
Permanently deletes the backup.
535 536 537 538 539 |
# File 'lib/google/cloud/bigtable/backup.rb', line 535 def delete ensure_service! service.delete_backup instance_id, cluster_id, backup_id true end |
#encryption_info ⇒ Google::Cloud::Bigtable::EncryptionInfo
The encryption information for the backup. See also Instance::ClusterMap#add.
239 240 241 |
# File 'lib/google/cloud/bigtable/backup.rb', line 239 def encryption_info EncryptionInfo.from_grpc @grpc.encryption_info end |
#end_time ⇒ Time
The time that the backup was finished. The row data in the backup will be no newer than this timestamp.
182 183 184 |
# File 'lib/google/cloud/bigtable/backup.rb', line 182 def end_time Convert. @grpc.end_time end |
#expire_time ⇒ Time
The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 30 days from the time the request is received. Once the expire time has passed, Cloud Bigtable will delete the backup and free the resources used by the backup.
152 153 154 |
# File 'lib/google/cloud/bigtable/backup.rb', line 152 def expire_time Convert. @grpc.expire_time end |
#expire_time=(new_expire_time) ⇒ Object
Sets the expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 30 days from the time the request is received. Once the #expire_time has passed, Cloud Bigtable will delete the backup and free the resources used by the backup.
163 164 165 |
# File 'lib/google/cloud/bigtable/backup.rb', line 163 def expire_time= new_expire_time @grpc.expire_time = Convert. new_expire_time end |
#instance_id ⇒ String
The unique identifier for the instance to which the backup belongs.
80 81 82 |
# File 'lib/google/cloud/bigtable/backup.rb', line 80 def instance_id @grpc.name.split("/")[3] end |
#path ⇒ String
The unique name of the backup. Value in the form
projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>
.
108 109 110 |
# File 'lib/google/cloud/bigtable/backup.rb', line 108 def path @grpc.name end |
#policy {|policy| ... } ⇒ Policy
Gets the Cloud IAM access control policy for the backup.
282 283 284 285 286 287 288 289 |
# File 'lib/google/cloud/bigtable/backup.rb', line 282 def policy ensure_service! grpc = service.get_backup_policy instance_id, cluster_id, backup_id policy = Policy.from_grpc grpc return policy unless block_given? yield policy update_policy policy end |
#project_id ⇒ String
The unique identifier for the project to which the backup belongs.
71 72 73 |
# File 'lib/google/cloud/bigtable/backup.rb', line 71 def project_id @grpc.name.split("/")[1] end |
#ready? ⇒ Boolean
The backup has been successfully created and is ready to serve requests.
218 219 220 |
# File 'lib/google/cloud/bigtable/backup.rb', line 218 def ready? state == :READY end |
#reload! ⇒ Google::Cloud::Bigtable::Backup
Reloads backup data.
514 515 516 517 |
# File 'lib/google/cloud/bigtable/backup.rb', line 514 def reload! @grpc = service.get_backup instance_id, cluster_id, backup_id self end |
#restore(table_id, instance: nil) ⇒ Google::Cloud::Bigtable::Table::RestoreJob
Creates a new table by restoring data from a completed backup. The new table may be created in an instance different than that of the backup.
417 418 419 420 421 422 423 424 425 |
# File 'lib/google/cloud/bigtable/backup.rb', line 417 def restore table_id, instance: nil table_instance_id = instance.respond_to?(:instance_id) ? instance.instance_id : instance grpc = service.restore_table table_id, instance_id, cluster_id, backup_id, table_instance_id: table_instance_id Table::RestoreJob.from_grpc grpc, service end |
#save ⇒ Boolean Also known as: update
Updates the backup.
expire_time
is the only updatable field.
502 503 504 505 506 |
# File 'lib/google/cloud/bigtable/backup.rb', line 502 def save ensure_service! @grpc = service.update_backup @grpc, [:expire_time] true end |
#size_bytes ⇒ Integer
The size of the backup in bytes.
191 192 193 |
# File 'lib/google/cloud/bigtable/backup.rb', line 191 def size_bytes @grpc.size_bytes end |
#source_backup ⇒ String
The name of the backup from which this backup is copied.
Value will be empty if its not a copied backup and of the form -
projects/<project>/instances/<instance>/clusters/<cluster>/backups/<source_backup>
if this is a copied backup.
120 121 122 |
# File 'lib/google/cloud/bigtable/backup.rb', line 120 def source_backup @grpc.source_backup end |
#source_table(perform_lookup: nil, view: nil) ⇒ Table
The table from which this backup was created.
139 140 141 142 143 |
# File 'lib/google/cloud/bigtable/backup.rb', line 139 def source_table perform_lookup: nil, view: nil table = Table.from_path @grpc.source_table, service return table.reload! view: view if perform_lookup table end |
#start_time ⇒ Time
The time that the backup was started (i.e. approximately the time the CreateBackup
request is received). The
row data in this backup will be no older than this timestamp.
173 174 175 |
# File 'lib/google/cloud/bigtable/backup.rb', line 173 def start_time Convert. @grpc.start_time end |
#state ⇒ Symbol
The current state of the backup. Possible values are :CREATING
and :READY
.
200 201 202 |
# File 'lib/google/cloud/bigtable/backup.rb', line 200 def state @grpc.state end |
#test_iam_permissions(*permissions) ⇒ Array<String>
Tests the specified permissions against the Cloud IAM access control policy.
357 358 359 360 361 |
# File 'lib/google/cloud/bigtable/backup.rb', line 357 def * ensure_service! grpc = service. instance_id, cluster_id, backup_id, .flatten grpc..to_a end |
#update_policy(new_policy) ⇒ Policy Also known as: policy=
Updates the Cloud IAM access control
policy for the backup. The policy should be read from #policy.
See Policy for an explanation of the policy
etag
property and how to modify policies.
You can also update the policy by passing a block to #policy, which will call this method internally after the block completes.
320 321 322 323 324 |
# File 'lib/google/cloud/bigtable/backup.rb', line 320 def update_policy new_policy ensure_service! grpc = service.set_backup_policy instance_id, cluster_id, backup_id, new_policy.to_grpc Policy.from_grpc grpc end |