#!/bin/bash
TIMESTAMP=`date +%m.%d.%y_%H-%M-%S`

# delete backups over 7 days old 
find /home/USER/ -mtime +7 -exec rm -f {} \;

# create new backup on the server
mysqldump  --single-transaction  --quick -u USER -pPASSWORD DATABASE | gzip -9 > "/home/USER/mysqlbackups/mysql_backup-$TIMESTAMP.sql.gz"

# move backup to another machine
scp /home/USER/mysqlbackups/mysql_backup-$TIMESTAMP.sql.gz [email protected]/home/USER/mysqlbackups/