Backing up all your MySQL databases one by one is a pain. Here is a small bash script I made to dump and compress all my databases to my Dropbox folder.
- The script will skip any database whose name starts with an underscore, so I can have test or junk databases that I don’t want to back up.
- Every time it runs, it’ll delete all the previous backups (I don’t care, but if you do then just comment out line 7)
- You need to change lines 3, 4 and 5 to reflect your MySQL user, password and folder where you want to put the dumps.
Now you just need to make it executable:
And then add it to the crontab so it’ll run automagically:
In this case it’ll run every day at 8 PM.