You've already forked crontab-ui
mirror of
https://github.com/alseambusher/crontab-ui.git
synced 2025-12-18 11:53:57 +08:00
take backup
This commit is contained in:
25
crontab.js
25
crontab.js
@@ -24,6 +24,14 @@ exports.create_new = function(name, command, schedule){
|
||||
exports.update = function(data){
|
||||
db.update({_id: data._id}, crontab(data.name, data.command, data.schedule, null));
|
||||
}
|
||||
|
||||
exports.status = function(_id, stopped){
|
||||
db.update({_id: _id},{$set: {stopped: stopped}});
|
||||
}
|
||||
|
||||
exports.remove = function(_id){
|
||||
db.remove({_id: _id}, {});
|
||||
}
|
||||
exports.crontabs = function(callback){
|
||||
db.find({}, function(err, docs){
|
||||
callback(docs);
|
||||
@@ -43,3 +51,20 @@ exports.set_crontab = function(){
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
exports.get_backup_names = function(){
|
||||
var backups = []
|
||||
fs.readdirSync(__dirname + '/crontabs').forEach(function(file){
|
||||
// file name begins with backup
|
||||
if(file.indexOf("backup") == 0){
|
||||
backups.push(file);
|
||||
}
|
||||
});
|
||||
|
||||
return backups;
|
||||
}
|
||||
|
||||
exports.backup = function(){
|
||||
//TODO check if it failed
|
||||
fs.createReadStream( __dirname + '/crontabs/crontab.db').pipe(fs.createWriteStream( __dirname + '/crontabs/backup ' + (new Date()).toString() + '.db'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user