Last Updated: February 25, 2016
·
1.717K
· austinginder

MediaTemple (dv) backup using Dropbox

On my server I have the follow file to backup my databases locally:

/var/www/vhosts/backup/backupdatabases.sh

#!/bin/sh

# The destination directory to backup the files to
destdir=/var/www/vhosts/_backup

# The MySQL database hostname
dbhost=localhost

# The MySQL database username - requires read access to databases
dbuser={database_username}

# The MySQL database password
dbpassword={database_password}

echo `date` ": Beginning backup process..." > $destdir/backup.log 

# remove old backups
rm $destdir/*.tar.gz

# backup databases
for dbname in `echo 'show databases;' | /usr/bin/mysql -h $dbhost -u$dbuser -p$dbpassword`
do
if [ $dbname != "Database" ];
then
echo `date` ": Backing up database $dbname..." >> $destdir/backup.log
/usr/bin/mysqldump --opt -h $dbhost -u$dbuser -p$dbpassword $dbname > $destdir/$dbname.sql
tar -czf $destdir/$dbname.sql.tar.gz $destdir/$dbname.sql
rm $destdir/$dbname.sql
fi
done

mail -s "Backup Complete" {email_address} < $destdir/backup.log

Here is what the cron job looks like in Plesk.

Picture

The rest of my backup I run from my local development machine. On my machine I'm using a paid version of <a href="http://db.tt/zGs2ic0">Dropbox</a> with the Packrat (unlimited undo history). The Packrat feature is what allows me to restore back in time to a particular date. Here is the file I'm using:

~/Dropbox/AnchorDevDevelopment/backup/backup-{servername}.command

#!/bin/bash
rsync --progress --force --delete --exclude 'fs' -azve ssh {username}@{hostname}:/var/www/vhosts ~/Dropbox/Backup/AnchorDev/{servername}/

Here is what my crontab looks like in CronniX on my local machine

Picture