Super easey script to make security copies of DB. This verision is inspired by this article.
The script will delete all the back-ups after 30 days.
- Clone repo
- Create a MySQL user with only read permissions over the data base you want to backup
- Add the DB info to your script
- Execute permissions to your sciprt:
sudo chmod +x backup_script.sh
- Test with
sh backup_script.sh
- Add the CRON Job to your user
- Create a backup account:
create user 'backup'@'localhost' IDENTIFIED BY password 'password';
- Grant permissions to the database you want to copyp:
GRANT LOCK TABLES, SELECT, SHOW VIEW, EVENT ON database.* TO 'backup'@'localhost';