How to auto-dump in Mysql?

Asked

Viewed 423 times

-1

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

I wanted to know a way to do the dump Mysql database automatically at the same time every day (for example: late afternoon) using PHP or other suggestion.

  • See if this can help you https://sourceforge.net/projects/automysqlbackup/ or this https://www.noupe.com/development/10-ways-to-automatically-manually-backup-mysql-database.html

1 answer

0

Hello.

First of all, it will depend on the environment the database is in. If it is in a Windows, you can program a . bat and schedule its execution 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 its execution on crontab. Both the Windows Scheduler and 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 that’s up to you :)

Remembering that for both systems, Mysql has tools to dump.

Now leaving aside the issue of the script and the S.O., an important fact is that you should think very carefully about how you will develop this code. A cool example is you program two or three daily dumps, with "strategic" times, for example, one at the beginning of the day, another at noon and the last 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) the copies of every day of the week, erasing them only in the exchange of the week.

Finally, I see that despite the copies, something very important is to keep these copies replicated in another medium, be it an external hard drive, a network machine or an FTP server. Another fact, is to program a routine to validate if the copies are intact, and of course, to check if they are running, or if the file is being created (in linux may happen some problems with folder permission).

This is a subject that can yield much, little or no work, all depends on your concern with the security of your customer data! Start with something small, but always try to pay attention to it. Backup is only remembered when we need it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.