Asked 6 years ago
2 Feb 2018
Views 1336
jaggy

jaggy posted

how to export database at mysql with PHP daily ?

i found a situation where i lost database

so i learn lesson that we should always daily backup so i am writing php program but i don't know where to start

so any one can help me to backup database daily at my server
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00


we are running mysql command by php and getting result a file name with "db_backup_2_2_2018.sql"


$result=exec('mysqldump dbname --password=password --user=username --single-transaction >/home/public_html/backup/'.'db_backup_'.date('m_d_y').'.sql',$output);



if you have mysql root acess you can direct run this in command prompt as well

mysqldump dbname --password=password --user=username --single-transaction >/home/public_html/backup/db_backup.sql


hope it work
Post Answer