This is a shell script that simplifies the process of restoring a PostgreSQL database from a backup file. The script expects the backup file to be located in the ~/Downloads/
directory.
- Save the script to a file with a
.sh
extension. - Open a terminal and navigate to the directory where the script is saved.
- Make the script executable using the command
chmod +x scriptname.sh
. - Run the script using the command
./scriptname.sh
. - The script will drop and recreate the database using the default database name or the name you provide.
- The script will prompt you to enter the backup file name or use the default file name.
- The script will restore the database using the chosen or default backup file name.
- Once the restore process is complete, the script will print a message indicating that the process is complete.
Note: The script expects the backup file to be located in the ~/Downloads/
directory. If the backup file is not located in that directory, the script will fail to restore the database.
You can customize the script by changing the default file name and database name. To do this, edit the following lines in the script:
defaultFileName="your_file_name_$today.backup"
defaultDatabase="your_database_name"
Replace your_file_name
with the name of your backup file and your_database_name
with the name of your database.