From 28a79ac295abe4a475cd8c5e0ca2919c60598f64 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 4 Oct 2018 12:29:36 -0400 Subject: [PATCH 1/3] For database dumps don't modify the directory name Typically "db_dump" or "db_backup" is added the remote path for backup upload. This gives the rake task the --skip-directory option so "db_backup" is not added to the target directory name --- lib/evm_database_ops.rb | 8 +++++++- lib/tasks/evm_dba.rake | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/evm_database_ops.rb b/lib/evm_database_ops.rb index fdcd68eb83d..76711210fda 100644 --- a/lib/evm_database_ops.rb +++ b/lib/evm_database_ops.rb @@ -114,7 +114,13 @@ def self.restore(db_opts, connect_opts = {}) connect_opts[:uri] = File.dirname(connect_opts[:uri]) else connect_opts[:remote_file_name] ||= File.basename(backup_file_name(action)) - backup_folder = action == :dump ? "db_dump" : "db_backup" + backup_folder = if connect_opts[:skip_directory] + [] + elsif action == :dump + "db_dump" + else + "db_backup" + end # # If the passed in URI contains query parameters, ignore them # when creating the dump file name. They'll be used in the session object. diff --git a/lib/tasks/evm_dba.rake b/lib/tasks/evm_dba.rake index 21c0da2c3b5..49305ba1cc7 100644 --- a/lib/tasks/evm_dba.rake +++ b/lib/tasks/evm_dba.rake @@ -33,6 +33,7 @@ module EvmDba when :local_file opt :local_file, "Destination file", :type => :string, :required => true when :remote_file + opt :skip_directory, "Don't add backup directory", :type => :boolean, :default => false opt :remote_file_name, "Destination depot filename", :type => :string when :splitable opt :byte_count, "Size to split files into", :type => :string @@ -57,7 +58,7 @@ module EvmDba db_opts end - CONNECT_OPT_KEYS = [:uri, :uri_username, :uri_password, :aws_region, :remote_file_name].freeze + CONNECT_OPT_KEYS = [:uri, :uri_username, :uri_password, :aws_region, :remote_file_name, :skip_directory].freeze def self.collect_connect_opts(opts) connect_opts = {} CONNECT_OPT_KEYS.each { |k| connect_opts[k] = opts[k] if opts[k] } From 689c08f4ed66c1926ad4177b3f3e4d30ec57a7d5 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Fri, 5 Oct 2018 17:28:29 -0400 Subject: [PATCH 2/3] improve url building for dump filename --- lib/evm_database_ops.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/evm_database_ops.rb b/lib/evm_database_ops.rb index 76711210fda..1822e40dbc9 100644 --- a/lib/evm_database_ops.rb +++ b/lib/evm_database_ops.rb @@ -114,19 +114,14 @@ def self.restore(db_opts, connect_opts = {}) connect_opts[:uri] = File.dirname(connect_opts[:uri]) else connect_opts[:remote_file_name] ||= File.basename(backup_file_name(action)) - backup_folder = if connect_opts[:skip_directory] - [] - elsif action == :dump - "db_dump" - else - "db_backup" - end # # If the passed in URI contains query parameters, ignore them # when creating the dump file name. They'll be used in the session object. # - connect_opts_uri = connect_opts[:uri].split('?')[0] - uri = File.join(connect_opts_uri, backup_folder, connect_opts[:remote_file_name]) + uri_parts = [connect_opts[:uri].split('?')[0]] + uri_parts << (action == :dump ? "db_dump" : "db_backup") unless connect_opts[:skip_directory] + uri_parts << connect_opts[:remote_file_name] + uri = File.join(uri_parts) end else uri = db_opts[:local_file] From 77d16160c1caf145ea4686a2d373a1a94f6c429d Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Tue, 9 Oct 2018 15:17:08 -0400 Subject: [PATCH 3/3] appease rubocop for evm_dba symbols --- lib/tasks/evm_dba.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/evm_dba.rake b/lib/tasks/evm_dba.rake index 49305ba1cc7..7562cbaf98e 100644 --- a/lib/tasks/evm_dba.rake +++ b/lib/tasks/evm_dba.rake @@ -58,7 +58,7 @@ module EvmDba db_opts end - CONNECT_OPT_KEYS = [:uri, :uri_username, :uri_password, :aws_region, :remote_file_name, :skip_directory].freeze + CONNECT_OPT_KEYS = %i(uri uri_username uri_password aws_region remote_file_name skip_directory).freeze def self.collect_connect_opts(opts) connect_opts = {} CONNECT_OPT_KEYS.each { |k| connect_opts[k] = opts[k] if opts[k] }