Category: | CGI programming |
Author/Contact Info | |
Description: | I created this script to play around with Archive::Zip.
Tested on win32, but could work on X systems too. The script creates and sends a Zip archive to the client. It will add a full dir tree and you can suggest a downloadname for the zipfile. Might be handy to backup/mirror sites that have slow FTP but good HTTP.
It uses a simple config file with two entries: |
binmode(STDOUT); use Archive::Zip; use Archive::Zip::Tree; my $zip = Archive::Zip->new(); our $programdir = "."; $programdir = $1 if $0=~/^(.+[\\\/])[^\\\/]+$/; my $docroot = ""; open(CONFIG,"$programdir/getbackup.conf") || &DieConfig; while(<CONFIG>){ $docroot =$1 if /root\=(.+)[\n\r\s]*/i; $backupname =$1 if /name\=(.+)[\n\r\s]*/i; } close(CONFIG); print STDOUT "HTTP/1.0 200 OK\n"; print STDOUT "Content-Type: application/x-downloads\n"; print STDOUT "Content-Disposition: attachment; filename=backup$backupn +ame-".time.".zip\n"; print STDOUT "\n"; # add all readable files and directories below . as xyz/* $zip->addTree( $docroot, './'); # and write them into a file $zip->writeToFileHandle(STDOUT,0); sub DieConfig { print STDOUT "Content-type: text/html\n\n"; print STDOUT "Need getbackup.conf with docroot= and name= setting\ +n"; exit; } |
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: CGI - Zip tree archiver backup thing
by merlyn (Sage) on Feb 27, 2003 at 13:15 UTC | |
Re: CGI - Zip tree archiver backup thing
by PodMaster (Abbot) on Feb 28, 2003 at 06:58 UTC |
Back to
Code Catacombs