ricodigo-capistrano-recipes 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/lib/recipes/db.rb CHANGED
@@ -10,7 +10,7 @@ Capistrano::Configuration.instance.load do
10
10
  EOF
11
11
  task :dump, :roles => :db, :only => { :primary => true } do
12
12
  prepare_from_yaml
13
- run "mongodump -u #{db_user} -p #{db_pass} -h #{db_host} --port #{db_port} -d #{db_name} #{db_backup_path}" do |ch, stream, out|
13
+ run "mongodump #{auth_options} -h #{db_host} --port #{db_port} -d #{db_name} -o #{db_backup_path}" do |ch, stream, out|
14
14
  puts out
15
15
  end
16
16
  end
@@ -18,7 +18,7 @@ Capistrano::Configuration.instance.load do
18
18
  desc "|capistrano-recipes| Restores the database from the latest compressed dump"
19
19
  task :restore, :roles => :db, :only => { :primary => true } do
20
20
  prepare_from_yaml
21
- run "mongorestore --drop -d #{db_name} #{db_backup_path}/#{db_name}" do |ch, stream, out|
21
+ run "mongorestore #{auth_options} --drop -d #{db_name} #{db_backup_path}/#{db_name}" do |ch, stream, out|
22
22
  puts out
23
23
  end
24
24
  end
@@ -26,17 +26,27 @@ Capistrano::Configuration.instance.load do
26
26
  desc "|capistrano-recipes| Downloads the compressed database dump to this machine"
27
27
  task :fetch_dump, :roles => :db, :only => { :primary => true } do
28
28
  prepare_from_yaml
29
- download db_remote_file, db_local_file, :via => :scp
29
+ download db_remote_backup, db_local_file, :via => :scp, :recursive => true
30
+ end
31
+
32
+ def auth_options
33
+ if db_user && db_pass
34
+ "-u #{db_user} -p #{db_pass}"
35
+ end
30
36
  end
31
37
 
32
38
  # Sets database variables from remote database.yaml
33
39
  def prepare_from_yaml
34
40
  set(:db_backup_path) { "#{shared_path}/backup/" }
35
- set(:db_local_file) { "tmp/#{db_file}" }
36
- set(:db_user) { db_config[rails_env]["username"] }
37
- set(:db_pass) { db_config[rails_env]["password"] }
38
- set(:db_host) { db_config[rails_env]["host"] }
39
- set(:db_name) { db_config[rails_env]["database"] }
41
+
42
+ set(:db_local_file) { "tmp/" }
43
+ set(:db_user) { db_config[rails_env.to_s]["username"] }
44
+ set(:db_pass) { db_config[rails_env.to_s]["password"] }
45
+ set(:db_host) { db_config[rails_env.to_s]["host"] }
46
+ set(:db_port) { db_config[rails_env.to_s]["port"] }
47
+ set(:db_name) { db_config[rails_env.to_s]["database"] }
48
+
49
+ set(:db_remote_backup) { "#{db_backup_path}/#{db_name}" }
40
50
  end
41
51
 
42
52
  def db_config
data/lib/recipes/log.rb CHANGED
@@ -22,7 +22,7 @@ Capistrano::Configuration.instance.load do
22
22
  copytruncate
23
23
  }}
24
24
  put rotate_script, "#{shared_path}/logrotate_script"
25
- "#{sudo} cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}"
25
+ sudo "cp #{shared_path}/logrotate_script /etc/logrotate.d/#{application}"
26
26
  run "rm #{shared_path}/logrotate_script"
27
27
 
28
28
  rotate_script = %Q{/var/log/mongodb/*.log {
@@ -35,7 +35,7 @@ Capistrano::Configuration.instance.load do
35
35
  copytruncate
36
36
  }}
37
37
  put rotate_script, "#{shared_path}/logrotate_script"
38
- "#{sudo} cp #{shared_path}/logrotate_script /etc/logrotate.d/mongodb"
38
+ sudo "cp #{shared_path}/logrotate_script /etc/logrotate.d/mongodb"
39
39
  run "rm #{shared_path}/logrotate_script"
40
40
  end
41
41
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ricodigo-capistrano-recipes}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David A. Cuadrado"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - David A. Cuadrado
@@ -191,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
- hash: 2593828221356723532
194
+ hash: 4371687022118033860
195
195
  segments:
196
196
  - 0
197
197
  version: "0"