backup/all.sh

28 lines
667 B
Bash
Raw Normal View History

2024-07-11 21:18:02 +05:00
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
2024-08-08 05:50:15 +05:00
echo -e "\033[31mThis script requires superuser rights\033[0m"
2024-07-11 21:18:02 +05:00
exit 0
fi
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT
set -e
export DEBIAN_FRONTEND=noninteractive
2024-08-08 05:50:15 +05:00
docker exec -i postgres psql -U $POSTGRES_USER -d $POSTGRES_DB -t -A -F',' <<-EOSQL |
SELECT d.datname, a.rolname
FROM pg_database d
JOIN pg_roles a ON d.datdba = a.oid
WHERE d.datistemplate = false;
EOSQL
while IFS=, read -r dbname owner; do
2024-07-11 21:18:02 +05:00
bash postgres.sh "$dbname" "$owner"
done
bash files.sh
2024-08-08 05:50:15 +05:00
bash acme.sh
2024-07-11 21:18:02 +05:00
bash cleaner.sh
trap - EXIT
2024-08-08 05:50:15 +05:00
echo "All backups were made successfully. Outdated backups have been deleted"