Class: Backup::Database::MySQL
- Defined in:
- lib/backup/database/mysql.rb
Constant Summary
Constants included from CLI::Helpers
Instance Attribute Summary collapse
- 
  
    
      #additional_options  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Additional “mysqldump” options. 
- 
  
    
      #host  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Connectivity options. 
- 
  
    
      #mysqldump_utility  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Path to mysqldump utility (optional). 
- 
  
    
      #name  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Name of the database that needs to get dumped To dump all databases, set this to ‘:all` or leave blank. 
- 
  
    
      #only_tables  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Tables to dump, tables that aren’t specified won’t get dumped. 
- 
  
    
      #password  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Credentials for the specified database. 
- 
  
    
      #port  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Connectivity options. 
- 
  
    
      #skip_tables  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Tables to skip while dumping the database. 
- 
  
    
      #socket  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Connectivity options. 
- 
  
    
      #username  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Credentials for the specified database. 
Instance Method Summary collapse
- 
  
    
      #initialize(model, &block)  ⇒ MySQL 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Creates a new instance of the MySQL adapter object. 
- 
  
    
      #perform!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Performs the mysqldump command and outputs the data to the specified path based on the ‘trigger’. 
Methods included from Configuration::Helpers
Constructor Details
#initialize(model, &block) ⇒ MySQL
Creates a new instance of the MySQL adapter object
| 42 43 44 45 46 47 48 49 50 51 52 53 | # File 'lib/backup/database/mysql.rb', line 42 def initialize(model, &block) super(model) @skip_tables ||= Array.new @only_tables ||= Array.new @additional_options ||= Array.new instance_eval(&block) if block_given? @name ||= :all @mysqldump_utility ||= utility(:mysqldump) end | 
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Configuration::Helpers
Instance Attribute Details
#additional_options ⇒ Object
Additional “mysqldump” options
| 30 31 32 | # File 'lib/backup/database/mysql.rb', line 30 def @additional_options end | 
#host ⇒ Object
Connectivity options
| 18 19 20 | # File 'lib/backup/database/mysql.rb', line 18 def host @host end | 
#mysqldump_utility ⇒ Object
Path to mysqldump utility (optional)
| 34 35 36 | # File 'lib/backup/database/mysql.rb', line 34 def mysqldump_utility @mysqldump_utility end | 
#name ⇒ Object
Name of the database that needs to get dumped To dump all databases, set this to ‘:all` or leave blank.
| 10 11 12 | # File 'lib/backup/database/mysql.rb', line 10 def name @name end | 
#only_tables ⇒ Object
Tables to dump, tables that aren’t specified won’t get dumped
| 26 27 28 | # File 'lib/backup/database/mysql.rb', line 26 def only_tables @only_tables end | 
#password ⇒ Object
Credentials for the specified database
| 14 15 16 | # File 'lib/backup/database/mysql.rb', line 14 def password @password end | 
#port ⇒ Object
Connectivity options
| 18 19 20 | # File 'lib/backup/database/mysql.rb', line 18 def port @port end | 
#skip_tables ⇒ Object
Tables to skip while dumping the database
| 22 23 24 | # File 'lib/backup/database/mysql.rb', line 22 def skip_tables @skip_tables end | 
#socket ⇒ Object
Connectivity options
| 18 19 20 | # File 'lib/backup/database/mysql.rb', line 18 def socket @socket end | 
#username ⇒ Object
Credentials for the specified database
| 14 15 16 | # File 'lib/backup/database/mysql.rb', line 14 def username @username end | 
Instance Method Details
#perform! ⇒ Object
Performs the mysqldump command and outputs the data to the specified path based on the ‘trigger’
| 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | # File 'lib/backup/database/mysql.rb', line 58 def perform! super pipeline = Pipeline.new dump_ext = 'sql' pipeline << mysqldump if @model.compressor @model.compressor.compress_with do |command, ext| pipeline << command dump_ext << ext end end pipeline << "cat > '#{ File.join(@dump_path, dump_filename) }.#{ dump_ext }'" pipeline.run if pipeline.success? Logger. "#{ database_name } Complete!" else raise Errors::Database::PipelineError, "#{ database_name } Dump Failed!\n" + pipeline. end end |