Novices Plagiarizing Mozart

    grunt-mysqldump

    0.1.6 • Public • Published

    grunt-mysqldump

    Version npm Downloads npm MIT license

    Grunt plugin for dumping and archiving MySQL databases. Supports exporting and archiving multiple databases in a single operation. Runs asynchronously and extremely fast. Outputs export and compression information as each operation completes. Tested on moderate to large size databases without any problems.

    Getting Started

    This plugin requires Grunt >=0.4.1

    If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

    npm install grunt-mysqldump --save-dev

    Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

    grunt.loadNpmTasks('grunt-mysqldump');

    The "mysqldump" task

    Overview

    In your project's Gruntfile, add a section named mysqldump to the data object passed into grunt.initConfig().

    db: grunt.file.readJSON('config/database.json'),    
    mysqldump: {
      dist: {
        user: '<%= db.local.user %>',
        pass: '<%= db.local.pass %>',
        host: '<%= db.local.host %>',
        port: '<%= db.local.port %>',
        dest: 'backup/',
        options: {
          compress: 'gzip'
        },
        databases: [
          'my_forum',
          'my_blog',
          'employees',
          'sakila'
        ],
      },
    },

    Wildcard Usage

    To dump all available databases simply use an asterisk aka wildcard. When using the wildcard flag you have the option to ignore specific databases by creating an ignore array.

    db: grunt.file.readJSON('config/database.json'),    
    mysqldump: {
      dist: {
        user: '<%= db.local.user %>',
        pass: '<%= db.local.pass %>',
        host: '<%= db.local.host %>',
        port: '<%= db.local.port %>',
        dest: 'backup/',
        options: {
          compress: true,
          algorithm: 'zip',
          level: 5,
          both: true
        },
        databases: [
          '*'
        ],
        ignore: [
          'information_schema',
          'performance_schema',
          'phpmyadmin',
          'mysql',
          'sakila',
          'world'
        ],
      },
    },

    Arguments

    user

    The database user.

    pass

    The user's password.

    host

    The host of the database.

    port

    The port where the database is running, mostly 3306.

    dest

    The destination folder to write the dump to.

    Options

    compress

    Type: Boolean

    Default: false

    Required: false

    Set to false for no compression. Will only perform a mysqldump of the target database files.

    algorithm

    Type: String

    Default: zip

    Required: false

    Currently supports gzip, deflate, deflateRaw, tar, tgz and zip.

    level

    Type: Integer

    Default: 1

    Required: false

    Sets the level of archive compression.

    both

    Type: Boolean

    Default: false

    Required: false

    You have the option of saving both the sql dump file and the compressed file. Only relevant when archiving.

    type

    Type: String

    Default: both

    Required: false

    Currently supports data only, schema only or both.

    ignore

    Type: Array

    An array of database names to ignore when exporting. Valid when using a wildcard.

    Running

    To run all tasks type grunt mysqldump

    Awesome Libraries Used

    • shelljs - Portable Unix shell commands for Node.js.
    • node-archiver - A streaming interface for archive generation.
    • each-async - Async concurrent iterator (async forEach).
    • bytes.js - Node byte string parser.
    • mysql - A pure node.js JavaScript Client implementing the MySql protocol.

    License

    See the bundled LICENSE file for details.

    Author

    Tom Shaw (@urlrider)

    Install

    npm i grunt-mysqldump

    DownloadsWeekly Downloads

    17

    Version

    0.1.6

    License

    MIT

    Unpacked Size

    15 kB

    Total Files

    7

    Last publish

    Collaborators

    • urlrider