This is a simple script that I wrote to backup my local databases. It uses terminal-notifier to create OS notifications and time_difference to report how much time it takes to execute a backup.
- Install the required gems:
gem install time_difference terminal-notifier
- Adjust the relevant variables:
databases
,path
- The connection variables are set in the
.my.cnf
file. I don't want your MySQL password in the script.- Create the following
.my.cnf
file in your home directory. The correct permission for this file is 600:
- Create the following
[client]
host=127.0.0.1
user=yourmysqluser
password=yourpassword
- Run the script:
ruby backup.rb
Extra tip: you should create an user with only select privilegies to execute this backup script