Skip to content

Instantly share code, notes, and snippets.

@cubuspl42
Created December 11, 2023 10:11
Show Gist options
  • Select an option

  • Save cubuspl42/cb8da9963c542b3ea31d34c5a9fdaa16 to your computer and use it in GitHub Desktop.

Select an option

Save cubuspl42/cb8da9963c542b3ea31d34c5a9fdaa16 to your computer and use it in GitHub Desktop.

Revisions

  1. cubuspl42 created this gist Dec 11, 2023.
    17 changes: 17 additions & 0 deletions prestashop_backup_site.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/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