2 changed files with 22 additions and 8 deletions
@ -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 |
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue