-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
33 lines (27 loc) · 786 Bytes
/
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
const admin = require('firebase-admin')
const serviceAccount = require('./serviceAccountKey')
// load modules
const backup = require('./backup')
const restore = require('./restore')
// initialize firestore
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) })
const db = admin.firestore()
// get cmd line arguments
const argv = require('minimist')(process.argv.slice(2))
const mode = argv._[0]
const collection = argv.c || argv.collection
const file = argv.f || argv.file || `${collection}.json`
// start backup / restore
switch (mode) {
case 'b':
case 'backup':
backup(db, file, collection)
break
case 'r':
case 'restore':
restore(db, file, collection)
break
default:
console.log('Use "backup" or "restore" option')
break
}