Add detection of psql without postgres
This commit is contained in:
parent
adb3d7b058
commit
53b178f609
1 changed files with 8 additions and 4 deletions
|
@ -3,10 +3,14 @@ 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
|
||||
if lxc exec "$i" -- which mysql>/dev/null; then
|
||||
echo "Dumping $i"
|
||||
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
|
||||
if lxc exec "$i" -- which psql >/dev/null; then
|
||||
if lxc exec "$i" -- id postgres >/dev/null 2/&1; then
|
||||
echo "Dumping $i"
|
||||
lxc exec "$i" -- sudo -u postgres pg_dumpall | cat > "${i}.sql"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Reference in a new issue