module Elasticsearch::API::Snapshot::Actions

Public Instance Methods

create(arguments={}) click to toggle source

Create a new snapshot in the repository

@example Create a snapshot of the whole cluster in the `my-backups` repository

client.snapshot.create repository: 'my-backups', snapshot: 'snapshot-1'

@example Create a snapshot for specific indices in the `my-backups` repository

client.snapshot.create repository: 'my-backups',
                       snapshot: 'snapshot-2',
                       body: { indices: 'foo,bar', ignore_unavailable: true }

@option arguments [String] :repository A repository name (Required) @option arguments [String] :snapshot A snapshot name (Required) @option arguments [Hash] :body The snapshot definition @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Boolean] :wait_for_completion Whether the request should block and wait until

the operation has completed

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_snapshot

# File lib/elasticsearch/api/actions/snapshot/create.rb, line 27
def create(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing"   unless arguments[:snapshot]
  valid_params = [
    :master_timeout,
    :wait_for_completion ]

  repository = arguments.delete(:repository)
  snapshot   = arguments.delete(:snapshot)

  method = HTTP_PUT
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot) )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = arguments[:body]

  perform_request(method, path, params, body).body
end
create_repository(arguments={}) click to toggle source

Create a repository for storing snapshots

@example Create a repository at `/tmp/backup`

client.snapshot.create_repository repository: 'my-backups',
                                  body: {
                                    type: 'fs',
                                    settings: { location: '/tmp/backup', compress: true  }
                                  }

@option arguments [String] :repository A repository name (Required) @option arguments [Hash] :body The repository definition (Required) @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Time] :timeout Explicit operation timeout

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_repositories

# File lib/elasticsearch/api/actions/snapshot/create_repository.rb, line 23
def create_repository(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'body' missing"       unless arguments[:body]
  valid_params = [
    :repository,
    :master_timeout,
    :timeout ]

  repository = arguments.delete(:repository)

  method = HTTP_PUT
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository) )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = arguments[:body]

  perform_request(method, path, params, body).body
end
delete(arguments={}) click to toggle source

Delete a snapshot from the repository

@note Will also abort a currently running snapshot.

@example Delete the `snapshot-1` snapshot

client.snapshot.delete repository: 'my-backups', snapshot: 'snapshot-1'

@option arguments [String] :repository A repository name (Required) @option arguments [String] :snapshot A snapshot name (Required) @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

# File lib/elasticsearch/api/actions/snapshot/delete.rb, line 20
def delete(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing"   unless arguments[:snapshot]

  valid_params = [
    :master_timeout ]

  repository = arguments.delete(:repository)
  snapshot   = arguments.delete(:snapshot)

  method = HTTP_DELETE
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__listify(snapshot) )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
delete_repository(arguments={}) click to toggle source

Delete a specific repository or repositories

@example Delete the `my-backups` repository

client.snapshot.delete_repository repository: 'my-backups'

@option arguments [List] :repository A comma-separated list of repository names (Required) @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Time] :timeout Explicit operation timeout

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

# File lib/elasticsearch/api/actions/snapshot/delete_repository.rb, line 18
def delete_repository(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  valid_params = [
    :master_timeout,
    :timeout ]

  repository = arguments.delete(:repository)

  method = HTTP_DELETE
  path   = Utils.__pathify( '_snapshot', Utils.__listify(repository) )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
get(arguments={}) click to toggle source

Return information about specific (or all) snapshots

@example Return information about the `snapshot-2` snapshot

client.snapshot.get repository: 'my-backup', snapshot: 'snapshot-2'

@example Return information about multiple snapshots

client.snapshot.get repository: 'my-backup', snapshot: ['snapshot-2', 'snapshot-3']

@example Return information about all snapshots in the repository

client.snapshot.get repository: 'my-backup', snapshot: '_all'

@option arguments [String] :repository A repository name (Required) @option arguments [List] :snapshot A comma-separated list of snapshot names (Required) @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

# File lib/elasticsearch/api/actions/snapshot/get.rb, line 26
def get(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing"   unless arguments[:snapshot]

  valid_params = [
    :master_timeout ]

  repository = arguments.delete(:repository)
  snapshot   = arguments.delete(:snapshot)

  method = HTTP_GET
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__listify(snapshot) )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
get_repository(arguments={}) click to toggle source

Get information about snapshot repositories or a specific repository

@example Get all repositories

client.snapshot.get_repository

@example Get a specific repository

client.snapshot.get_repository repository: 'my-backups'

@option arguments [List] :repository A comma-separated list of repository names. Leave blank or use `_all`

to get a list of repositories

@option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Boolean] :local Return local information, do not retrieve the state from master node

(default: false)

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

# File lib/elasticsearch/api/actions/snapshot/get_repository.rb, line 24
def get_repository(arguments={})
  valid_params = [
    :master_timeout,
    :local ]

  repository = arguments.delete(:repository)

  method = HTTP_GET
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository) )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
restore(arguments={}) click to toggle source

Restore the state from a snapshot

@example Restore from the `snapshot-1` snapshot

client.snapshot.restore repository: 'my-backups', snapshot: 'snapshot-1'

@example Restore a specific index under a different name

client.snapshot.restore repository: 'my-backups',
                        snapshot: 'snapshot-1',
                        body: {
                          rename_pattern: "^(.*)$",
                          rename_replacement: "restored_$1"
                        }

@note You cannot restore into an open index, you have to {Indices::Actions#close} it first

@option arguments [String] :repository A repository name (Required) @option arguments [String] :snapshot A snapshot name (Required) @option arguments [Hash] :body Details of what to restore @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

# File lib/elasticsearch/api/actions/snapshot/restore.rb, line 31
def restore(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing"   unless arguments[:snapshot]

  valid_params = [
    :master_timeout,
    :wait_for_completion ]

  repository = arguments.delete(:repository)
  snapshot   = arguments.delete(:snapshot)

  method = HTTP_POST
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot), '_restore' )

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = arguments[:body]

  perform_request(method, path, params, body).body
end
status(arguments={}) click to toggle source

Return information about a running snapshot

@example Return information about all currently running snapshots

client.snapshot.status repository: 'my-backups', human: true

@example Return information about a specific snapshot

client.snapshot.status repository: 'my-backups', human: true

@option arguments [String] :repository A repository name @option arguments [List] :snapshot A comma-separated list of snapshot names @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_snapshot_status

# File lib/elasticsearch/api/actions/snapshot/status.rb, line 22
def status(arguments={})
  valid_params = [
    :master_timeout ]

  repository = arguments.delete(:repository)
  snapshot   = arguments.delete(:snapshot)

  method = HTTP_GET

  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot), '_status')
  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
verify_repository(arguments={}) click to toggle source

Explicitely perform the verification of a repository

@option arguments [String] :repository A repository name (Required) @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Time] :timeout Explicit operation timeout

@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

# File lib/elasticsearch/api/actions/snapshot/verify_repository.rb, line 14
def verify_repository(arguments={})
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  valid_params = [
    :repository,
    :master_timeout,
    :timeout ]

  repository = arguments.delete(:repository)
  method = HTTP_POST
  path   = Utils.__pathify( '_snapshot', Utils.__escape(repository), '_verify' )
  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end