A while back, I had written a quick and dirty shell script to take a simple tarball of the /etc directory of my linux machines and copy it to an FTP server. Then, to make sure that the FTP directory didn’t get out of hand, I had written the following in my puppet config for that server that would clean everything up with the use of the tidy resource type. The code looked like this:
tidy { "/srv/ftp/mrbackup":
path => "/srv/ftp/mrbackup/",
age => "30d",
recurse => true,
}
Nothing really fancy there and I put this in day 1 so I figured everything would run and the tidy command is pretty straight forward.
Unfortunately, when I checked the machine after it had been recieving the backup files for several months, I found something a bit disturbing…Thousands of files!!! WTF!
The documentation seemed pretty straight forward and I was using this command in other parts of my manifests that worked as expected.
The fix!
The key was at the very end of the documention in the type section.
type
Set the mechanism for determining age. Default: atime.
Valid values are atime, mtime, ctime.
As you will note, the default is atime. Because the files are being FTP’d in, they are never being read by the system, simply written. So if you ran a command like find . -type f -atime +30, you would get zero results. My fix is pretty simple, change this to mtime and suddenly I have a lot less files on the system. The new code now looks like this:
tidy { "/srv/ftp/mrbackup":
path => "/srv/ftp/mrbackup/",
age => "30d",
backup => false,
recurse => true,
type => "mtime",
}
Share this:
<div class="sd-content">
<ul>
<li class="share-facebook">
<a rel="nofollow" data-shared="sharing-facebook-2539" class="share-facebook sd-button share-icon no-text" href="http://usrlocal.com/2016/05/when-puppet-leaves-an-un-tidy-mess/?share=facebook" target="_blank" title="Click to share on Facebook"><span></span><span class="sharing-screen-reader-text">Click to share on Facebook (Opens in new window)</span></a>
</li>
<li class="share-linkedin">
<a rel="nofollow" data-shared="sharing-linkedin-2539" class="share-linkedin sd-button share-icon no-text" href="http://usrlocal.com/2016/05/when-puppet-leaves-an-un-tidy-mess/?share=linkedin" target="_blank" title="Click to share on LinkedIn"><span></span><span class="sharing-screen-reader-text">Click to share on LinkedIn (Opens in new window)</span></a>
</li>
<li class="share-google-plus-1">
<a rel="nofollow" data-shared="sharing-google-2539" class="share-google-plus-1 sd-button share-icon no-text" href="http://usrlocal.com/2016/05/when-puppet-leaves-an-un-tidy-mess/?share=google-plus-1" target="_blank" title="Click to share on Google+"><span></span><span class="sharing-screen-reader-text">Click to share on Google+ (Opens in new window)</span></a>
</li>
<li class="share-pinterest">
<a rel="nofollow" data-shared="sharing-pinterest-2539" class="share-pinterest sd-button share-icon no-text" href="http://usrlocal.com/2016/05/when-puppet-leaves-an-un-tidy-mess/?share=pinterest" target="_blank" title="Click to share on Pinterest"><span></span><span class="sharing-screen-reader-text">Click to share on Pinterest (Opens in new window)</span></a>
</li>
<li class="share-twitter">
<a rel="nofollow" data-shared="sharing-twitter-2539" class="share-twitter sd-button share-icon no-text" href="http://usrlocal.com/2016/05/when-puppet-leaves-an-un-tidy-mess/?share=twitter" target="_blank" title="Click to share on Twitter"><span></span><span class="sharing-screen-reader-text">Click to share on Twitter (Opens in new window)</span></a>
</li>
<li class="share-email">
<a rel="nofollow" data-shared="" class="share-email sd-button share-icon no-text" href="http://usrlocal.com/2016/05/when-puppet-leaves-an-un-tidy-mess/?share=email" target="_blank" title="Click to email this to a friend"><span></span><span class="sharing-screen-reader-text">Click to email this to a friend (Opens in new window)</span></a>
</li>
<li class="share-end">
</li>
</ul>
</div>