Skip to content

Instantly share code, notes, and snippets.

@yglodt
Created February 7, 2019 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yglodt/b314b6cb37d6c55447a9bf6052c94066 to your computer and use it in GitHub Desktop.
Save yglodt/b314b6cb37d6c55447a9bf6052c94066 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ "$1" == "" ]]; then
echo "Dump file to restore not specified, please give it as parameter."
exit 1
fi
echo "Stopping apache2"
sudo service apache2 stop
#echo "Stopping tomcat7"
#sudo service tomcat7 stop
echo "Restarting postgresql"
sudo service postgresql restart
echo "Dropping mydb database"
sudo -u postgres dropdb mydb
echo "Creating new mydb database"
sudo -u postgres createdb mydb
echo "Restoring backup dump"
#sudo -u postgres pg_restore --create --clean -v -d mydb $1
sudo -u postgres pg_restore -v -d mydb $1
#echo "Starting tomcat7"
#sudo service tomcat7 start
echo "Starting apache2"
sudo service apache2 start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment