Bash Scripts for Laravel PHP Linux Devops Bash Scripts for Laravel PHP Linux Devops

August 25, 2020

bash debian devops laravel

Having spent the summer learning more of the Devops toolkit, I often come back to bash shell scripts to achieve something.

I wanted a little script to import the values of the .env file to use in the bash scripts. This works as i expect.


source /var/www/laravel/.env


This is a one liner to backup all the mysql databases.

mysql -u root -p -N -e 'show databases' | while read dbname; do mysqldump -u root -p --complete-insert --routines --triggers --single-transaction "$dbname" > "$dbname".sql; done

Working with the jigsaw static site builder, i wrote this simple script to copy the production version of the site to another directory and deploy it to the github pages site.

#!/bin/bash -e

echo "Deploying build_production to"
echo "---------"

cd build_production 
cp -r * /var/www/

cd /var/www/

git add .
git commit -m "update"
git push

echo 'finished'


echo "This a bash script to run composer clear the caches)"
echo "--------------"
php -v
#echo "--------------"

cd /var/www/laravel

php artisan down

composer dump-autoload -o

php artisan view:clear
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan clear-compiled
php artisan config:cache
php artisan optimize

php artisan up

If you would like to contact me you can either use this form on or via Twitter @andylondon