Skip to content

Instantly share code, notes, and snippets.

@cubuspl42
Created December 11, 2023 10:11
Show Gist options
  • Save cubuspl42/cb8da9963c542b3ea31d34c5a9fdaa16 to your computer and use it in GitHub Desktop.
Save cubuspl42/cb8da9963c542b3ea31d34c5a9fdaa16 to your computer and use it in GitHub Desktop.
#!/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