1 | 'use strict'
|
2 |
|
3 | const co = require('co')
|
4 | const cli = require('heroku-cli-util')
|
5 |
|
6 | function * run (context, heroku) {
|
7 | const host = require('../../lib/host')
|
8 | const fetcher = require('../../lib/fetcher')(heroku)
|
9 | const {app} = context
|
10 |
|
11 | let db = yield fetcher.arbitraryAppDB(app)
|
12 | let schedules = yield heroku.get(`/client/v11/databases/${db.id}/transfer-schedules`, {host: host(db)})
|
13 |
|
14 | if (!schedules.length) {
|
15 | throw new Error(`No backup schedules found on ${cli.color.app(app)}
|
16 | Use ${cli.color.cmd('heroku pg:backups:schedule')} to set one up`)
|
17 | }
|
18 |
|
19 | cli.styledHeader('Backup Schedules')
|
20 | for (let s of schedules) {
|
21 | cli.log(`${cli.color.configVar(s.name)}: daily at ${s.hour}:00 ${s.timezone}`)
|
22 | }
|
23 | }
|
24 |
|
25 | module.exports = {
|
26 | topic: 'pg',
|
27 | command: 'backups:schedules',
|
28 | description: 'list backup schedule',
|
29 | needsApp: true,
|
30 | needsAuth: true,
|
31 | run: cli.command({preauth: true}, co.wrap(run))
|
32 | }
|