How to do automatic dump in MySQL?

-1

I have a simple system for managing a store that for now, in the testing phase, is running with a local server.

I wanted to know a way to do the dump of the MySQL database automatically at the same time every day (eg late afternoon) using PHP or another suggestion.

    
asked by anonymous 23.11.2017 / 22:45

1 answer

0

Hello.

First, it will depend on the environment in which the database is. If it is in a Windows, you can schedule a .bat and schedule it to run in the Task Scheduler. So you can determine what times it will run. And if it is on Linux, the output is to create a script and schedule it to run in crontab. Both the Windows Scheduler and the Linux Crontab basically have the same functionality. If your intention is to use a language, python is very interesting and can suit you very well. But this is at your discretion:)

Remembering that for both systems, MySQL has tools to perform the dump.

Now leaving aside the issue of script and SO, one important fact is that you should think hard about how you will develop this code. A good example is that you schedule two or three daily dumps, with "strategic" times, for example one at the beginning of the day, another at noon, and the last one at the end of the day. In addition, it is important to keep these copies for a certain time. Ex: (i) save the last copy of the month of every month, (ii) the last copy of the week, and (iii) copies of all days of the week, deleting them only for the week.

Finally, I see that despite the copies, something very important is to keep those copies replicated to another medium, be it an external hard drive, a network machine or an FTP server. Another thing is to program a routine to validate if the copies are intact, besides of course, to verify if they are being executed, or if the file is being created (in linux some problems can happen with permission of folders). >

This is a subject that can yield a lot, little or no work, it all depends on your concern for your client's data security! Start with something small, but always try to pay attention to this subject. Backup is only remembered when we need it.

    
23.11.2017 / 23:23