#!/usr/bin/perl ### # Zip Back-up Utility 2010 expanding head # Use to back-up a directory and all files # under it. The new zip file will be added # to the directory this script is ran in. # The Directory Path must be the full path to # the directory you wish to archive # The Zip file name must end in .zip # Requires CGI.pm. # Chmod this script to 755 ### # This software is provided "as is" and any express or # implied warranties, including, but not limited to, the implied warranties # of merchantability and fitness for a particular purpose are disclaimed. # In no event shall the author be liable for any direct, indirect, # incidental, special, exemplary, or consequential damages my ($q, $root, $dir, $zip, $zname); use CGI qw(:standard); use strict; use warnings; $q = new CGI; $root = $ENV{'DOCUMENT_ROOT'}; $dir = $q->param('dir') || ''; $zname = $q->param('zname') || ''; print header,start_html(-title =>'Zip Back-Up Utility', -author =>'expandinghead.net', -bgcolor => '#ffffff', -text => '#000000'), p,h1('Zip Back-Up Utility'),p,'compress the files in a directory including subs',hr, start_form,table(Tr([ td(['Directory Path ',textfield(-size=>50,-name=>'dir',-default=> $root,)]), td(['Zip File Name ',textfield(-size=>50,-name=>'zname',-default=>'myback_up.zip',)]), td([submit(undef,' Submit '),reset]), ])),end_form; if (($dir ne '') && ($zname ne '')) { if (-d $dir) { if ($zname !~ /\.zip$/i) { $zname = $zname.'.zip'; } $zip = `zip -vr $zname $dir`; if (-e $zname) { print 'Zip file ',$zname,' was created',br, a({href=>"$zname"},$zname),br,pre($zip),br; } else { print 'Could not read file',pre($zip),br,br; } } else { print 'Could not find directory, Check your entry',br; } } print p,h5('expanding head'),end_html;