Project

db_dumper

0.0
No commit activity in last 3 years
No release in over 3 years
Dump database schema and chosen data from remote machine
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 5.0
~> 10.0

Runtime

>= 5.2.1, ~> 5.2
 Project Readme

DB dumper - configurable SQL database data copying util from remote to local machine.

Gem Version Maintainability Build Status

Index

  • Usage
  • Config
  • Installation
    • Manually from RubyGems.org
    • Bundler

Usage

  • Setup config/application.yml file properly.
  • Install pg_dump, psql utils on remote machine for PostgreSQL adapter.

Example for simple Ruby file:

require 'rubygems/package'
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'db_dumper'
end

DbDumper.dump do
  dump 'roles'

  user_id = 1
  copy q('users').where(id: user_id)
  campaigns_q = q('campaigns').where('user_id = ? OR for_all IS TRUE', user_id)
  copy campaigns_q
  copy q('offices').where(campaign_id: campaigns_q.ar)
end

After executing you will see:

  • schema sql at schema_dump.sql
  • dumped tables sql at data_dump.sql
  • csv files at csv/*.csv

Config

remote_db

adapter

Currently supported only postgres adapter, so you can dump only PostgreSQL.

Config file example at config/application.yml

remote_db:
  adapter: postgres
  host: host
  port: 5432
  database: dockerdb
  username: docker
  password: pass

remote_user:
  name: docker
  host: beta.staging.com
  ssh_keys: ['/.ssh/docker']
  passphrase: pass

remote_machine:
  dest_path: /tmp

local_machine:
  dest_path: /tmp

Manually from RubyGems.org

% gem install db_dumper

Or if you are using Bundler

# Gemfile
gem 'db_dumper'

Latest changes

Take a look at the CHANGELOG for details about recent changes to the current version.

Questions?

Feel free to

Maintainers

Warranty

This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.