06.7
10

Automated backup of MySQL databases

by admin ·

If there’s two things to do with a computer or a server backup and automation. And of course, as the two combine to automate backups.

The SQL database backup is no exception to this rule, whether on a personal PC or a server, it is always important to make backups and since we did not necessarily want to connect to each phpmyadmin time to do (it would be done once in me this way: ) here’s a little trick very easy to implement.


If like me, you like many separate databases, creating a specific user for a given application to reduce the use of user root on the bases the following little script should make your case. It also allows you to get the backups in different files for each user. The syntax is very simple without need of explanation.

# / Bin / sh
mysqldump-uwordpress-pmonpass – all-databases> backup.wp.sql
mysqldump-uforum-pmonpassquitu – all-databases> forum_back.sql

In other words, a breeze!
With of course an argument:

  • -U user database to save.
  • -P: pass corresponding to the user.

You have to make executable script and restrict access as any sensitive files with a chmod 700.

To automate the whole a little cron (simple with the execution frequency of course) and again not need more explanation to do but tutorials are readily available over there.
Script could be improved by rotating logs on several days because there it is automatically deleted.

Tags: , , ,

Leave a Reply