#!/bin/bash clear; # Backup the whole PostgreSQL application # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Remove the file showing that a previous backup was successful echo ""; echo -e "\e[1;33mRemove the file showing that a previous backup was successful...\e[0m"; rm /home/foo/logs/postgresql_backup_created; echo -e "\e[32mDone\e[0m"; # Backup the whole of the PostgreSQL database installation echo ""; echo -e "\e[1;33mBackup the whole of the PostgreSQL database...\e[0m"; rm -R /home/foo/backups/postgresql/; pg_basebackup -h localhost -p 5432 -U postgres -D /home/foo/backups/postgresql -Fp -Xs -P; echo -e "\e[32mDone\e[0m"; # Create a file to show that the backup has successfully completed echo ""; echo -e "\e[1;33mCreate a file to show that the backup has successfully completed...\e[0m"; touch /home/foo/logs/postgresql_backup_created; echo -e "\e[32mDone\e[0m";