Skip to content

Commit

Permalink
Add file splitting to dump and backup tasks
Browse files Browse the repository at this point in the history
Adds the ability to pass the `--byte-count` (`-b`) to the following rake
tasks:

    - evm:db:backup:local
    - evm:db:backup:remote
    - evm:db:dump:local
    - evm:db:dump:remote

Adds additional options to the `EvmDba.with_options` method, and adds
the `EvmDba.collect_additional_opts` method, which pulls out the split
params from the options hash into it's own hash.  Used by EvmDatabaseOps
to determine if piping through `file_splitter.rb` is necessary.
  • Loading branch information
NickLaMuro committed Jul 18, 2018
1 parent 916ba0a commit 83c2d8c
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions lib/tasks/evm_dba.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module EvmDba
opt :local_file, "Destination file", :type => :string, :required => true
when :remote_file
opt :remote_file_name, "Destination depot filename", :type => :string
when :splitable
opt :byte_count, "Size to split files by", :type => :string
when :remote_uri
opt :uri, "Destination depot URI", :type => :string, :required => true
opt :uri_username, "Destination depot username", :type => :string
Expand All @@ -59,6 +61,12 @@ module EvmDba
connect_opts[:password] = connect_opts.delete(:uri_password) if connect_opts[:uri_password]
connect_opts
end

def self.collect_additional_opts(opts)
additional_opts = {}
[:byte_count].each { |k| additional_opts[k] = opts[k] if opts[k] }
additional_opts
end
end

namespace :evm do
Expand Down Expand Up @@ -185,21 +193,24 @@ namespace :evm do
require File.expand_path(File.join(Rails.root, "lib", "evm_database_ops"))
desc 'Backup the local ManageIQ EVM Database (VMDB) to a local file'
task :local do
opts = EvmDba.with_options(:local_file, :db_credentials)
opts = EvmDba.with_options(:local_file, :splitable, :db_credentials)

additional_opts = EvmDba.collect_additional_opts(opts)

EvmDatabaseOps.backup(opts)
EvmDatabaseOps.backup(opts, {}, additional_opts)

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

desc 'Backup the local ManageIQ EVM Database (VMDB) to a remote file'
task :remote do
opts = EvmDba.with_options(:remote_uri, :remote_file, :db_credentials)
opts = EvmDba.with_options(:remote_uri, :remote_file, :splitable, :db_credentials)

db_opts = EvmDba.collect_db_opts(opts)
connect_opts = EvmDba.collect_connect_opts(opts)
db_opts = EvmDba.collect_db_opts(opts)
connect_opts = EvmDba.collect_connect_opts(opts)
additional_opts = EvmDba.collect_additional_opts(opts)

EvmDatabaseOps.backup(db_opts, connect_opts)
EvmDatabaseOps.backup(db_opts, connect_opts, additional_opts)

exit # exit so that parameters to the first rake task are not run as rake tasks
end
Expand All @@ -209,21 +220,23 @@ namespace :evm 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
opts = EvmDba.with_options(:local_file, :db_credentials, :exclude_table_data)
opts = EvmDba.with_options(:local_file, :splitable, :db_credentials, :exclude_table_data)

EvmDatabaseOps.dump(opts)
additional_opts = EvmDba.collect_additional_opts(opts)
EvmDatabaseOps.dump(opts, {}, additional_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
opts = EvmDba.with_options(:remote_uri, :remote_file, :db_credentials, :exclude_table_data)
opts = EvmDba.with_options(:remote_uri, :remote_file, :splitable, :db_credentials, :exclude_table_data)

db_opts = EvmDba.collect_db_opts(opts)
connect_opts = EvmDba.collect_connect_opts(opts)
db_opts = EvmDba.collect_db_opts(opts)
connect_opts = EvmDba.collect_connect_opts(opts)
additional_opts = EvmDba.collect_additional_opts(opts)

EvmDatabaseOps.dump(db_opts, connect_opts)
EvmDatabaseOps.dump(db_opts, connect_opts, additional_opts)

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

0 comments on commit 83c2d8c

Please sign in to comment.