#!/usr/bin/env bash
set -euo pipefail
cd /var/backups/databases
for i in $(lxc list --format csv -c n); do
if lxc exec $i -- which mysql; then
lxc exec $i -- mysqldump --opt --all-databases --force --events --hex-blob | cat > ${i}.sql
fi
if lxc exec $i -- which psql; then
lxc exec $i -- sudo -u postgres pg_dumpall | cat > ${i}.sql
done