Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ set :db_ignore_tables, []
# if you want to exclude table data (but not table schema) from dump
set :db_ignore_data_tables, []

# configure location where the dump file should be created
set :db_dump_dir, "./db"

# If you want to import assets, you can change default asset dir (default = system)
# This directory must be in your shared directory on the server
set :assets_dir, %w(public/assets public/att)
Expand Down
18 changes: 11 additions & 7 deletions lib/capistrano-db-tasks/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def current_time
end

def output_file
@output_file ||= "db/#{database}_#{current_time}.sql.#{compressor.file_extension}"
@output_file ||= "#{database}_#{current_time}.sql.#{compressor.file_extension}"
end

def compressor
Expand Down Expand Up @@ -117,19 +117,19 @@ def initialize(cap_instance)
end

def dump
@cap.execute "cd #{@cap.current_path} && #{dump_cmd} | #{compressor.compress('-', output_file)}"
@cap.execute "cd #{@cap.current_path} && #{dump_cmd} | #{compressor.compress('-', db_dump_file_path)}"
self
end

def download(local_file = "#{output_file}")
@cap.download! dump_file_path, local_file
@cap.download! db_dump_file_path, local_file
end

def clean_dump_if_needed
if @cap.fetch(:db_remote_clean)
@cap.execute "rm -f #{dump_file_path}"
@cap.execute "rm -f #{db_dump_file_path}"
else
@cap.info "leaving #{dump_file_path} on the server (add \"set :db_remote_clean, true\" to deploy.rb to remove)"
@cap.info "leaving #{db_dump_file_path} on the server (add \"set :db_remote_clean, true\" to deploy.rb to remove)"
end
end

Expand All @@ -143,8 +143,12 @@ def load(file, cleanup)

private

def dump_file_path
"#{@cap.current_path}/#{output_file}"
def db_dump_file_path
"#{db_dump_dir}/#{output_file}"
end

def db_dump_dir
@cap.fetch(:db_dump_dir) || "#{@cap.current_path}/db"
end
end

Expand Down