Skip to content

motomod/mysql-stash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MySQL-Stash

Quick, easy & simple way to stash your database state and reapply.

System requirements

MacOS

Install mysql-client package via Brew:

motomod@mac:~$ brew install mysql-client

Download the Go package from here and install.

Linux

Install the mysql-client & golang via your favourite package manager:

motomod@ubuntu:~$ apt-get install mysql-client golang

You'll also need bash but I'll assume that you probably already have this.

Installation

Clone this repo to your computer:

motomod@ubuntu:~$ git clone git@github.com:motomod/mysql-stash.git

Move into the new directory:

motomod@ubuntu:~$ cd mysql-stash

Install the package, this will plop a binary into your bin path:

motomod@ubuntu:~$ make install

You will need to ensure that you're GOPATH is set in your bash, zsh (or whatever) profile to be able to execute the binary.

Configuration

To use this application you'll need to create a configuration file located at ~/.config/mysql-stash/config.yml, see bundled example.

Root properties:

  • databases - An array of a database objects, keys are the name of the database:
    • host
    • port
    • database
    • user
    • pass

Usage

You can access the application by running:

motomod@ubuntu:~$ mysql-stash

Providing no arguments will result in a message to come back here, hiya 👋


Creating a stash

This command makes a snapshot of your current database, ready for you to reapply at a later date.

motomod@ubuntu:~$ mysql-stash stash <db name> <stash name>
  • <db name> the name of the database that you wish to create a stash for, must match one of the keys defined in your configuration or be all which will stash all of your databases.
  • <stash name> is the name that you wish to give your stash, you'll need this later when reapplying.

Stashes are standard SQL dumps from mysqldump and are located in the same path as your configuration.


Applying a stash

motomod@ubuntu:~$ mysql-stash apply <db name> <stash name>
  • <db name> the name of the database that you wish to apply a stash for, must match one of the keys defined in your configuration or be all which will apply the stashes for all of your databases.
  • <stash name> name of the stash that you wish to reapply.

Stashes are piped to the system mysql command in bash.


List stashes

List all of the stashes that you've created.

motomod@ubuntu:~$ mysql-stash list

View stash

If you want to export or view the SQL generated by a stash then:

motomod@ubuntu:~$ mysql-stash view <db name> <stash name>
  • <db name> the name of the database for the stash you wish to view, cannot be all this time, soz.
  • <stash name> name of the stash that you wish to view.

About

Small app that quickly stashes and reapplies database state

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors