Sha256: 45809eb88b4bddc2b94716cf652264c7f8611b89bdff39f412edad069533e9ec
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'rake' require 'rake/tasklib' module Koine module Tasks class MysqlDump < Rake::TaskLib OutputFileNotSetError = Class.new(StandardError) attr_accessor :task_name attr_accessor :dependencies attr_accessor :hostname attr_accessor :database attr_accessor :username attr_accessor :password attr_accessor :url attr_writer :output_file def initialize(env: ENV) self.task_name ||= 'mysql:dump' self.dependencies ||= [] self.url ||= env['DB_URL'] self.hostname ||= env['DB_HOST'] self.database ||= env['DB_NAME'] self.username ||= env['DB_USER'] self.password ||= env['DB_PASSWORD'] self.output_file = env['MYSQL_BACKUP_FILE'] yield(self) if block_given? define_task end def output_file @output_file || raise(OutputFileNotSetError) end private def define_task desc 'Mysqldump to backup file' task task_name => dependencies do execute_task end end def execute_task backup = Koine::DbBkp::Mysql::Dump.new(configuration) backup.to_sql_file(output_file) end def configuration { url: url, hostname: hostname, database: database, username: username, password: password } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
koine-db_bkp-0.1.3 | lib/koine/tasks/mysql_dump.rb |
koine-db_bkp-0.1.2 | lib/koine/tasks/mysql_dump.rb |
koine-db_bkp-0.1.1 | lib/koine/tasks/mysql_dump.rb |