Skip to content

Instantly share code, notes, and snippets.

@bvogel
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save bvogel/4d96dbaab859a33bd157 to your computer and use it in GitHub Desktop.

Select an option

Save bvogel/4d96dbaab859a33bd157 to your computer and use it in GitHub Desktop.
/usr/local/cron/backup_buddy_production_db.sh
#!/bin/sh
date_today=`date +%Y-%m-%d`
year_month_today=`date +%Y-%m`
ssh rails-deploy@buddy.buddyandselly.com "mysqldump -h 93.92.128.20 -u xxx -pxxx buddy_production | bzip2 -c > buddy/backups/buddy.dump.$date_today.sql.bz2"
if [ ! -d "/share/ReRe-Server/IT/Buddy_Development/Database-Backup/$year_month_today" ]; then
mkdir /share/ReRe-Server/IT/Buddy_Development/Database-Backup/$year_month_today
chown admin.everyone /share/ReRe-Server/IT/Buddy_Development/Database-Backup/$year_month_today
chmod 770 /share/ReRe-Server/IT/Buddy_Development/Database-Backup/$year_month_today
fi
scp rails-deploy@buddy.buddyandselly.com:~/buddy/backups/buddy.dump.$date_today.sql.bz2 /share/ReRe-Server/IT/Buddy_Development/Database-Backup/$year_month_today/
ssh rails-deploy@buddy.buddyandselly.com "rm buddy/backups/buddy.dump.$date_today.sql.bz2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment