Browse Source

added messaging and switched from symlinks to actual directories

main
ppound 8 months ago
parent
commit
db7df2f428
  1. 16
      multisite-db-dump.bash
  2. 14
      multisite-drush-command.bash

16
multisite-db-dump.bash

@ -1,18 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# usage ./mulitsite-db-dump.bash path_to_sites_directory # 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) # 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 # This script will get the directories in the sites directory and cd into the directory and run drush sql-dump
# for this to work we need sites to be symlinked and no file symlinks is the site directory #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; } [ $# -ne 1 ] && { echo "Usage: $0 path_to_site_directory"; exit 1; }
cd "$1" cd "$1"
pwd pwd
list="$(find ./ -maxdepth 1 -type l)" list="$(find ./ -maxdepth 1 -type d)"
for link in $list ; do for link in $list ; do
if [ "$(basename "$link")" != "all" ] && [ "$(basename "$link")" != "." ] ; then
cd "$link" cd "$link"
# pwd
filename=$(basename "$link") 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 ../../../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" cd "$1"
fi
done done
exit exit

14
multisite-drush-command.bash

@ -2,14 +2,22 @@
# usage ./mulitsite-drush-command.bash path_to_sites_directory command # 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) # path_to_sites_directory is the full path drupals sites directory (something like /var/www/drupal/web/sites)
# and command is a drush command # 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" cd "$1"
pwd pwd
list="$(find ./ -maxdepth 1 -type l)" list="$(find ./ -maxdepth 1 -type d)"
for link in $list ; do for link in $list ; do
if [ "$(basename "$link")" != "all" ] && [ "$(basename "$link")" != "." ] ; then
cd "$link" cd "$link"
pwd #pwd
echo "Executing Drush command '$2' for site: $link"
../../../vendor/bin/drush "$2" --yes ../../../vendor/bin/drush "$2" --yes
if [ $? -ne 0 ]; then
echo "Error: Drush command failed for site: $site_name"
fi
cd "$1" cd "$1"
fi
done done
exit exit

Loading…
Cancel
Save