Giter Site home page Giter Site logo

mysql-backup's Introduction

Mysql Backup

Create a backup from MySQL. A modern version of mysqldump, but it's not to create a file, to output a string instead.

Installation

npm install mysql-backup

Get Start

Example

const mysqlBackup = require('mysql-backup')

mysqlBackup({
  host: 'localhost',
  user: 'root',
  password: '',
  database: 'test',
}).then(dump => {
  console.log(dump)
})

Full Options Example

const mysqlBackup = require('mysqldump')
const fs = require('fs')

mysqlBackup({
  host: 'localhost',
  user: 'root',
  password: '',
  database: 'test',
  tables:['players'], // only these tables
  where: {'players': 'id < 1000'}, // Only test players with id < 1000
  ifNotExist:true, // Create table if not exist
}).then(dump => {
  fs.writeFileSync('test.sql', dump) // Create data.sql file with dump result
})

Options

host

Type: String

Url to Mysql host. Default: localhost

port

Type: String

Port to Mysql host. Default: 3306

user

Type: String

The MySQL user to authenticate as.

password

Type: String

The password of that MySQL user

database

Type: String

Name of the database to dump.

tables

Type: Array

Array of tables that you want to backup.

Leave Blank for All. Default: [] ALL

schema

Type: Boolean

Output table structure Default: true;

data

Type: Boolean

Output table data for ALL tables Default: true;

where

Type: Object

Where clauses to limit dumped data Example: where: {'users': 'id < 1000'}

Combine with data: false to only dump tables with where clauses Default: null;

ifNotExist

Type: Boolean

Create tables if not exist method Default: true;

dropTable

Type: Boolean

Drop tables if exist Default: false;

getDump

Type: Boolean

Return dump as a raw data on callback instead of create file Default: false;

socketPath

Type: String

Path to a unix domain socket to connect to. When used host and port are ignored.

npm


The MIT License

mysql-backup's People

Contributors

ajouve avatar akamaozu avatar cperryk avatar dafrok avatar deathmark avatar droidmunkey avatar jonathanargentiero avatar jumplink avatar lukasgjetting avatar webcaetano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

alancnet

mysql-backup's Issues

Add typescript support

I would love to use this module in my typescript projects, but I cannot.

import mysqlbackup from "mysql-backup";

throws an error

Could not find a declaration file for module 'mysql-backup'. 'node_modules/mysql-backup/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/mysql-backup` if it exists or add a new declaration (.d.ts) file containing `declare module 'mysql-backup';`ts(7016)

and the command npm i --save-dev @types/mysql-backup also throws an error npm ERR! 404 '@types/mysql-backup@*' is not in this registry.

Support for views is missing.

Looks like this doesn't have support for views?
Line 155 index.js: let r =${data[i][0]['Create Table']};; returns undefined and that is then output in the string.
When a view is part one of the returned rows here, r is undefined.

does not exit

Hi

running your program, its dumps ok!
but the program does not exit from nodejs
the dump is ready but does not give back the nodejs prompt

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.