Skip to content

Instantly share code, notes, and snippets.

@codeprimate
Created May 6, 2009 16:43
Show Gist options
  • Save codeprimate/107596 to your computer and use it in GitHub Desktop.
Save codeprimate/107596 to your computer and use it in GitHub Desktop.
#!/bin/bash
# /home/username/bin/backup_db.sh
# MySQL Backup
DATE=`date "+%y%m%d"`
BACKUP_DEST="/home/username/site/production/current/db"
DB="database_name"
DB_USER="db_user"
DB_USER_PW="db_password"
DB_BACK=$BACKUP_DEST/$DATE-db.sql.gz
/usr/bin/mysqldump --password=$DB_USER_PW -Ke -u $DB_USER $DB | gzip > $DB_BACK
#### END
#!/bin/bash
# /home/username/bin/backup_production_site.sh
# Client backup script
SOURCEPATH='/home/remote_username/site/production/current'
DESTPATH='/home/local_username/backups/production_site_backup'
SOURCEHOST='production.host'
SOURCEUSER='remote_username'
LOGFILE='/home/local_username/backups/rsync.log'
echo
echo " * Running MySQLDump on $SOURCEHOST..."
ssh $SOURCEUSER@$SOURCEHOST '/home/remote_username/bin/backup_db.sh'
echo " * Syncing Local Backup..."
echo >> $LOGFILE
rsync -av -e ssh $SOURCEUSER@$SOURCEHOST:$SOURCEPATH $DESTPATH
echo "Completed at: `/bin/date`" >> $LOGFILE
echo "Done."
#### END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment