Last active
August 29, 2015 14:13
-
-
Save esolitos/6d10d8532ad6678fa29d to your computer and use it in GitHub Desktop.
SQL Dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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