MySQL Backup Cron Script

Do you have a MySQL server that needs a basic backup mechanism with compression and retention? Try this script on for size and see if it fits your needs. Create the backup script: nano Add the following in to the script: #!/bin/bash # Variables, adjust as necessary date=$(date +%Y-%m-%d) dest=”/var/backup” ret=”5″ # retention in number of days pass=”password” # mysql root password # Workin’ section find $dest -type f -mtime +$ret -exec rm {} ; mysqldump -uroot -p$pass –all-databases |gzip -9 > $dest/backup_db_$date.sql.gz exit 0 Adjust any of the variables for your own environment, particularly the $pass variable Make … Continue reading MySQL Backup Cron Script