Module: DumpCommand
- Defined in:
- lib/backupper/dump_command.rb
Constant Summary collapse
- EXTENSIONS =
Extension of the file produced by each adapter ('.sql.bz2' if not listed here)
Hash.new('.sql.bz2').update('mydumper' => '.tar.bz2').freeze
Class Method Summary collapse
- .mydumper(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) ⇒ Object
- .mysql(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) ⇒ Object
- .postgresql(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) ⇒ Object
Class Method Details
.mydumper(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/backupper/dump_command.rb', line 20 def self.mydumper(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) params = [] params << "--user #{username}" params << "--password #{password}" if password params << if return "mydumper --database #{database} #{params.join(' ')} --outputdir #{working_dir} && tar -cjf #{outfile} -C #{File.dirname(working_dir)} #{File.basename(working_dir)}" end |
.mysql(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/backupper/dump_command.rb', line 5 def self.mysql(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) params = [] params << "-u#{username}" params << "-p#{password}" if password params << if return "mysqldump #{database} #{params.join(' ')} | bzip2 > #{outfile}" end |
.postgresql(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/backupper/dump_command.rb', line 13 def self.postgresql(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:) params = [] params << "-U #{username}" params << if return "PGPASSWORD=#{password} pg_dump #{database} #{params.join(' ')} | bzip2 > #{outfile}" end |