Last active
March 24, 2022 15:56
-
-
Save bonesoul/6932759 to your computer and use it in GitHub Desktop.
MySQL Database to Git Backup Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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