Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
No CPAN modules? This version tars and gzips and allows the user to override a lot of default names. Instead of placing all arguments in another file, this one accepts long style arguments. Since the number of files to archive could be large, it does accept a textfile containing the list of files to archive.
#!/usr/bin/perl -w use strict; use Archive::Tar; use Getopt::Long; use Pod::Usage; use vars qw($base $dir $name $comp $list @file $debug $help); GetOptions( 'base=s' => \$base, 'dir=s' => \$dir, 'name=s' => \$name, 'comp=s' => \$comp, 'list=s' => \$list, 'file=s' => \@file, 'debug!' => \$debug, 'help|?' => \$help, ); pod2usage(-verbose=>1) if $help; pod2usage(-verbose=>2) unless $name and $list or @file; $base ||= '.'; $comp ||= 9; $dir = (localtime)[7]; print "BaseDIR: $base\n" if $debug; die "$base is not a directory" unless -d $base; if ($list) { open FH,'<',$list or die "couldn't open $list: $!"; chomp(@file = <FH>); } my $tardir = "$base/$dir"; print "archive is $tardir/$name\n" if $debug; print "files are @file\n" if $debug; if (-d "$tardir") { print "$tardir already exists\n" if $debug; } else { mkdir "$tardir", 0740 or die "cannot mkdir $tardir"; print "created $tardir\n" if $debug; } my $tar = Archive::Tar->create_archive("$tardir/$name",$comp,@file); __END__ =head1 NAME backup.pl -- backup files listed in text file or command line =head1 SYNOPSIS backup.pl -list|-file [-dir -name -args -debug -help] Options: -name required - name of tar file: -file required - specify files to archive or ... -list text file containing list of files to srchive -base dir to store tar directory: default is . -dir dir to store tar file: day of year is default -comp compression level: default is 9 -debug prints debugging messages -help this message Examples: backup.pl -list=backlist.txt -name=foo.tar backup.pl -file=foo.txt -file=bar.txt -name=foo.tar =cut

In reply to (jeffa) Re: backfiles by jeffa
in thread backfiles by xiphias

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (4)
    As of 2014-09-19 02:08 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (129 votes), past polls