I am attempting to dump a portion of my table after 7 days. This table will hold access logs so will fill up pretty quickly.
I'm not too sure if this is entirely possible but this is what I'm trying to use.
Any help or a push in the right direction would be amazing.
function log_dump() {
$week = (date("Ymd") - 7);
$dbhost = 'hostname';
$dbuser = 'username';
$dbpass = 'pass';
$dbname = 'db_name.table_name';
$backupFile = $dbname . "." . date("Y-m-d") . '.sql';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname --where=\"date_in='$week'\" > $backupFile";
system($command);
}
Thanks,
Daryll.