lib/capones_recipes/tasks/database/sync.rb in capones_recipes-1.2.0 vs lib/capones_recipes/tasks/database/sync.rb in capones_recipes-1.2.2

- old
+ new

@@ -62,18 +62,17 @@ # Download dump download "#{shared_path}/sync/#{filename}", filename # Local DB import username, password, database, host = database_config('development') - run_locally "rake db:drop && rake db:create" - run_locally "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}" - run_locally "rm -f #{filename}" + run "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}" + run "rm -f #{filename}" logger.important "sync database from the stage '#{stage}' to local finished" # Start db:migrate - run_locally "rake db:migrate" + run "rake db:migrate" end desc <<-DESC Sync declared directories from the selected multi_stage environment to the local development environment. The synced directories must be declared as an array of Strings with the sync_directories @@ -90,11 +89,11 @@ logger.info "create local '#{syncdir}' folder" Dir.mkdir "#{syncdir}" end logger.info "sync #{syncdir} from #{server}:#{port} to local" destination, base = Pathname.new(syncdir).split - run_locally "rsync --verbose --archive --compress --copy-links --delete --stats --rsh='ssh -p #{port}' #{user}@#{server}:#{current_path}/#{syncdir} #{destination.to_s}" + run "rsync --verbose --archive --compress --copy-links --delete --stats --rsh='ssh -p #{port}' #{user}@#{server}:#{current_path}/#{syncdir} #{destination.to_s}" end logger.important "sync filesystem from the stage '#{stage}' to local finished" end @@ -133,13 +132,12 @@ # Download dump download "#{shared_path}/sync/#{filename}", filename # Local DB import username, password, database, host = database_config('development') - run_locally "rake db:drop && rake db:create" - run_locally "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}" - run_locally "rm -f #{filename}" + run "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}" + run "rm -f #{filename}" logger.important "sync database from the stage '#{stage}' to local finished" end end end @@ -181,13 +179,13 @@ # Local DB export filename = "dump.local.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2" username, password, database, host = database_config('development') host_option = host ? "--host='#{host}'" : "" - run_locally "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}" + run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}" upload filename, "#{shared_path}/sync/#{filename}" - run_locally "rm -f #{filename}" + system "rm -f #{filename}" # Remote DB import username, password, database, host = remote_database_config(stage) host_option = host ? "--host='#{host}'" : "" run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}" @@ -219,11 +217,11 @@ run "mkdir #{current_path}/#{syncdir}" end # Sync directory up logger.info "sync #{syncdir} to #{server}:#{port} from local" - run_locally "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir} #{user}@#{server}:#{current_path}/#{destination.to_s}" + run "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir} #{user}@#{server}:#{current_path}/#{destination.to_s}" end logger.important "sync filesystem from local to the stage '#{stage}' finished" end namespace :kuhsaft do @@ -248,11 +246,11 @@ filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2" on_rollback do delete "#{shared_path}/sync/#{filename}" - run_locally "rm -f #{filename}" + system "rm -f #{filename}" end # Make a backup before importing username, password, database, host = remote_database_config(stage) host_option = host ? "--host='#{host}'" : "" @@ -262,12 +260,12 @@ # Local DB export filename = "dump.local.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2" username, password, database, host = database_config('development') host_option = host ? "--host='#{host}'" : "" - run_locally "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}" + run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}" upload filename, "#{shared_path}/sync/#{filename}" - run_locally "rm -f #{filename}" + system "rm -f #{filename}" # Remote DB import username, password, database, host = remote_database_config(stage) host_option = host ? "--host='#{host}'" : "" run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}"