#!/bin/bash input=".env" while IFS= read -r line do if [ "APP_ENV" == "${line%=*}" ]; then env="${line##*=}" fi if [ "DB_DATABASE" == "${line%=*}" ]; then database="${line##*=}" fi if [ "DB_USERNAME" == "${line%=*}" ]; then user="${line##*=}" fi if [ "DB_PASSWORD" == "${line%=*}" ]; then pass="${line##*=}" fi done < "$input" year=$(date +"%Y") month=$(date +"%m") day=$(date +"%d") hour=$(date +"%H") minutes=$(date +"%M") mysqldump --user="$user" --password="$pass" -B "$database" > storage/logs/database/save-$database-$year$month$day-$hour$minutes.sql if [ "production" == "$env" ]; then echo "en production" git pull origin production composer install php artisan migrate --force php artisan optimize npm install npm run prod fi