Created
September 4, 2010 19:44
-
-
Save vixh/565435 to your computer and use it in GitHub Desktop.
Dump drupal content files and DB
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 | |
# Dump Drupal content(files, sites) and MySQL database | |
HOST_PATH='/var/www/vhosts/'; | |
if [ $1 != '' ] ; then | |
cd $HOST_PATH$1/httpdocs | |
fi | |
DUMP_DIRS='' | |
if [ -d 'files' ]; then | |
DUMP_DIRS=' files/' | |
fi | |
if [ -d 'sites' ]; then | |
DUMP_DIRS=' sites/' | |
fi | |
if [ $DUMP_DIRS != '' ]; then | |
echo 'Start taring files and sites directories. Please wait, can take several minutes.'; | |
tar -c --file=../files_sites.tar -g ../files_sites.snar $DUMP_DIRS | |
fi | |
# EXAMPLE $db_url = 'mysql://meslunettes:65nlikeh@localhost/velli_meslunettes'; | |
DBN=`cat sites/default/settings.php |grep -e '^$db_url'`; | |
USER=`echo $DBN | sed "s/.*:\/\/\(.*\):.*/\1/"`; | |
PASS=`echo $DBN | sed "s/.*:\(.*\)@.*/\1/"`; | |
HOST=`echo $DBN | sed "s/.*@\(.*\)\/.*/\1/"`; | |
DB_NAME=`echo $DBN | sed "s/.*\/\(.*\)';/\1/"`; | |
echo 'Start mysqldumping. Please wait, can take several minutes.'; | |
mysqldump -u $USER --password=$PASS --host=$HOST $DB_NAME > ../$DB_NAME.mysql | |
echo 'Done.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment