Skip to content

Commit

Permalink
Clean up and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
callahanrts committed Nov 16, 2017
1 parent 31c8c59 commit fe20d5c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 21 deletions.
72 changes: 57 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

`dbmgr` is a command line tool for backing up and restoring databases. It's a useful
tool for:
- Backing up and restoring your development databases
- Sharing databases between developers
- Provisioning new Vagrant vms and Docker images
- Provisioning new Vagrant VMs and Docker images
- Provisioning new developers with a working database

## Installation
Expand All @@ -12,39 +13,80 @@ tool for:
$ brew tap callahanrts/dbmgr
$ brew install dbmgr
```

or

```
$ gem install dbmgr
```

## Backup
### Back up a MySQL database
## Usage
```
dbmgr [dbms] [action] --options-list
```

### Backup
#### Back up a database
```bash
# Back up database from local MySQL server
$ dbmgr backup database_name -d mysql
# Back up database from local server
dbmgr [dbms] backup database_name

# Back up database from a remote MySQL server
$ dbmgr backup database_name -d mysql -P 3307 -h 192.168.33.10 -u root
# 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 backup database_name -d mysql -p ~/Downloads
dbmgr [dbms] backup database_name -p ~/Downloads

# Back up database as a named backup
$ dbmgr backup database_name -d mysql -f my_backup.sql
dbmgr [dbms] backup database_name -f my_backup.sql
```

## Restore
### Restore a MySQL database
### Restore
#### Restore a MySQL database
```bash
# Restore local database from the latest backup in the default location
$ dbmgr restore database_name -d mysql
dbmgr [dbms] restore database_name

# Restore remote database with the latest backup
$ dbmgr restore database_name -d mysql -P 3307 -h 192.168.33.10 -u root
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 restore database_name -d mysql -p ~/Downloads
dbmgr [dbms] restore database_name -p ~/Downloads

# Restore database from a named backup
$ dbmgr restore database_name -d mysql -f my_backup.sql
dbmgr [dbms] restore database_name -f my_backup.sql
```

## Help
```
dbmgr help
dbmgr help mysql
dbmgr mysql help backup
dbmgr psql help backup
...
```

## Tips
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.
```bash
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
}
```

## Contributing

### Build the Gem
```bash
gem build dbmgr.gemspec
```

### Install the Built Gem
```bash
gem install ./dbmgr-x.x.x.gem
```
2 changes: 1 addition & 1 deletion bin/dbmgr-dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

require 'dbmgr'

Dbmgr::DbMgr.start( ARGV )
Dbmgr::CLI.start( ARGV )
3 changes: 2 additions & 1 deletion dbmgr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '< 2.5'

spec.summary = %q{Create database backups and restore from previously created backups}
spec.description = %q{Create database backups to share with others across your dev team. Other developers can restore from backups you've created.}
spec.description = %q{Create database backups to share with others across your dev team.
Other developers can restore from backups you've created.}
spec.homepage = "https://github.com/callahanrts/dbmgr"
spec.license = "MIT"

Expand Down
2 changes: 1 addition & 1 deletion lib/dbmgr/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Dbmgr
class CLI < Thor

desc "mysql [COMMAND]", "Run commands on MySQL Databases"
desc "mysql", "Run commands on MySQL Databases"
subcommand "mysql", Dbmgr::MySQLCLI

end
Expand Down
2 changes: 1 addition & 1 deletion lib/dbmgr/mysql/backup.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Dbmgr
class MySQLCLI < Thor

desc "backup [database_name]", "Create a backup"
desc "backup", "Create a backup"
method_option :filename,
aliases: ["f"],
type: :string,
Expand Down
2 changes: 1 addition & 1 deletion lib/dbmgr/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Dbmgr
class CLI < Thor

desc "psql [COMMAND]", "Run commands on MySQL Databases"
desc "psql", "Run commands on PostgreSQL Databases"
subcommand "psql", Dbmgr::PostgreSQLCLI

end
Expand Down
2 changes: 1 addition & 1 deletion lib/dbmgr/postgresql/backup.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Dbmgr
class PostgreSQLCLI < Thor

desc "backup [database_name]", "Create a backup"
desc "backup", "Create a backup"
method_option :filename,
aliases: ["f"],
type: :string,
Expand Down

0 comments on commit fe20d5c

Please sign in to comment.