{"id":8655,"date":"2006-11-29T11:26:00","date_gmt":"1999-11-29T20:00:00","guid":{"rendered":"https:\/\/aidanfinn.com\/?p=8655"},"modified":"2006-11-29T11:26:00","modified_gmt":"1999-11-29T20:00:00","slug":"delete-old-files","status":"publish","type":"post","link":"https:\/\/aidanfinn.com\/?p=8655","title":{"rendered":"Delete Old Files"},"content":{"rendered":"<div>I&#8217;ve been working with Brightstor 11.5 SP2 Disk Staging Option lately.\u00a0 We&#8217;ve configured it to purge old staging data according to a policy.\u00a0 Unforunately, we&#8217;ve found that it only automatically purges data if the associated backup ran <em>perfectly.\u00a0 <\/em>Of course, being a CA product, this is a rare event.\u00a0 Hence our disk fills up with unwanted data and prevents future backups when the disk fills.<\/div>\n<div>\u00a0<\/div>\n<div>My solution is to purge old data using a script.\u00a0 I found something very similar to what I wanted on <a href=\"http:\/\/www.tek-tips.com\/viewthread.cfm?qid=1303716&amp;page=1\" rel=\"nofollow\">Tek-Tips<\/a> by a poster called &quot;monsterjta&quot;.\u00a0 After a little tweaking, I had what I wanted:<\/div>\n<div>\u00a0<\/div>\n<div>Option Explicit<br \/>on error resume next<br \/>\u00a0\u00a0\u00a0 Dim oFSO<br \/>\u00a0\u00a0\u00a0 Dim sDirectoryPath<br \/>\u00a0\u00a0\u00a0 Dim oFolder<br \/>\u00a0\u00a0\u00a0 Dim oFileCollection<br \/>\u00a0\u00a0\u00a0 Dim oFile<br \/>\u00a0\u00a0\u00a0 Dim iDaysOld<br \/>\u00a0\u00a0\u00a0 Dim CurDir<\/div>\n<div>\u00a0<\/div>\n<div>&#8216;Definitions<br \/>\u00a0\u00a0\u00a0 Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br \/>\u00a0\u00a0\u00a0 sDirectoryPath = CreateObject(&quot;WScript.Shell&quot;).CurrentDirectory<\/div>\n<div>\u00a0<\/div>\n<div>&#8216;Set the age (in days) for files to be deleted in E:D2DFulls<br \/>\u00a0\u00a0\u00a0 <strong><em>iDaysOld = 6<br \/><\/em><\/strong>\u00a0\u00a0\u00a0 <strong><em>sDirectoryPath = &quot;E:D2DFulls&quot;<br \/><\/em><\/strong>\u00a0\u00a0\u00a0 set oFolder = oFSO.GetFolder(sDirectoryPath)<br \/>\u00a0\u00a0\u00a0 set oFileCollection = oFolder.Files <br \/>\u00a0\u00a0\u00a0 DelOldFiles oFileCollection, iDaysOld<\/div>\n<div>\u00a0<\/div>\n<div>&#8216;Set the age (in days) for files to be deleted in E:D2DDiffs<br \/>\u00a0\u00a0\u00a0 <strong><em>iDaysOld = 5<\/em><\/strong><br \/>\u00a0\u00a0\u00a0 <strong><em>sDirectoryPath = &quot;E:D2DDiffs&quot;<br \/><\/em><\/strong>\u00a0\u00a0\u00a0 set oFolder = oFSO.GetFolder(sDirectoryPath)<br \/>\u00a0\u00a0\u00a0 set oFileCollection = oFolder.Files <br \/>\u00a0\u00a0\u00a0 DelOldFiles oFileCollection, iDaysOld<\/div>\n<div>Function DelOldFiles (oFileCollection, iDaysOld)<\/div>\n<div>&#8216;Walk through each file in this folder collection. <br \/>\u00a0\u00a0\u00a0 For each oFile in oFileCollection<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 If oFile.DateLastModified &lt; (Date() &#8211; iDaysOld) and NOT oFile.name = &quot;HEADER.CTF&quot; Then<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 oFile.Delete(True)<br \/>&#8216; The following line is commented out.\u00a0 It can be run for testing.<br \/>&#8216;\u00a0\u00a0\u00a0\u00a0 wscript.echo &quot;This file should be deleted: &quot; &amp; oFile.name<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 End If<br \/>\u00a0\u00a0\u00a0 Next<br \/>End Function<\/div>\n<div>\u00a0<\/div>\n<div>This script runs as a scheduled task on the backup server.\u00a0 The highlighted sections are set up to match the data retention\/purge policy in Disk Staging Option.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working with Brightstor 11.5 SP2 Disk Staging Option lately.\u00a0 We&#8217;ve configured it to purge old staging data according to a policy.\u00a0 Unforunately, we&#8217;ve found that it only automatically purges data if the associated backup ran perfectly.\u00a0 Of course, being a CA product, this is a rare event.\u00a0 Hence our disk fills up with &hellip; <a href=\"https:\/\/aidanfinn.com\/?p=8655\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Delete Old Files&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8655","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"jetpack_featured_media_url":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/8655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8655"}],"version-history":[{"count":0,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/8655\/revisions"}],"wp:attachment":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}