Skip to content

Use pg_backup helpers in custom Capistrano task #11

@vzamanillo

Description

@vzamanillo

I am trying to use the PgBackup::Helpers::Database in a custom Capistrano task

require 'rake'
require 'pg_backup/helpers/database'

include PgBackup::Helpers::Database

namespace :database do
  task :dev_backup do
    on roles(:db) do
      within current_path do
        with rails_env: fetch(:environment) do
          dump_dir = "#{shared_path}/#{fetch(:pg_backup_remote_dump_dir)}"
          backup_file = "#{dump_dir}/dev_database.backup"
          if !test("[ -d #{dump_dir} ]")
            error "Folder '#{dump_dir}' does not exits!"
          else
            with_database_config do |host, db, user, pw|
              ` PGPASSWORD=#{pw} pg_dump --host #{host} --username #{user} --clean --format=c --no-owner --no-acl --exclude-table-data 'table' #{db} > #{backup_file} `
            end
          end
        end
      end
    end
  end
end

but looks like ActiveRecord constant is not loaded

uninitialized constant PgBackup::Helpers::Database::ActiveRecord

any hints about how to resolve this?

Thx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions