Am new to linux cron job, i am using mysql DB, my database name finaldb, i want to take this database every one hour,
I have folder called dailbackup, in this i have folder by date wise,in this each folder i have backup mysql db file
name like final_db_9.sql (this backup taken at morning 9 am), final_db_13.sql(this backup taken at noon 1pm, like that ,
this process at present am doing manually , is it possible to make it automation , any ideas, suggestions ,
Create a PHP Script containing the following:
$dbFile = 'final_db'.date('H').'.sql.gz';
$dbHost = 'localhost'; // Database Host
$dbUser = 'username'; // Database Username
$dbPass = 'password'; // Database Password
exec( 'mysqldump --host="'.$dbHost.'" --user="'.$dbUser.'" --password="'.$dbPass.'" --add-drop-table "finaldb" | gzip > "'.$dbFile.'"' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With