How can I archive a directory in Perl -


i'm trying archive directory subdirectory , files. below code doesnt work properly. archived files , folders, not content of folders ! how can solve ?

my @files = glob( $backup_path.'website/*' ); $tar = archive::tar->new(); $tar->add_files(@files);  $date = datetime->now(time_zone=>"local"); $tar->write($backup_path.$websitefoldername."/".$date->dmy('-')."-".$websitefoldername.".tar"); 

glob (perldoc) not recurse subdirectories. need take care of or use module file::find:

use archive::tar; use file::find qw(find);  @files; find( { wanted => sub { push @files, $file::find::name } }, $backup_path.'website'); $tar = archive::tar->new(); $tar->add_files( @files );  $date = datetime->now(time_zone=>"local"); $tar->write($backup_path.$websitefoldername."/".$date->dmy('-')."-".$websitefoldername.".tar"); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -