Sha256: 275f16d30f40563305a9127b8f0b25d2f0818bec7bdd17af96b08a2e4d1905f6

Contents?: true

Size: 1.03 KB

Versions: 39

Compression:

Stored size: 1.03 KB

Contents

namespace :db do
  desc "Capture a database snapshot"
  task :backup do
    on roles(:db), primary: true do |host|
      unless fetch(:linked_dirs).include?("db/backups")
        warn "'db/backups' is not in your capistrano linked_dirs; you should add it yo"
      end
      within release_path do
        execute :rake, "db:backup", "RAILS_ENV=#{fetch(:rails_env)}"
      end
    end
  end

  desc "Fetch the latest database backup"
  task :fetch do
    on roles(:db), primary: true do |host|
      FileUtils.mkdir_p 'db/backups'
      download! "#{deploy_to}/shared/db/backups/latest.dump", "db/backups/latest-#{fetch(:stage)}.dump"
    end
  end

  desc "Restore the database from a local file FILE=./local/file_path"
  task :restore do
    on roles(:app), primary: true do |host|
      within release_path do
        remote_path = "#{release_path}/db/backups/#{File.basename(ENV["FILE"])}"
        upload! ENV["FILE"], remote_path
        execute :rake, "db:restore", "RAILS_ENV=#{fetch(:rails_env)}", "FILE=#{remote_path}"
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
jefferies_tube-1.2 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.1.1 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.1.0 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.0.5 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.0.4 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.0.3 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.0.2 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.0.1 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-1.0.0 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.9 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.8 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.7 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.6 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.5 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.4 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.3 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.2 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.1 lib/jefferies_tube/capistrano/db.rb
jefferies_tube-0.1.0 lib/jefferies_tube/capistrano/db.rb