#!/bin/bash #Backs up a site (database & directory) and gzips it up with a formatted name. #Database config DBUSER='db_username' DBPASS='db_password' DBNAME='db_name' #Do not edit below if [ -n "$1" ]; then #Set up variables FILE=$1 CDATE=`date +%d%m%Y` OUTFILE=$FILE.$CDATE.tgz OUTDBFILE=$FILE.$CDATE.db.sql cd $HOME echo 'Dumping database...' `mysqldump -u $DBUSER --password=$DBPASS $DBNAME>./$FILE/$OUTDBFILE` echo 'Tar/GZipping it up...' `tar zcf $OUTFILE ./$FILE` rm ./$FILE/$OUTDBFILE echo 'Done!' else #Fail echo "Usage: $0 <target dir>"; fi