class Toolshed::Commands::Mysql::Backup

Responsible for handing backup of mysql database

Public Class Methods

cli_options() click to toggle source
# File lib/toolshed/commands/mysql/backup.rb, line 9
def self.cli_options # rubocop:disable MethodLength
  {
    banner: 'Usage: mysql backup [options]',
    options: {
      host: {
        short_on: '-l'
      },
      path: {
        short_on: '-p'
      },
      username: {
        short_on: '-u'
      },
      password: {
        short_on: '-d'
      },
      name: {
        short_on: '-n'
      },
      wait_time: {
        short_on: '-w'
      }
    }
  }
end

Public Instance Methods

execute(_args, options = nil) click to toggle source
# File lib/toolshed/commands/mysql/backup.rb, line 35
def execute(_args, options = nil)
  options = options_with_defaults(options)
  Toolshed.logger.info ''
  Toolshed::Databases::Mysql::Backup.new(options).execute
  Toolshed.logger.info ''
  Toolshed.die
end

Private Instance Methods

options_with_defaults(options = nil) click to toggle source
# File lib/toolshed/commands/mysql/backup.rb, line 45
def options_with_defaults(options = nil)
  options ||= {}
  options[:host] ||= 'localhost'
  options[:path] ||= read_user_input("Storage Path (/tmp/test/#{Time.now.utc.getlocal.strftime('%Y%m%d')}.sql) ?", required: true)
  options[:username] ||= read_user_input('Username?', required: true)
  options[:name] ||= read_user_input('Database Name?', required: true)
  options
end