Cloud Spanner API - Class Google::Cloud::Spanner::Backup::Restore::Job (v2.21.0)

Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Backup::Restore::Job.

Job

A resource representing the long-running, asynchronous processing of a backup restore. The job can be refreshed to retrieve the restored database object once the operation has been completed.

See {Backup#restore}

{Google::Cloud::Spanner::Admin::Database#database_admin Client#restore_database} instead.

Inherits

  • Object

Example

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

if job.error?
  status = job.error
else
  database = job.database
end

Methods

#database

def database() -> Database, nil

The database is the object of the operation.

Returns
  • (Database, nil) — The database instance, or nil if the operation is not complete.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload!
job.done? #=> true
database = job.database

#done?

def done?() -> boolean

Checks if the processing of the restore operation is complete.

Returns
  • (boolean) — true when complete, false otherwise.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false

#end_time

def end_time() -> Time, nil

The operation end time.

Returns
  • (Time, nil)

#error

def error() -> Google::Cloud::Spanner::Status, nil

The status if the operation associated with this job produced an error.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.error? # true

error = job.error

#error?

def error?() -> boolean

Checks if the processing of the restore operation has errored.

Returns
  • (boolean) — true when errored, false otherwise.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.error? #=> false

#progress_percent

def progress_percent() -> Integer

The operation progress in percentage.

Returns
  • (Integer)

#refresh!

def refresh!() -> Backup::Job
Alias Of: #reload!

Reloads the job with current data from the long-running, asynchronous processing of a restore operation.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

#reload!

def reload!() -> Backup::Job
Aliases

Reloads the job with current data from the long-running, asynchronous processing of a restore operation.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

#start_time

def start_time() -> Time, nil

The operation start time.

Returns
  • (Time, nil)

#wait_until_done!

def wait_until_done!()

Reloads the job until the operation is complete. The delay between reloads will incrementally increase.

Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.wait_until_done!
job.done? #=> true