Skip to content

Instantly share code, notes, and snippets.

@ip413
Created June 27, 2018 20:30
Show Gist options
  • Save ip413/430a9025e1afbb857c491950a791f926 to your computer and use it in GitHub Desktop.
Save ip413/430a9025e1afbb857c491950a791f926 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script reads configuration values from Prestashop settings,
# and makes database dump into default prestashop backup folder (adminXYZ1234/backups).
function get_parameter_value() {
echo $(cat $PARAMETERS | grep $1 | awk '{print $3}' | sed -e "s/[',]//g")
}
PARAMETERS=../public_html/app/config/parameters.php
DB_NAME=$(get_parameter_value database_name)
DB_USER=$(get_parameter_value database_user)
DB_PASSWORD=$(get_parameter_value database_password)
OUTPUT_PATH=../public_html/$(ls ../public_html/ | grep "^admin")/backups/
mysqldump --user=$DB_USER --password=$DB_PASSWORD --host=localhost --default-character-set=utf8 "$DB_NAME" > db_backup.sql
OUTPUT_FILENAME=$(date +%s)-$(md5sum db_backup.sql | cut -c -8).sql.gz
gzip -c db_backup.sql > $OUTPUT_PATH/$OUTPUT_FILENAME
rm db_backup.sql
ls $OUTPUT_PATH/$OUTPUT_FILENAME;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment