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

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

Job

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

See {Google::Cloud::Spanner::Database#create_backup}

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

Inherits

  • Object

Example

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

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

Methods

#backup

def backup() -> Backup, nil

The backup is the object of the operation.

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

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

#cancel

def cancel()

Cancel the backup job.

Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.done? #=> false
job.cancel

#cancel_time

def cancel_time() -> Time, nil

The operation canceled time.

Returns
  • (Time, nil)

#done?

def done?() -> boolean

Checks if the processing of the backup operation is complete.

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

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.error? # true

error = job.error

#error?

def error?() -> boolean

Checks if the processing of the backup operation has errored.

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

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.error? #=> false

#progress_percent

def progress_percent() -> Integer

The operation progress in percentage.

Returns
  • (Integer)

#refresh!

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

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

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

#reload!

def reload!() -> Google::Cloud::Spanner::Backup::Job
Aliases

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

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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