-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrestore.js
More file actions
59 lines (52 loc) · 1.48 KB
/
restore.js
File metadata and controls
59 lines (52 loc) · 1.48 KB
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
const { reporter, tryCatchAsync } = require('@dhis2/cli-helpers-engine')
const {
initDockerComposeCache,
resolveConfiguration,
} = require('../../common.js')
const { restore } = require('../../helpers/db.js')
const run = async function (argv) {
const { name, getCache } = argv
const cfg = await resolveConfiguration(argv)
const cacheLocation = await initDockerComposeCache({
composeProjectName: name,
cache: getCache(),
dockerComposeRepository: cfg.dockerComposeRepository,
dockerComposeDirectory: cfg.dockerComposeDirectory,
force: false,
})
if (!cacheLocation) {
reporter.error('Failed to initialize cache...')
process.exit(1)
}
const res = await tryCatchAsync(
'db::restore',
restore({
cacheLocation,
dbVersion: cfg.dbVersion,
url: cfg.demoDatabaseURL,
...argv,
})
)
if (res.err) {
reporter.error('Failed to restore database')
reporter.debugErr(res.err)
process.exit(1)
}
}
module.exports = {
command: 'restore <name> [path]',
desc: 'Restore the database from a backup',
builder: {
update: {
alias: 'u',
desc: 'Force re-download of cached files',
type: 'boolean',
default: false,
},
dbVersion: {
desc: 'Version of the Database dump to use',
type: 'string',
},
},
handler: run,
}