class Nexpose::Backup
Details about an existing backup on the security console.
Attributes
Date the backup was made.
Description of the backup.
Filename
Whether the backup is platform-idependent or not.
Size of backup file on disk, in Bytes. Can be used to estimate the amount of time the backup may take to load.
Nexpose
version the console was on when the backup was made.
Public Class Methods
# File lib/nexpose/maint.rb, line 86 def initialize(name, date, description, version, independent, size) @name = name @date = date @description = description @version = version @platform_independent = independent @size = size end
# File lib/nexpose/maint.rb, line 127 def self.parse(hash) new(hash['Download'], Time.at(hash['Date'].to_i / 1000), hash['Description'], hash['Version'], hash['Platform-Independent'], hash['Size']) end
Public Instance Methods
Remove this backup file from the security console.
@param [Connection] nsc An active connection to a Nexpose
console. @return [Boolean] If the backup was removed.
# File lib/nexpose/maint.rb, line 119 def delete(nsc) parameters = { 'backupid' => @name, 'cmd' => 'deleteBackup', 'targetTask' => 'backupRestore' } xml = AJAX.form_post(nsc, '/admin/global/maintenance/maintCmd.txml', parameters) !!(xml =~ /succeded="true"/) end
Restore this backup to the Nexpose
console. It will restart the console after acknowledging receiving the request.
@param [Connection] nsc An active connection to a Nexpose
console. @param [String] (Optional) The password to use when restoring the backup. @return [Boolean] Whether the request was received.
# File lib/nexpose/maint.rb, line 102 def restore(nsc, password = nil) raise 'Supplied Password is incorrect for restoring this Backup.' if invalid_backup_password?(nsc, password) parameters = { 'backupid' => @name, 'cmd' => 'restore', 'targetTask' => 'backupRestore', 'password' => password } xml = AJAX.form_post(nsc, '/admin/global/maintenance/maintCmd.txml', parameters) if !!(xml =~ /succeded="true"/) nsc._maintenance_restart end end
Private Instance Methods
# File lib/nexpose/maint.rb, line 142 def backup_need_password?(nsc) resp = Nexpose::AJAX.get(nsc, '/data/admin/backups/password', Nexpose::AJAX::CONTENT_TYPE::JSON, 'backupID' => name) resp == 'true' end
# File lib/nexpose/maint.rb, line 147 def correct_backup_password?(nsc, password) raise 'This Backup file requires a Password. Please include a password during the restore command.' if password.nil? resp = Nexpose::AJAX.post(nsc, "/data/admin/backups/password?backupID=#{name}&password=#{password}", nil, Nexpose::AJAX::CONTENT_TYPE::JSON) resp == 'true' end
# File lib/nexpose/maint.rb, line 138 def invalid_backup_password?(nsc, password) !correct_backup_password?(nsc, password) if backup_need_password?(nsc) end