Last active
July 4, 2023 20:02
-
-
Save ingeit/b52bf89b95f6cc74f7b3930fee835977 to your computer and use it in GitHub Desktop.
backup mysql automatico con schedule completo nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysqlDump = require('mysqldump'); | |
//npm install node-schedule --save | |
var schedule = require('node-schedule'); | |
var j = schedule.scheduleJob(' 12 * * * * * ', function(){ | |
// * * * * * * | |
// ┬ ┬ ┬ ┬ ┬ ┬ | |
// │ │ │ │ │ | | |
// │ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun) | |
// │ │ │ │ └───── month (1 - 12) | |
// │ │ │ └────────── day of month (1 - 31) | |
// │ │ └─────────────── hour (0 - 23) | |
// │ └──────────────────── minute (0 - 59) | |
// └───────────────────────── second (0 - 59, OPTIONAL) | |
mysqlDump({ | |
host: 'localhost', | |
user: 'root', | |
password: '', | |
database: 'DATABASENAME', | |
tables:['TABLENAME'], // only these tables | |
// getDump: false,//BOOLEAN Return dump as a raw data on callback instead of create file Default: false; | |
// where: {'players': 'id < 1000'}, // Only test players with id < 1000 | |
dest:'./mysqlDumps/chBack.sql' // destination file | |
},function(err){ | |
if (err) console.log("error"); | |
else console.log("Dump correcto desde models"); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment