#!/bin/bash HEIGHT=15 WIDTH=75 CHOICE_HEIGHT=4 BACKTITLE="Restore iceshrimp database and / or files" TITLE="Restoring Iceshrimp" MENU="Choose one of the following options:" OPTIONS=(1 "Restore the iceshrimp database" 2 "Restore the iceshrimp /files/ directory") CHOICE=$(dialog --clear \ --backtitle "$BACKTITLE" \ --title "$TITLE" \ --menu "$MENU" \ $HEIGHT $WIDTH $CHOICE_HEIGHT \ "${OPTIONS[@]}" \ 2>&1 >/dev/tty) clear case $CHOICE in 1) echo -e "\e[1;33mRestoring the iceshrimp database\e[0m" echo -e "\e[1;33mThis process will restore the iceshrimp database (if a backup exists)\e[0m" # 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/00.logs/iceshrimp_backup_database ]; then # Message echo "" echo -e "\e[31mNo previous backup to restore!\e[0m" else # Restore the 'iceshrimp_backup_database' file echo "" echo -e "\e[1;33mRestore the 'iceshrimp_backup_database' file' file...\e[0m" sleep 2 pg_restore -U postgres -h localhost -p 5432 -d iceshrimp -v "/home/foo/Backups/10.sites/iceshrimp/database/iceshrimp_backup_database.sql" # Message echo "" echo -e "\e[32mRestored the iceshrimp database backup\e[0m" fi # Pause sleep 2 # Reload the menu bash /etc/init.d/restore_iceshrimp.sh ;; 2) echo -e "\e[1;33mRestoring the iceshrimp /files/ directory\e[0m" echo -e "\e[1;33mThis process will restore the iceshrimp /files/ (if a backup exists)\e[0m" # 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/00.logs/iceshrimp_backup_files ]; then # Message echo "" echo -e "\e[31mNo previous backup to restore!\e[0m" else # Restore the iceshrimp /files/ directory echo "" echo -e "\e[1;33mRestore the iceshrimp /files/ directory...\e[0m" sleep 2 sudo cp /home/foo/Backups/10.sites/iceshrimp/files/* /home/foo/iceshrimp/files # Message echo "" echo -e "\e[32mRestored the iceshrimp /files/ directory\e[0m" fi # Pause sleep 2 # Reload the menu bash /etc/init.d/restore_iceshrimp.sh ;; esac