Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database.
WARNING: This will blow away your development database (duh)
gem install capistrano-mysqldump
- In your deploy file:
require 'capistrano/mysqldump'
- Run:
cap mysqldump
Or if you're using capistrano-ext/multistage
, do
cap production mysqldump
Or whatever environment you want to take the mysqldump from
Override these defaults in deploy.rb
if necessary
- Location of the mysqldump binary
set :mysqldump_bin, "/usr/local/mysql/bin/mysqldump"
- Where on the remote machine to dump the sql dump file
set :mysqldump_remote_tmp_dir, "/tmp"
- Where on the local machine to download the sql dump file from the remote machine
set :mysqldump_local_tmp_dir, "/tmp"
- Where to run the mysqldump command. If set to
:local
, mysqldump will use the-h
parameter and run the dump locally. The default is set to:local
if a host is specified, otherwise it is set to:remote
set :mysqldump_location, :local
- The tables to ignore during the dump
set :mysqldump_ignore_tables, %w(logs page_views)
- Or the tables to extract
set :mysqldump_tables, %w{cool_info totally_awesome_rows}
(default is all tables)
- Arbitrary options to pass to mysql dump
set :mysqldump_options, {'no-data' => true, 'port' => 3307 }}
Equivalent to running
$ mysqldump --no-data --port=3308
- Contributions welcome
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright (c) 2011 Alex Farrill. See LICENSE.txt for further details.