Last updated August 21, 2010. Created by kuschelhummer on August 18, 2010.
Log in to edit this page.
Bash scripts do an excellent job of making life easier in linux envrionments.
I use this one to make backups of my development site:
archive_instance
#!/bin/bash
#### Script for putting drupal instance source and database content in one file
#### it follows the convention that direcotry name and database name match
#### eg. if you have drupal instance under sandbox the database name is sandbox, tooo
E_BADARGS=65
E_NOT_DIREXISTS=99
EXPECTED_ARGS=1
#### apply your settings here
BACKUPPATH=/var/archived_versions/
WWW_ROOT=/var/www/
MYSQLUSER=root
MYSQLPASSWORD=mypass
if [ $# -ne $EXPECTED_ARGS ]
then
echo "This script will backup your site and database into one zip, stored in $BACCKUPPATH"
echo "Usage: $0 sitedir "
echo ":eg $0 sandbox for $WWW_ROOTsandbox and mysqldatabase sandbox"
exit $E_BADARGS
fi
SOURCEDIR=$WWW_ROOT$1
echo $SOURCEDIR
# bash check if directory exists
if [ ! -d $SOURCEDIR ]; then
echo "SOURCE Directory $SOURCEDIR does not exist, please check params"
exit $E_NOT_DIREXISTS
fi
OF=${BACKUPPATH}${1}archive_$(date +%Y_%m_%d_%T).zip
DUMP=${BACKUPPATH}dump_${1}_$(date +%Y%m%d).txt
echo $OF
zip -ru $OF $SOURCEDIR
mysqldump --user=$MYSQLUSER --password=$MYSQLPASSWORD $1 > $DUMP
zip -u $OF $DUMP
rm $DUMP