All,
This is a tiny script that I am using to create nightly dumps of my MySQL
dbs. Each night it will generate these files:
a-071804-0900pm.sql
b-071804-0900pm.sql
c-071804-0900pm.sql
I am trying to modify the script so that it will 1) check the current month,
and 2) delete the backups that are not from the current month (i.e. in the
case above, all the a-06*.sql, b-06*.sql and c-06*.sql 's will be deleted.
This way I only have 1 month of dumps.
Here is the script (I have it setup as a scheduled task)
<?php
$host = "localhost" ;
$user = "root";
$pass = "password";
$dbnames = array ("a","b","c" );
$savepath = "c:\\inetpub\\s qlbackup\\";
$date = date("mdy-hia");
foreach($dbname s as $dbname)
{
$filename = $savepath.$dbna me."-".$date.".s ql";
$execCmd = "mysqldump -h$host -u$user -p$pass $dbname >> $filename";
exec($execCmd);
}
?>
Any ideas ?
Thanks.
This is a tiny script that I am using to create nightly dumps of my MySQL
dbs. Each night it will generate these files:
a-071804-0900pm.sql
b-071804-0900pm.sql
c-071804-0900pm.sql
I am trying to modify the script so that it will 1) check the current month,
and 2) delete the backups that are not from the current month (i.e. in the
case above, all the a-06*.sql, b-06*.sql and c-06*.sql 's will be deleted.
This way I only have 1 month of dumps.
Here is the script (I have it setup as a scheduled task)
<?php
$host = "localhost" ;
$user = "root";
$pass = "password";
$dbnames = array ("a","b","c" );
$savepath = "c:\\inetpub\\s qlbackup\\";
$date = date("mdy-hia");
foreach($dbname s as $dbname)
{
$filename = $savepath.$dbna me."-".$date.".s ql";
$execCmd = "mysqldump -h$host -u$user -p$pass $dbname >> $filename";
exec($execCmd);
}
?>
Any ideas ?
Thanks.
Comment