Mysql Backup with PHP
Database is one of the most important thing in building a website. Therefore, making database backup is also very important. Database backup will avoid loss if there is a crash in our database.
In this article I will try to share a method that i use to make Mysql Backup with PHP. The frist thing that we need to do is making the code it self.
The php code:
$current = date("Y-m-d_H-i-s"); $host = "";//fill it with host name $user = "";//fill it with user name $pass = "";//fill it with password $database = "";//fill it with database name exec("mysqldump --opt --host=$host --user=$user --password=$pass $database | gzip --best > $database_$current.sql.gz");
That is it, the code will automatically make a backup with extention .sql.gz and save it with the same directory with your code.
You can combine this code with Attachment Email with PHP
Cogratulation you just learn how to make Mysql Backup with PHP.