#!/bin/bash # The remote restore process # ~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Restore from the hourly backup on the server clear # Check to see if a backup has previously completed successfully # If a backup is in place then carry on and restore it if [ ! -f /home/foo/Backups/firefish_backup_created ]; then echo "No previous backup to restore!" exit 0 fi # Restore the Firefish 'default.yml' config echo -e "\e[1;33mRestore the Firefish 'default.yml' config...\e[0m" sudo cp /home/foo/Backups/firefish/configs/* /home/firefish/firefish/.config/ echo -e "\e[32mDone\e[0m" echo "" # Restore the Firefish /files/ directory echo -e "\e[1;33mRestore the Firefish /files/ directory...\e[0m" sudo cp /home/foo/Backups/firefish/files/* /home/firefish/firefish/files echo -e "\e[32mDone\e[0m" echo "" # Stop the running PostgreSQL service echo -e "\e[1;33mStop the running PostgreSQL service...\e[0m" sudo systemctl stop postgresql.service echo -e "\e[32mDone\e[0m" echo "" # Current PostgreSQL status echo -e "\e[1;33mCurrent PostgreSQL status...\e[0m" sudo systemctl status postgresql echo -e "\e[32mDone\e[0m" echo "" # chown the existing PostgreSQL installation echo -e "\e[1;33mchown the existing PostgreSQL installation...\e[0m" sudo chown -R foo:foo /var/lib/postgresql/15/main/ echo -e "\e[32mDone\e[0m" echo "" # Remove the existing PostgreSQL files echo -e "\e[1;33mRemove the existing PostgreSQL files...\e[0m" sudo rm -fr /var/lib/postgresql/15/main/* echo -e "\e[32mDone\e[0m" echo "" # Copy the latest backup to the PostgreSQL target location echo -e "\e[1;33mCopy the latest backup to the PostgreSQL target location...\e[0m" sudo cp -R /home/foo/Backups/firefish/postgresql/* /var/lib/postgresql/15/main/ echo -e "\e[32mDone\e[0m" echo "" # Make the PostgreSQL user take ownership of the target location echo -e "\e[1;33mMake the PostgreSQL user take ownership of the target location...\e[0m" sudo chown -R postgres:postgres /var/lib/postgresql/15/main/ echo -e "\e[32mDone\e[0m" echo "" # Start the PostgreSQL service echo -e "\e[1;33mStart the PostgreSQL service...\e[0m" sudo systemctl start postgresql.service echo -e "\e[32mDone\e[0m" echo "" # Current PostgreSQL status echo -e "\e[1;33mCurrent PostgreSQL status...\e[0m" sudo systemctl status postgresql echo -e "\e[32mDone\e[0m" echo "" # Is Firefish running echo -e "\e[1;33mIs Firefish running...\e[0m" systemctl status --no-pager site.example.net.service echo -e "\e[32mDone\e[0m" echo ""