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

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -