class Object
Public Instance Methods
dump_database(pack=nil)
click to toggle source
# File lib/capistrano_misc_recipes/tasks.rb, line 29 def dump_database pack=nil config = ActiveRecord::Base.configurations[Rails.env] raise "Destination directory do not exists" if !ENV['store_path'].blank? && !File.exists?(File.expand_path(ENV['store_path'])) store_path = !ENV['store_path'].blank? ? File.expand_path(ENV['store_path']) : '.' dump_file = !ENV['dump_file'].blank? ? ENV['dump_file'].dup : "#{`hostname`.chomp}-#{config['database']}" dump_file << '-' + Time.now.strftime('%Y-%m-%d-%H-%M-%S') unless !ENV['without_timestamp'].blank? && ENV['without_timestamp'].downcase == 'y' dump_file << '.sql' case pack when 'gzip' ; dump_file << '.gz' when 'bzip2' ; dump_file << '.bz2' end file = File.expand_path(File.join(store_path, dump_file)) command = ::CapistranoMiscRecipes::DbDump.command config.merge('pack' => pack, 'dump_file' => dump_file) puts command system command end