#!/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 [ $# -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 cd "$link" # pwd filename=$(basename "$link") ../../../vendor/bin/drush sql-dump --result-file=/var/www/backups/db-dump-"$filename"-$(date +%F).sql cd "$1" done exit