-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
47 lines (41 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
const config = require('./config');
const command = process.argv[2];
const param = process.argv[3];
const doBackup = require('./lib/backup');
const doRotation = require('./lib/rotate');
switch(command){
case 'backup':
backup();
break;
case 'rotate':
rotate();
break;
default:
console.error("Invalid parameter");
process.exit(1);
}
async function backup(){
var actions = config;
if(param) {
actions = config.filter(c => c.name == param);
if(!actions.length){
console.log("There is no backup configuration with this name");
return
}
}
else console.log("Running all backup configurations");
await Promise.map(actions, action => doBackup(action));
}
async function rotate(){
var actions = config;
if(param) {
actions = config.filter(c => c.name == param);
if(!actions.length){
console.log("There is no backup configuration with this name");
return
}
}
else console.log("Running all backup configurations");
await Promise.map(actions, action => doRotation(action));
}