Created
December 11, 2023 10:11
-
-
Save cubuspl42/cb8da9963c542b3ea31d34c5a9fdaa16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ex | |
[ -n "$1" ] || exit 1 | |
cd /var/www | |
SHOP_NAME=$1 | |
DB_CREDENTIALS=$( | |
php <<PHP | |
<?php | |
require '$SHOP_NAME/config/settings.inc.php'; | |
print(_DB_USER_ . ' ' . _DB_PASSWD_ . ' ' . _DB_NAME_ . PHP_EOL); | |
?> | |
PHP | |
) | |
read DB_USER DB_PASSWD DB_NAME <<< $DB_CREDENTIALS | |
mysqldump -u $DB_USER -p$DB_PASSWD $DB_NAME > $SHOP_NAME/$DB_NAME.sql | |
7z -xr!backup -xr!backups -xr!cache a "$HOME/backup/$SHOP_NAME-backup-$(date +%F-%T).7z" $(realpath "$SHOP_NAME") | |
rm $SHOP_NAME/$DB_NAME.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment