Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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("myFile.zip");

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

Comment on Archive::Zip[ing] a very active directory
Download Code
Re: Archive::Zip[ing] a very active directory
by jfroebe (Vicar) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://864674]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-10-25 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls