Restore postgresql db from dump

script.sh

 #!/bin/bash
 if ["$(whoami)" != "root"]; then
     echo "Start script as root root!"
     exit 1
 fi
 _DBNAME="$1"
 while [ -z "$_DBNAME" ]; do
     echo "Write DB name!"
     read _DBNAME
 done
 _DBUSER="$2"
 while [ -z "$_DBUSER" ]; do
     echo "Write DB username!"
     read _DBUSER
 done
 _PATH="$3"
 while [ -z "$_PATH" ]; do
     echo "Write path to DB dump file!"
     read _PATH
 done
 service postgresql restart
 su - postgres -c "dropdb $_DBNAME"
 su - postgres -c "createdb $_DBNAME -O $_DBUSER"
 su - postgres -c "psql $_DBNAME < $_PATH"

Update permissions – Laravel

script.sh

#!/bin/bash
if [ "$(whoami)" != "root" ]; then
     echo "Start script as root!"
     exit 1
fi
_PATH="$1"
while [ -z "$_PATH" ]; do
     echo "Write path to Laravel folder!"
     read _PATH
done
_USER="$2"
while [ -z "$_USER" ]; do
     echo "Write user name!"
     read _USER
done
chown -R $_USER:www-data $_PATH/./portal
find $_PATH/./ -type f -exec chmod 664 {} \;
find $_PATH/./ -type d -exec chmod 775 {} \;
chgrp -R www-data $_PATH/storage $_PATH/bootstrap/cache
chmod -R ug+rwx $_PATH/storage $_PATH/bootstrap/cache