Using cron, schedule automated MySQL database backups to git
I like this approach because I don't have to cleanup or version files on my system
One caveat: if you're using github or bitbucket, this approach is probably only appropriate for databases < 50mb
- Create repo on github or bitbucket
cd /dir/outside/webroot
git clone [email protected]:user/new_repo.git
export BACKUP_DIR=/dir/outside/webroot/new_repo
- Define environment variables for DB_USER, DB_PW, DB_NAME
- Save file and add to crontab
chmod 600 git-db-backup.sh