Command line tool to back up, restore, and provision development databases
dbmgr
is a command line tool for backing up and restoring databases. It’s a useful
tool for:
$ brew tap callahanrts/dbmgr
$ brew install dbmgr
or
$ gem install dbmgr
dbmgr [dbms] [action] --options-list
# Back up database from local server
dbmgr [dbms] backup database_name
# Back up database from a remote server
dbmgr [dbms] backup database_name -P 3307 -h 192.168.33.10 -u root
# Back up database and store in a specific location
dbmgr [dbms] backup database_name -p ~/Downloads
# Back up database as a named backup
dbmgr [dbms] backup database_name -f my_backup.sql
# Restore local database from the latest backup in the default location
dbmgr [dbms] restore database_name
# Restore remote database with the latest backup
dbmgr [dbms] restore database_name -P 3307 -h 192.168.33.10 -u root
# Restore local database from the latest backup in a specific location
dbmgr [dbms] restore database_name -p ~/Downloads
# Restore database from a named backup
dbmgr [dbms] restore database_name -f my_backup.sql
dbmgr help
dbmgr help mysql
dbmgr mysql help backup
dbmgr psql help backup
...
Add a function in your ~/.bashrc
to back up a specific database so you don’t
have to type out all of the options each time.
function dbbackup(){
dbmgr mysql backup mydb_dev -P 3306 -h 192.168.99.100
}
function dbrestore() {
dbmgr mysql restore mydb_dev -P 3306 -h 192.168.99.100
}
gem build dbmgr.gemspec
gem install ./dbmgr-x.x.x.gem