Programmatically backing up (and sending by email) the full MySQL database via PHP

I need to back up my MySQL database daily and preferably send it by email to the email address of my choice.

Can this be done? What is SQL to create a backup file? How can I add this file as an โ€œattachmentโ€ to the sent message?

Thanks for the help, I really need to make these backups!

I know how to call a script via cronjob, so the daily thing is not a problem.

+3
source share
4 answers

mysql_dump :

mysqldump <DB name> -u<user> -p<password> | gzip -c > /backup/`date +%Y-%m-%d`.sql.gz

mail ( , ).

+10

exec, mysqldump , .

 mysqldump -u username -p password databaseName > databaseFile.sql

PHP .

, , , , .

Tom Tom, PHP Zlib GZIP " " zip PHP.

+3
+2

MySQL   =====================   http://restkultur.ch/personal/wolf/scripts/db_backup

, , .. ( , , - FTP ).

0
source

Source: https://habr.com/ru/post/1731234/


All Articles