Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Archive::Zip[ing] a very active directory

by brooklynBen (Initiate)
on Oct 11, 2010 at 18:45 UTC ( #864674=perlquestion: print w/replies, xml ) Need Help??
brooklynBen has asked for the wisdom of the Perl Monks concerning the following question:

I've been using a server side script for about 5 years now. The idea is to mirror the contents of the requested directory. These directories are very, very active; at any time files are being created, modified, deleted and renamed. I can have as few as a dozen to as many as fifty-thousand files. At any moment in time I cannot predict what if anything will happen much less to which file(s) it will happen to.

This whole process works 98% of the time except for when (I think) a file is renamed between the time I call $zip->addFile and then $zip->writeToFileNamed. The program dies.

I'm not all that concern that I get a perfect mirror it's just supposed to be a snapshot so if my mirror leaves out a file or two it won't matter a whole lot. Is there a way to tell Archive to skip a file if it no longer exists?

use Archive::Zip qw( :ERROR_CODES ); my $zip = Archive::Zip->new(); opendir(DataDir, "."); foreach (readdir(DataDir)) { if( -e $_ and $_ ne "." and $_ ne "..") { $member = $zip->addFile($_); $member->desiredCompressionLevel( 1 ); } } $zip->writeToFileNamed("");

Edit: I forgot to mention that I'm running this on a Windows Server 2003 with ActivePerl

Replies are listed 'Best First'.
Re: Archive::Zip[ing] a very active directory
by jfroebe (Parson) on Oct 11, 2010 at 20:43 UTC

    Check out Shadow Volumes - part of windows XP and higher. They will create a snapshot where you can backup the files you need.

    Jason L. Froebe

    Blog, Tech Blog

      The link above didn't work for me, but Wiki - Shadow Copy has a pretty good description to get started. Should work on Win 2003 server. These things can have some significant performance issues - so ymmy.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://864674]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2018-06-20 21:36 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.