Home > Technology > 删除多余的备份

删除多余的备份

Sat, 19 Sep 2009 01:38:55 +0800

当初的server-backup.pl不太完善,因为不会自动删除已经备份的文件,所以日积月累会很多多余的文件。现在改进一下。

#now, we delete the file created at 7 days ago.
($sec,$min,$hour,$mday,$mon,$year,
          $wday,$yday,$isdst) = localtime(time()-7*24*60*60);
$bto = sprintf("/data/backup/%4d%02d%02d.tar.gz", $year+1900, $mon+1, $mday);
system("rm -f ".$bto);
system("echo \"".localtime(time)." delete $bto OK.\" >> /data/log/backup.log");

这样,就会删除7天以前的备份档了。

Hots
评论
发表评论:


  [TIPS:首次发表评论的朋友,需要验证]
Tags
Recent Post
Recent Comments
Links
Copyright Notes
You can reship all of these articles without permission but MUST mark the original link in your post. Please contact with me() if u have advice or other arrangements.
Copyright©2007-2011 lewphee.com All rights reserved.