Drupal Backup & Update Shell Script (Multiple Users / Sites on Linux)

drush.ini

safe_mode =
open_basedir =
max_execution_time = 3600
max_file_uploads = 20
max_input_time = 3600
memory_limit = 8G

 

drupal_backup_update.sh

#!/bin/bash
array=( myuser1 otheruser2 user3 user4 )
for i in "${array[@]}"
do
drush='php -c ~/httpdocs/drush.ini ~/httpdocs/vendor/drush/drush/drush'

if [[ $1 == status ]]; then
su  "$i" <<EOF
cd && cd httpdocs
echo " --------------------- STATUS -------------------"
${drush} status
${drush} pm:security
composer update --dry-run
EOF
fi





if [[ $1 == backup ]]; then
 su  "$i" <<EOF
cd && cd httpdocs
echo " --------------------- BACKUP -------------------"
${drush} sql:dump  | gzip -c > ../backup/db-$(date +%Y-%m-%d-%H%M).sql.gz && tar -zcf ../backup/web-$(date +%Y-%m-%d-%H%M).tar.gz ../httpdocs/
ls -lah ../backup | grep $(date +%Y-%m-%d)
EOF
fi






if [[ $2 == update ]]; then

su  "$i" <<EOF
cd && cd httpdocs
echo " --------------------- UPDATE -------------------"
composer update
${drush} updb -y
${drush} webform:libraries:download
${drush} cr
EOF

fi

run:

/path/to/drupal_backup_update.sh backup update

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare

  • 1 week ago
    Transaction isolation level REPEATABLE-READ The recommended level for Drupal is "READ COMMITTED". (Drupal Status Report)

     Edit "/etc/my.cnf" ( under [mysqld] ):

    transaction_isolation="READ-COMMITTED"

    Restart MariaDB / MySQL:

  • 2 weeks 2 days ago
    Wget - Eine Webseite rekursive downloaden

    wget -U 'Mozilla/MyUserAgent' -P MyTempDir123 --wait=0.2 --random-wait -nd -r -x -l 4 -e robots=off --reject

  • 2 weeks 2 days ago
    Wget - Eine Webseite rekursive downloaden

    wget -U 'Mozilla/MyUserAgent2024' -P MyOutPutDirectory --wait=1 --random-wait -nd -r -l 2 -e robots=off --reject

  • 1 month 2 weeks ago
    CPU benchmarking with sysbench (single-threaded/all cores)

     

    # sysbench --threads="$(nproc)" cpu run

  • 1 month 2 weeks ago
    CPU benchmarking with sysbench (single-threaded/all cores)

    # sysbench --threads="$(nproc)" cpu run

  • 1 month 2 weeks ago
    Linux Autovervollständigung - bash autocomplete
    source ~/.bashrc

    Diese Lösung wird empfohlen aber hat bei mir nicht funktioniert.

    Welche Alternative gibt es?

  • 1 month 2 weeks ago
    PHP-CLI auf PHP8.2 umstellen (für Composer, Drush etc)

    ln -snf /opt/plesk/php/8.3/bin/php /etc/alternatives/php

  • 1 month 3 weeks ago
    Drush Update failed (require php >=8.2)

    In composer.json, update: 

     

  • 1 month 3 weeks ago
    Drupal: Anmeldung fehlgeschlagen Es hat mehr als 5 fehlerhafte Anmeldeversuche für dieses Benutzerkonto gegeben. Es ist vorübergehend gesperrt.
    drush sqlq "DELETE FROM flood"
  • 1 month 3 weeks ago
    Drupal SMTP + Gmail funktioniert nicht mehr (Passwort ist richtig); was ist die Lösung?