Module: CloudantBackup::Backup

Included in:
CloudantBackup
Defined in:
lib/cloudant_backup/backup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cloudant_hostObject

Returns the value of attribute cloudant_host.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def cloudant_host
  @cloudant_host
end

#date_patternObject

Returns the value of attribute date_pattern.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def date_pattern
  @date_pattern
end

#host=(host) ⇒ Object

Sets the attribute host

Parameters:

  • value

    the value to set the attribute host to.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def host=(value)
  @host = value
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def password
  @password
end

#sourceObject

Returns the value of attribute source.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def source
  @source
end

#targetObject

Returns the value of attribute target.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def target
  @target
end

#userObject

Returns the value of attribute user.



7
8
9
# File 'lib/cloudant_backup/backup.rb', line 7

def user
  @user
end

Instance Method Details

#backupObject



12
13
14
15
# File 'lib/cloudant_backup/backup.rb', line 12

def backup
  create_target_db
  replicate
end

#create_target_dbObject



17
18
19
20
21
# File 'lib/cloudant_backup/backup.rb', line 17

def create_target_db
  make_request(:put, target_db)
rescue RestClient::PreconditionFailed
  # When the db existed already, we're fine with that
end

#initializeObject



9
10
# File 'lib/cloudant_backup/backup.rb', line 9

def initialize
end

#replicateObject



23
24
25
26
27
28
29
# File 'lib/cloudant_backup/backup.rb', line 23

def replicate
  data = {
    source: source_db_url,
    target: target_db_url
  }.to_json
  make_request(:post, "_replicate", data)
end