Created
December 28, 2012 15:34
-
-
Save anonymous/4398903 to your computer and use it in GitHub Desktop.
Backup a Drupal site's database using drush, minus disposable data.
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
#!/bin/bash | |
# Check for the existance of drush on the system | |
if [[ ! -x /bin/drush || ! -x /usr/bin/drush ]]; then | |
echo "This script requires drush!" | |
echo | |
exit 3 | |
fi | |
if [[ -z ${1} ]]; then | |
echo "Must specify destination directory for backup tarball" | |
echo | |
echo "Directory can be a complete path, or a relative path" | |
echo "Ex: backup-site ~/backupdir" | |
echo | |
echo "Enjoy!" | |
echo | |
echo | |
exit 2 | |
fi | |
# Setup the backup prefix | |
BACKUP_PREFIX=${1}/$(hostname) | |
# get the date | |
DATE=`date +%Y%m%d` | |
# Dump the Drupal DB structure only | |
echo "Dumping database and compressing . . ." | |
drush sql-dump | grep -Ev "^INSERT.*(cache_.*|flood|search_.*|semaphore|sessions).*$" | bzip2 > ${BACKUP_PREFIX}-${DATE}.sql.bz2 | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment