From db7df2f42812700472bfca535d0f54d653031c54 Mon Sep 17 00:00:00 2001 From: ppound Date: Thu, 3 Apr 2025 11:26:44 -0300 Subject: [PATCH] added messaging and switched from symlinks to actual directories --- multisite-db-dump.bash | 16 +++++++++++----- multisite-drush-command.bash | 14 +++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/multisite-db-dump.bash b/multisite-db-dump.bash index 2ae3280..632fbd8 100755 --- a/multisite-db-dump.bash +++ b/multisite-db-dump.bash @@ -1,18 +1,24 @@ #!/usr/bin/env bash # usage ./mulitsite-db-dump.bash path_to_sites_directory # path_to_sites_directory is the full path drupals sites directory (something like /var/www/drupal/web/sites) -# This script will get the symlinks in the sites directory cd into the symlink directory and run drush sql-dump -# for this to work we need sites to be symlinked and no file symlinks is the site directory +# This script will get the directories in the sites directory and cd into the directory and run drush sql-dump +#switched to actual directories instead of symlinks as we have multiple symlinks for some production directories +#excludes the all and the current directory (.). [ $# -ne 1 ] && { echo "Usage: $0 path_to_site_directory"; exit 1; } cd "$1" pwd -list="$(find ./ -maxdepth 1 -type l)" -for link in $list ; do +list="$(find ./ -maxdepth 1 -type d)" +for link in $list ; do + if [ "$(basename "$link")" != "all" ] && [ "$(basename "$link")" != "." ] ; then cd "$link" -# pwd filename=$(basename "$link") + echo "backing up database for site: $filename" ../../../vendor/bin/drush sql-dump --result-file=/var/www/backups/db-dump-"$filename"-$(date +%F).sql + if [ $? -ne 0 ]; then + echo "Error: Drush command failed for site: $site_name" + fi cd "$1" + fi done exit diff --git a/multisite-drush-command.bash b/multisite-drush-command.bash index c9e08c3..13f172e 100755 --- a/multisite-drush-command.bash +++ b/multisite-drush-command.bash @@ -2,14 +2,22 @@ # usage ./mulitsite-drush-command.bash path_to_sites_directory command # path_to_sites_directory is the full path drupals sites directory (something like /var/www/drupal/web/sites) # and command is a drush command -[ $# -ne 0 ] && { echo "Usage: $0 path_to_sites_directory drush_command"; exit 1; } +#switched to actual directories instead of symlinks as we have multiple symlinks for some production directories +#excludes the all and the current directory (.). +[ $# -ne 2 ] && { echo "Usage: $0 path_to_sites_directory drush_command"; exit 1; } cd "$1" pwd -list="$(find ./ -maxdepth 1 -type l)" +list="$(find ./ -maxdepth 1 -type d)" for link in $list ; do + if [ "$(basename "$link")" != "all" ] && [ "$(basename "$link")" != "." ] ; then cd "$link" - pwd + #pwd + echo "Executing Drush command '$2' for site: $link" ../../../vendor/bin/drush "$2" --yes + if [ $? -ne 0 ]; then + echo "Error: Drush command failed for site: $site_name" + fi cd "$1" + fi done exit