-
Notifications
You must be signed in to change notification settings - Fork 0
/
badhan.js
72 lines (63 loc) · 1.82 KB
/
badhan.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require('./dotenv')
const yargs = require('yargs');
const fsExtra = require('fs-extra')
const controllers = require('./controllers');
require('./mongotools')
fsExtra.emptyDirSync('backup')
yargs.command({
command: 'backup',
describe: 'Backup the mongodb database to firebase storage',
handler: controllers.backupController
})
yargs.command({
command: 'list',
describe: 'Get the list of backups of mongodb database from firebase storage',
handler:controllers.listController
})
yargs.command({
command: 'delete',
describe: 'Remove a backup using timestamp',
builder:{
time: {
describe: 'Backup specified by the timestamp will be deleted.',
demandOption: true,
type: 'number'
}
},
handler: controllers.deleteController
})
yargs.command({
command: 'restore',
describe: 'Restore a backup using timestamp',
builder:{
time: {
describe: 'The backup having the specified timestamp will be restored',
demandOption: true,
type: 'number'
},
production: {
describe: 'If true, then the backup will be restored to the production database',
type: 'boolean',
default: false,
}
},
handler: controllers.restoreController
})
yargs.command({
command: 'prune',
describe: 'Keep latest maximum 3 backups and delete the remaining backups',
handler: controllers.pruneController
})
yargs.command({
command: 'restoreLatest',
describe: 'Restore the last backup to database',
builder:{
production: {
describe: 'If true, then the backup will be restored to the production database',
type: 'boolean',
default: false,
}
},
handler: controllers.restoreLatestController
})
yargs.parse();