engineyard-eycap 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/eycap/recipes/database.rb +6 -20
- data/lib/eycap.rb +1 -1
- metadata +1 -1
data/History.txt
CHANGED
@@ -13,32 +13,18 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
13
13
|
|
14
14
|
# This task currently runs only on traditional EY offerings.
|
15
15
|
# You need to have both a production and staging environment defined in
|
16
|
-
# your deploy.rb file.
|
16
|
+
# your deploy.rb file.
|
17
17
|
|
18
18
|
backup_name
|
19
19
|
on_rollback { run "rm -f #{backup_file}" }
|
20
|
-
run("cat #{shared_path}/config/database.yml") { |channel, stream, data| @environment_info = YAML.load(data)[rails_env] }
|
21
|
-
|
22
|
-
# If the production db hostname has a trailing -master string, substitute
|
23
|
-
# it with -replica.
|
24
|
-
# Elsif the production db hostname doesn't have a trailing -master, just
|
25
|
-
# append -replica.
|
26
|
-
# Else you're using PostgreSQL and we'll dump it that way.
|
20
|
+
run("cat #{shared_path}/config/database.yml") { |channel, stream, data| @environment_info = YAML.load(data)[rails_env] }
|
27
21
|
|
28
|
-
if @environment_info['adapter'] == 'mysql'
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
run "mysql -u #{dbuser} -p -h #{staging_dbhost} #{staging_database} < #{backup_file}" do |ch, stream, out|
|
33
|
-
ch.send_data "#{dbpass}\n" if out=~ /^Enter password:/
|
34
|
-
end
|
35
|
-
elsif @environment_info['adapter'] == 'mysql' && production_dbhost.scan('-master') != true
|
36
|
-
run "mysqldump --add-drop-table -u #{dbuser} -h #{production_dbhost + '-replica'} #{production_database} -p > #{backup_file}" do |ch, stream, out|
|
22
|
+
if @environment_info['adapter'] == 'mysql'
|
23
|
+
dbhost = @environment_info['host']
|
24
|
+
dbhost = environment_dbhost.sub('-master', '') + '-replica' if dbhost != 'localhost' # added for Solo offering, which uses localhost
|
25
|
+
run "mysqldump --add-drop-table -u #{dbuser} -h #{dbhost} -p #{environment_database} | bzip2 -c > #{backup_file}.bz2" do |ch, stream, out |
|
37
26
|
ch.send_data "#{dbpass}\n" if out=~ /^Enter password:/
|
38
27
|
end
|
39
|
-
run "mysql -u #{dbuser} -p -h #{staging_dbhost} #{staging_database} < #{backup_file}" do |ch, stream, out|
|
40
|
-
ch.send_data "#{dbpass}\n" if out=~ /^Enter password:/
|
41
|
-
end
|
42
28
|
else
|
43
29
|
run "pg_dump -W -c -U #{dbuser} -h #{production_dbhost} -f #{backup_file} #{production_database}" do |ch, stream, out|
|
44
30
|
ch.send_data "#{dbpass}\n" if out=~ /^Password:/
|
data/lib/eycap.rb
CHANGED