Skip to content

Commit

Permalink
Add evm:db:dump:local and evm:db:dump:remote tasks
Browse files Browse the repository at this point in the history
Effectively a carbon copy of the `:backup` namespace tasks.
  • Loading branch information
NickLaMuro committed May 25, 2018
1 parent c4e7793 commit a89a6e5
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lib/tasks/evm_dba.rake
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,53 @@ namespace :evm do
end
end

namespace :dump do
require Rails.root.join("lib", "evm_database_ops").expand_path.to_s
desc 'Dump the local ManageIQ EVM Database (VMDB) to a local file'
task :local do
require 'trollop'
opts = Trollop.options(EvmRakeHelper.extract_command_options) do
opt :local_file, "Destination file", :type => :string, :required => true
opt :username, "Username", :type => :string
opt :password, "Password", :type => :string
opt :hostname, "Hostname", :type => :string
opt :dbname, "Database name", :type => :string
end

opts.delete_if { |_, v| v.nil? }
EvmDatabaseOps.dump(opts)

exit # exit so that parameters to the first rake task are not run as rake tasks
end

desc 'Dump the local ManageIQ EVM Database (VMDB) to a remote file'
task :remote do
require 'trollop'
opts = Trollop.options(EvmRakeHelper.extract_command_options) do
opt :uri, "Destination depot URI", :type => :string, :required => true
opt :uri_username, "Destination depot username", :type => :string
opt :uri_password, "Destination depot password", :type => :string
opt :remote_file_name, "Destination depot filename", :type => :string
opt :username, "Username", :type => :string
opt :password, "Password", :type => :string
opt :hostname, "Hostname", :type => :string
opt :dbname, "Database name", :type => :string
end

db_opts = {}
[:dbname, :username, :password, :hostname].each { |k| db_opts[k] = opts[k] if opts[k] }

connect_opts = {}
[:uri, :uri_username, :uri_password, :remote_file_name].each { |k| connect_opts[k] = opts[k] if opts[k] }
connect_opts[:username] = connect_opts.delete(:uri_username) if connect_opts[:uri_username]
connect_opts[:password] = connect_opts.delete(:uri_password) if connect_opts[:uri_password]

EvmDatabaseOps.dump(db_opts, connect_opts)

exit # exit so that parameters to the first rake task are not run as rake tasks
end
end

namespace :restore do
desc 'Restore the local ManageIQ EVM Database (VMDB) from a local backup file'
task :local => :environment do
Expand Down

0 comments on commit a89a6e5

Please sign in to comment.