Dumpman gem is what you need if you have application somewhere and need to dump your DB, download it and restore that dump localy!
You have staging OR production server with running rails app on it.
For some reason you need DB dump from that server.
What you can do?
- Solution 1: connect to that server, make dump via CLI, download it, extract it on your local machine
- Solution 2: install this gem and run
bash rake db:prod:up
and that's it.
Add this line to your application's Gemfile:
gem 'dumpman'
Then execute:
$ bundle
Or install it yourself as:
$ gem install dumpman
Generate default config:
$ rails g dumpman
it will create file app/config/initializers/dumpman.rb
Dumpman.setup do
# dump file name
dump_file_name "dumpman.sql"
# :prod is uniq connection name
define_source :prod do
# application environment (RAILS_ENV)
app_env 'production'
# ssh command for connection to the remote server
ssh_cmd '[email protected]'
# ssh options for connection to the remote server
# example:
# ssh_opts '-i ~/.ssh/sertificate.pem'
# fetch strategy
# if you are using capistrano or other deployment methods
# where you have direct access to filesystem where the application code is located
# you should use :direct strategy
fetch_strategy :direct
# if your application is running under the docker you can use :docker strategy
# if you selected :docker as fetch_strategy
# you have to set docker_image as well
# docker_image "645843940509.dkr.ecr.us-east-1.amazonaws.com/oh-snowflake"
# if you selected :direct as fetch strategy
# please set
# app path on the remote server
app_path '~/application/current'
end
end
Update app/config/initializers/dumpman.rb with propper settings.
Now you are able to use awesome commands:
$ rake db:prod:up # makes db dump on that server, compreses it, downloads, extracts localy
$ rake db:stage:up
$ rake db:qa:up
as well as local dump&restor
$ rake db:dump
$ rake db:restore
Bug reports and pull requests are welcome!
The gem is available as open source under the terms of the MIT License.