#!/bin/sh
HOST='YOURBACKUPSERVER'
USER='USERNAME'
PASSWD='PASSWORD'
DATE=`date +%Y%m%d`
TMP_DIR=/tmp
IGNORE_FILE=/tmp/ignorefiles.txt
FILE_DB=rocket_db_$DATE.sql
FILE_WWW=rocket_www_$DATE.tar.gz
DOMAIN=/var/www/vhosts/rockettheme.com
DB_USER='DBUSER'
DB_PASSWORD='DBPASSWORD'
# mysql db
echo 'dumping mysql databases....'
mysqldump --opt -u $DB_USER -p$DB_PASSWORD --all-databases > $TMP_DIR/$FILE_DB
cd $TMP_DIR
tar czf $FILE_DB.tar.gz $FILE_DB
rm $FILE_DB
#file system
echo 'dumping rocket directory...'
cd $DOMAIN
find . -type d -name 'logs' > $IGNORE_FILE
find . -type d -name '*cache*' >> $IGNORE_FILE
tar -czf $TMP_DIR/$FILE_WWW ./* --exclude=./statistics/logs/* --exclude=*cache/* --exclude=*tmp/* --exclude=./download/*
cd $TMP_DIR
ftp -n $HOST <<END_SCRIPT
quote USER $USER
Time to create page: 0.062 seconds