#!/bin/bash

set -e

kinit -k "daemon/$(hostname -f)"
aklog sipb

db_filename="/mit/xvm/backups/db/prod/$(date +%Y-%m-%d-%H-%M.sql.gz)"

/usr/bin/pg_dump -U "$(invirt-getconf db.user)" \
                 -h "$(invirt-getconf db.host)" \
                 "$(invirt-getconf db.dbname)" | gzip - >"$db_filename"

running_filename="/mit/xvm/log/running/prod/$(date +%Y-%m-%d-%H-%M.gz)"

remctl "$(invirt-getconf remote.hostname)" web listvms | gzip - >"$running_filename"
