Pyinfra that deploy my LXD server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
518 B

#!/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 >/dev/null 2>&1; then
echo "Dumping $i"
lxc exec "$i" -- mysqldump --opt --all-databases --force --hex-blob | cat > "${i}.sql"
if lxc exec "$i" -- which psql >/dev/null 2>&1; then
if lxc exec "$i" -- id postgres >/dev/null 2>&1; then
echo "Dumping $i"
lxc exec "$i" -- sudo -u postgres pg_dumpall 2>/dev/null | cat > "${i}.sql"