Created
November 20, 2010 05:39
-
-
Save dtseiler/707648 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| DATESTAMP=`date +%Y%m%d` | |
| SITESFILE=${HOME}/.drupalsites | |
| # SITESFILE contents are in the following format: | |
| # SITENAME:DBNAME:DBUSER:DBPASSWD | |
| DRUPALDIR=/path/to/drupal | |
| BACKUPDIR=${HOME}/backups/${DATESTAMP} | |
| mkdir -p ${BACKUPDIR} | |
| # Backup the drupal codebase | |
| echo -n "Backing up ${DRUPALDIR} ... " | |
| cd ${DRUPALDIR}/../ | |
| tar -cjpf ${BACKUPDIR}/drupal_${DATESTAMP}.tar.bz2 drupal | |
| echo "Done." | |
| cd ${BACKUPDIR} | |
| # Backup MySQL Databases | |
| cat $SITESFILE | while read line; do | |
| #echo $line | |
| line=(${line//:/ }) | |
| echo -n "Backing up MySQL db ${line[1]} ... " | |
| DUMPFILE=${line[0]}_${DATESTAMP}.sql | |
| mysqldump -u ${line[2]} -p${line[3]} ${line[1]} > ${DUMPFILE} | |
| gzip ${DUMPFILE} | |
| echo "Done." | |
| done | |
| echo "Backup completed, all files are in ${BACKUPDIR}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment