Skip to content

Use pg_backup helpers in custom Capistrano task #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vzamanillo opened this issue Jun 22, 2020 · 0 comments
Open

Use pg_backup helpers in custom Capistrano task #11

vzamanillo opened this issue Jun 22, 2020 · 0 comments

Comments

@vzamanillo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant