Create a backup from MySQL
npm install mysqldump
Example
var mysqlDump = require('mysqldump');
mysqlDump({
host: 'localhost',
user: 'root',
password: '',
database: 'test',
dest:'./data.sql' // destination file
},function(err){
// create data.sql file;
})
Full Options Example :
var mysqlDump = require('mysqldump');
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
disableForeignKeyChecks: true, //Adds SET foreign_key_checks = 0; at the file begin
dest:'./data.sql' // destination file
},function(err){
// create data.sql file;
})
Type: String
Url to Mysql host. Default: localhost
Type: String
Port to Mysql host. Default: 3306
Type: String
The MySQL user to authenticate as.
Type: String
The password of that MySQL user
Type: String
Name of the database to dump.
Type: Array
Array of tables that you want to backup.
Leave Blank for All. Default: [] ALL
Type: Boolean
Output table structure Default: true
;
Type: Boolean
Output table data for ALL tables Default: true
;
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
;
Type: Boolean
Create tables if not exist method Default: true
;
Type: Boolean
Drop tables if exist Default: false
;
Type: Boolean
Adds SET foreign_key_checks = 0; at the begin of the generated file Default: false
;
Type: Boolean
Return dump as a raw data on callback instead of create file Default: false
;
Type: String
Output filename with directories Default: './data.sql'
;
Type: String
Path to a unix domain socket to connect to. When used host
and port
are ignored.
The MIT License
I am looking for maintainers to help triage issues and merge pull requests for this repository
If you are interested in helping me maintain this library, please let me know! Read more here »
Your help would be greatly appreciated!