Skip to content

Instantly share code, notes, and snippets.

@esolitos
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esolitos/6d10d8532ad6678fa29d to your computer and use it in GitHub Desktop.
Save esolitos/6d10d8532ad6678fa29d to your computer and use it in GitHub Desktop.
SQL Dump
# While inside a drupal site directory creates a SQL backup with the name of the site's directory and the current date.
drush sql-dump | gzip > ~/SQL-Backup/${PWD##*/}.$(date +%y%m%d).gz
# More advanced example:
# From the `drupal/sites` directory do a SQL backup of all the sites available
for dir in $(ls | egrep -v 'all|default'); do
if [ -d $dir ]; then
cd $dir
echo "Backup of site: $dir"
drush sql-dump | gzip > ~/SQL/${pwd##/}.$(date +%Y-%m-%d).gz
cd ..
fi
done
# ..or in one line:
for dir in $(ls | egrep -v 'all|default'); do if [ -d $dir ]; then cd $dir; echo "Backup of site: $dir"; drush sql-dump | gzip > ~/SQL/${pwd##/}.$(date +%Y-%m-%d).gz; cd ..; fi; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment