Giter Site home page Giter Site logo

heroku-mysqldump's Introduction

heroku-mysqldump

Simple plugin to synchronize a Heroku remote MySQL database to a local MySQL database, and vice versa. Optional search and replace capabilities are included and provided by Search-Replace-DB. Both ClearDB and JawsDB Heroku add-ons are supported.

Installation

heroku plugins:install https://github.com/josepfrantic/heroku-mysqldump

Usage

All commands accept Heroku's --app <heroku_application_name> convention.

By default the plugin assumes either ClearDB or JawsDB add-on is in use, but not both. In case of having both add-ons indicate which one you want to use with the --db parameter (Values accepted: cleardb / jawsdb).

Note: The plugin will overwrite existing database contents, and cannot be undone. You are encouraged to take a database backup before running mysql:push to production environments.

Remote database (Heroku) to local MySQL database

Basic usage

heroku mysql:pull <local_database_name or MySQL DSN string>

Examples

heroku mysql:pull test --app my-heroku-app
heroku mysql:pull mysql://foo:bar@localhost/test --app my-heroku-app

With Search and replace

heroku mysql:pull <local_database_name | MySQL DSN string> --search mysite.herokuapp.com --replace localhost:5000

Local MySQL to remote MySQL database (Heroku)

Basic usage

heroku mysql:push <local_database_name | MySQL DSN string>

With Search and replace

heroku mysql:push <local_database_name | MySQL DSN string> --search localhost:5000 --replace mysite.herokuapp.com

Taking a database backup from Heroku

heroku mysql:dump 2>/dev/null > project_production_$(date +"%F_%H%M").sql

Note: Make sure to check the backup since errors are silenced from the output.

Note 2: 2>/dev/null is used to discard STDERR stream (for example Heroku warnings) which would end up to the output and therefore break the actual MySQL dump file. Again, please do check the dump.

Note 3: --search and --replace are not supported in mysql:dump. In such case, use mysql:pull (with search & replace) and manually run mysqldump locally afterwards.

heroku-mysqldump's People

Contributors

josepfrantic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heroku-mysqldump's Issues

Using mysql:dump prepends a comment to the dump file, making it syntax error

Using heroku mysql:dump <db> --search <old> --replace <new> > dump.sql prepends the generated dump.sql with info about database provider, such as Using ClearDB.

Easy fix would be to prepend the echo with -- making it -- Using ClearDB so it wont destroy the syntax, but it might not be ideal to fix the root cause.

Updating command-line interface for the tool

After discussion with pnu we agreed to change the interface for the tool.

heroku cleardb:pull X, where X is either:

a) local database name (we will use user root, empty password, and localhost as default).

b) MySQL DSN (mysql://username:password@host/database_name). For example: mysql://root@localhost/database-name should be an equivalent of option a).

Issue with installation

Hi, looks like a very handy script.
Unfortunately I have trouble installing.

heroku plugins:install https://github.com/josepfrantic/heroku-mysqldump

Installing https://github.com/josepfrantic/heroku-mysqldump@latest... !
 ▸    yarn add https://github.com/josepfrantic/heroku-mysqldump@latest --non-interactive
 ▸    --mutex=file:/Users/edwin/.local/share/heroku/plugins/yarn.lock
 ▸    --preferred-cache-folder=/Users/edwin/Library/Caches/heroku/yarn
 ▸    --registry=https://cli-npm.heroku.com exited with code 1
 ▸    error Refusing to download the git repo
 ▸    {"hostname":"github.com","protocol":"https:","repository":"https://github.com/josepfrantic/heroku-mysqldump@latest"}
 ▸    over HTTPS without a commit hash - possible certificate error?
 ▸
 ▸    yarn add v1.3.2
 ▸    info No lockfile found.
 ▸    [1/4] Resolving packages...
 ▸    info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

I tried to follow some of the tips when searching for this error like here:
yarnpkg/yarn#2976

However, I did not manage to get it working (not knowing much about yarn etc).

Is there a workaround for installing heroku-mysqldump ?

dash in the schema name

dear developer,

first of all - this is an awesome tool!!! i am so thankful you made it!
a minor addition to make it more awesome would be to allow for dash - separators in the schema name.

at present, when the local schema name contains a dash -, the operation fails with failing to parse url

you are the best. thank you for the great work. <3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.