npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-mysqldump

v0.2.0

Published

A MYSQL database backup grunt task.

Downloads

5

Readme

grunt-mysqldump

Version npm Downloads npm MIT license

Grunt-mysqldump is a Grunt plugin for dumping and archiving MySQL databases. It supports exporting and archiving multiple databases in a single operation, runs asynchronously, and is extremely fast. Outputs export and compression information as each operation completes. Tested on moderate to large size databases without any problems.

Installation

Install the plugin with this command:

npm install grunt-mysqldump --save-dev

Enable the plugin inside your Gruntfile:

grunt.loadNpmTasks('grunt-mysqldump');

To run the task, issue the following command:

grunt mysqldump

Configuration

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: 'exports/',
    options: {
      compress: 'gzip'
    },
    databases: [
      'sakila',
      'world',
      'employees'
    ],
  },
},

Example config/database.json

{
  "local": {
    "username": "root",
    "password": "password",
    "hostname": "127.0.0.1",
    "port": "3306"
  }
}

Wildcard Usage

Dump all your databases by using an asterisk aka wildcard.

Note: When using the wildcard flag you have the option to ignore specific databases by creating a forget array.

mysqldump: {
  dist: {
    user: '<%= db.local.user %>',
    pass: '<%= db.local.pass %>',
    host: '<%= db.local.host %>',
    port: '<%= db.local.port %>',
    dest: 'backups/',
    options: {
      compress: true,
      algorithm: 'zip',
      level: 5,
      data_only: true
    },
    databases: [
      '*'
    ],
    forget: [
      '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 normally 3306.

dest

The destination folder to write the dump to.

Options

compress

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

  • Type: Boolean
  • Default: false
  • Required: false

algorithm

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

  • Type: String
  • Default: zip
  • Required: false

level

Sets the zlib compression level. This is an integer in the range of 0 to 9.

  • Type: Integer
  • Default: 1
  • Required: false

Here's what each level means:

| Level | Description | |-------|-------------| | 0 | No compression | | 1 | Best speed | | 2-8 | A compromise between speed and compression | | 9 | Best compression |

data_only

Suppress the CREATE TABLE statements from the output.

  • Type: Boolean
  • Default: false
  • Required: false

databases

An array of databases to export.

  • Type: Array

forget

An array of databases to ignore when using a databases wildcard.

  • Type: Array

Libraries Used

  • shelljs - Portable Unix shell commands for Node.js.
  • node-archiver - A streaming interface for archive generation.
  • bytes.js - Node byte string parser.
  • mysql - A pure node.js JavaScript Client implementing the MySql protocol.

License

The MIT License (MIT). See License File for more information.