Skip to content

Instantly share code, notes, and snippets.

@bonesoul
Last active March 24, 2022 15:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bonesoul/6932759 to your computer and use it in GitHub Desktop.
Save bonesoul/6932759 to your computer and use it in GitHub Desktop.
MySQL Database to Git Backup Script
#!/bin/sh
cd /var/www/YOURSITE.ORG
date=`date +"%b-%d-%y-%H-%M-%S"`
mysqldump -h SERVER_IP -u root -pPASSWORD --skip-extended-insert --skip-dump-date --databases DBNAME > db-backups/YOURSITE.ORG.sql
git add -A
git commit -m "Site backups for $date"
git push
git gc
# m h dom mon dow command
1 0 * * * sh /var/www/YOURSITE.org/backup.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment