clone_remote_db 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e4ef1f0948c75e7b40317ada0a5561c677ce93a
4
- data.tar.gz: c1f4de4836d591b99952a9587ac908b072715f13
3
+ metadata.gz: 7bd2ff0fa7e22c69b5649170bd2d66b30ffefdd3
4
+ data.tar.gz: aa38915a48d27f3ac23d1b3622482353d4f4c832
5
5
  SHA512:
6
- metadata.gz: b3b63f475666459d1a108fca67f0129814195a0e8379ee00584193066e2df20724247c8f24f541a1ee0e06e6cd23e70b48c42b1c7dfdb7cbfcc39cb61df3e369
7
- data.tar.gz: 7551aee85ba3d6e42b9c9f86c20edce8c68251daa569593f12cb50b1979d28919d18c9d36e60e20e017e01a6a68c7a7052c26526954073bb25be0431460cc0c6
6
+ metadata.gz: eda295fe00556e2f497b209f2aa4681818ff775cb40182ab6b569111a016dc441894aa7e8fd915017b241c89c28c370087617cfcd3c1e3365b147a7ec80487c4
7
+ data.tar.gz: b47d9c51ca1a2586f21cdb6ff0e2b7a0ce90b2e2f49db07b6b5c6869ef83c91e44732505990812cb4da5905d5ec09ea3d35d6b61144eb6263ed19c08dc6c97ff
data/bin/clone_remote_db CHANGED
@@ -48,12 +48,16 @@ if cmd
48
48
  cmd_config = CONFIG['environments'][cmd]
49
49
  if cmd_config
50
50
  cmd_config = cmd_config.symbolize_keys
51
- loader.options.merge!(cmd_config.select { |k,v| cli_opts[k].nil? })
51
+
52
+ # do not merge parameters that were set from the command line
53
+ cmd_config_opts = cmd_config.select { |k,v| cli_opts[k].nil? }
54
+ loader.options.merge!(cmd_config_opts)
52
55
  else
53
56
  loader.die("unknown subcommand #{cmd}")
54
57
  end
55
58
  end
56
59
 
60
+ loader.load_defaults!
57
61
  opts = loader.options
58
62
 
59
63
  [:local_db, :remote_db, :host].each do |opt|
@@ -66,7 +70,7 @@ loader.die(:import_only, "file not found") if opts[:import_only] && !File.exist?
66
70
  gzip_opts = opts[:gzip_opts]
67
71
 
68
72
  # pg_dump exclude-table-data tables
69
- pg_exclude_data = opts[:pg_exclude_data]
73
+ pg_exclude_data = opts[:exclude_table_data]
70
74
 
71
75
  db_name = opts[:remote_db]
72
76
  local_dbname = opts[:local_db]
@@ -75,7 +79,9 @@ host = opts[:host]
75
79
  # pg_dump setup
76
80
  pg_user = opts[:remote_user]
77
81
  pg_options = opts[:pg_dump_opts] << "-x #{escape_opts(db_name)}"
78
- pg_options_joined = pg_exclude_data.map { |t| '--exclude-table-data=' + escape_opts(t) }.
82
+ pg_options_joined = \
83
+ (pg_exclude_data.is_a?(String) ? pg_exclude_data.split(',') : pg_exclude_data).
84
+ map { |t| '--exclude-table-data=' + escape_opts(t) }.
79
85
  join(' ') + ' ' + pg_options.join(' ')
80
86
  pg_dump_part = "pg_dump #{pg_options_joined}"
81
87
 
@@ -19,4 +19,6 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.5"
21
21
  spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "pry"
23
+ spec.add_development_dependency "debugger"
22
24
  end
@@ -16,6 +16,8 @@ class CloneRemoteDb::Loader
16
16
  opt(opts, :host, "Host of the postgresql database", arg: 'HOST', short: '-h')
17
17
  opt(opts, :import_only, "Skip download and provide path to dump.sql.gz file", arg: 'PATH')
18
18
  opt(opts, :local_dest, "The path to save the dump.sql.gz file to", arg: 'PATH')
19
+ opt(opts, :remote_user, "Sudo as this user on the remote server", arg: 'USER')
20
+ opt(opts, :exclude_table_data, "Do not download data from these table(s). Separate multiple tables by comma.", arg: 'TABLE')
19
21
  opt(opts, :dry_run, "Don't actually do anything", short: '-n')
20
22
  end.parse!
21
23
  options
@@ -54,23 +56,23 @@ EOS
54
56
  arg << " #{arg_opts[:arg]}" if arg_opts[:arg]
55
57
  on_args = [arg, msg]
56
58
  on_args.unshift(arg_opts[:short]) if arg_opts[:short]
57
- opts.on(*on_args, msg) do |v|
59
+ opts.on(*on_args) do |v|
58
60
  options[key] = v
59
61
  end
60
62
  end
61
63
 
62
64
  def options
63
- @options ||= {}.merge(defaults)
65
+ @options ||= {}
64
66
  end
65
67
 
66
- def defaults
67
- {
68
+ def load_defaults!
69
+ @options = {
68
70
  local_dest: '~/pg_dumps/{remote_db}/%Y-%m/%Y-%m-%d_%H.%M.sql.gz',
69
71
  gzip_opts: %w(-9 --stdout),
70
72
  pg_dump_opts: %w(-c -O),
71
- pg_exclude_data: %w(versions),
73
+ exclude_table_data: %w(versions),
72
74
  remote_user: 'postgres'
73
- }
75
+ }.merge(options)
74
76
  end
75
77
 
76
78
  def replace_variables(str)
@@ -1,3 +1,3 @@
1
1
  module CloneRemoteDb
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,41 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clone_remote_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh McDade
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: debugger
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0'
41
69
  description:
@@ -46,7 +74,7 @@ executables:
46
74
  extensions: []
47
75
  extra_rdoc_files: []
48
76
  files:
49
- - .gitignore
77
+ - ".gitignore"
50
78
  - Gemfile
51
79
  - LICENSE.txt
52
80
  - README.md
@@ -67,17 +95,17 @@ require_paths:
67
95
  - lib
68
96
  required_ruby_version: !ruby/object:Gem::Requirement
69
97
  requirements:
70
- - - '>='
98
+ - - ">="
71
99
  - !ruby/object:Gem::Version
72
100
  version: '0'
73
101
  required_rubygems_version: !ruby/object:Gem::Requirement
74
102
  requirements:
75
- - - '>='
103
+ - - ">="
76
104
  - !ruby/object:Gem::Version
77
105
  version: '0'
78
106
  requirements: []
79
107
  rubyforge_project:
80
- rubygems_version: 2.0.3
108
+ rubygems_version: 2.2.0
81
109
  signing_key:
82
110
  specification_version: 4
83
111
  summary: Helper script to dump, download, and remote a remote PostgreSQL database