Skip to content

Instantly share code, notes, and snippets.

@jak119
Created December 31, 2014 20:39
Show Gist options
  • Save jak119/154d585c92bd24f74031 to your computer and use it in GitHub Desktop.
Save jak119/154d585c92bd24f74031 to your computer and use it in GitHub Desktop.
Backup MySQL Databases to File
#!/bin/bash
#@author Jamison Kissh
#Schedule the job to run via a cron job
#edit line below to include password after -p
mysqldump -u root -p --all-databases | gzip > ./database`date +%F_%T`.sql.gz
#Remove backups older than five days
find ./database* -mtime +5 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment