Dumpr

A Ruby Gem that's objective is to make dumping and importing databases easy.

Features:

  • generates gzipped sql dump files for a specific database or specific tables.
  • automates transfer of dump files to remote hosts
  • automates import

Executables installed:

  • dumpr

Dependencies

SSH access is assumed to be automated with .ssh/config entries

Installation

  gem install dumpr

Usage

Use the dumpr executable to export and import your databases.

dumpr

The dumpr command can be used to export and import database dumps.

Exporting

Generate yourdb.sql.gz and transfer it to server2

  dumpr --user user --password pw --db yourdb --file yourdb.sql --destination dbserver2:/data/dumps/

Importing

Then, over on dbserver2, import your dump file

  dumpr -i --user user --password pw --file /data/dumps/yourdb.sql

Ruby API

You can write your own scripts that use a Dumpr::Driver

Exporting

Generate yourdb.sql.gz and transfer it to server2

 Dumpr::Driver::Mysql.export( 
    :user => 'backupuser', :pass => 'dbpass',
    :db => 'yourdb', 
    :destination => 'server2:/data/dumps/yourdb.sql'
 )

Importing

Then, over on dbserver2, import your dump file

 Dumpr::Driver::Mysql.import( 
    :user => 'importuser', :pass => 'pass',
    :db => 'yourdb', 
    :file => '/data/dumps/yourdb.sql'
)

Standard Dumpr::Driver options

See Dumpr::Driver

CHANGELOG

  • Version 1.0

TODO

  • Dumpr::Driver::Postgres
  • automate importing after an export (socket communication exporter/importer, or just some dumb lockfile checking / polling)
  • security: stop logging passwords
  • daemonize
  • SSH parameters