This is an experimental database fetching tool for projects using SilverStripe
with _ss_environment.php
files for database config and Beam.
A project's beam.json
config is used to find SSH connection details, and the database details
for that environment are read from the _ss_environment.php file on the server.
This is essentially a wrapper to build and run a shell command like this:
ssh user@example.com mysqldump -u user -p'password' someremotedatabase \| gzip -c | gunzip -c | mysql somelocaldb
This script currently uses pv
to show download progress. pv
is not optional yet, so you may need to install it:
# OSX with brew
brew install pv
Download the script below to somewhere on your PATH, and make it executable:
curl https://gist.githubusercontent.com/stecman/21ef4452dc18d30391a5/raw/getdb -o ~/bin/getdb
chmod +x ~/bin/getdb
Then use as:
getdb [beam target] [local database name]
eg. getdb live dev_foo
The local database will be created automatically if it doesn't exist.