UNPKG

873 BJavaScriptView Raw
1'use strict'
2
3const co = require('co')
4const cli = require('heroku-cli-util')
5
6function * 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.name}/transfer-schedules`, {host: host(db)})
13
14 if (!schedules.length) {
15 throw new Error(`No backup schedules found on ${cli.color.app(app)}
16Use ${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
25module.exports = {
26 topic: 'pg',
27 command: 'backups:schedules',
28 needsApp: true,
29 needsAuth: true,
30 run: cli.command({preauth: true}, co.wrap(run))
31}