Socket
Socket
Sign inDemoInstall

mysql-backup

Package Overview
Dependencies
16
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mysql-backup

Create a backup from MySQL


Version published
Weekly downloads
23
decreased by-20.69%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

var mysqlDump = require('mysqldump');
var fs = require('fs');

mysqlDump({
	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

Keywords

FAQs

Last updated on 07 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc