Sha256: d93631b0199638db29137b554f29578dc5be2c04eaa064fdb5ff6dc96ad0bb68

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

namespace :pull do
  desc 'Pull data (db/files) from remote (i.e: production) application.'
  task :data do
    invoke "pull:files"
    invoke "pull:db"
  end

  desc 'Pull db'
  task :db do
    on roles(:app) do |host|
      debug ":   Pulling database from #{fetch(:stage)} ..."
      within "#{current_path}/tmp" do
        with rails_env: fetch(:stage) do
          rake "db:backup"
        end
      end
      run_locally do
        execute "scp -P #{host.port} #{host.user}@#{host.hostname}:#{current_path}/tmp/db.sql tmp/"
        rake "db:restore tmp/db.sql"
      end
    end

  end

  desc 'Pull files uploaded'
  task :files do
    on roles(:app) do |host|
      run_locally do
        debug ":   Pulling Files from #{fetch(:stage)} ..."
        if fetch(:backup_dirs).any?
          fetch(:backup_dirs).each do |dir|
            execute "rm -r #{dir}"
            execute "scp -r -P #{host.port} #{host.user}@#{host.hostname}:#{current_path}/#{dir} #{dir}"
          end
        else
          error ":    Set key :backup_dirs to know which ones to pull"
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prun-ops-0.1.6 lib/capistrano/pull.rake
prun-ops-0.1.5 lib/capistrano/pull.rake
prun-ops-0.1.4 lib/capistrano/pull.rake
prun-ops-0.1.3 lib/capistrano/pull.rake
prun-ops-0.1.2 lib/capistrano/pull.rake
prun-ops-0.1.1 lib/capistrano/pull.rake
prun-ops-0.1.0 lib/capistrano/pull.rake
prun-ops-0.0.22 lib/capistrano/pull.rake
prun-ops-0.0.21 lib/capistrano/pull.rake
prun-ops-0.0.20 lib/capistrano/pull.rake