Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies


Is it possible to use relative path names?



8:20 am on Jul 3, 2005 (gmt 0)

10+ Year Member

Is it possible to use the Archive::Tar module with relative path names, so that I can archive all files of the /home/domain1/public_html directory, and extract the archive file on another server: /home/domain2/public_html?


4:34 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

There are a number of commercial options available for this, I also found this article that may be of use to you.


This is very acheivable of you are intending to backup the tar file to another server on your network.



6:52 pm on Jul 5, 2005 (gmt 0)

10+ Year Member

Yes, Archive::Tar does relative pathames. Here's a little command line script (call it at.pl) to demonstrate:
use Archive::Tar;
die "Usage: at.pl <dir> [<dir>...]\n" unless @ARGV;
my $tar = Archive::Tar->new;
for my $dir (@ARGV) {
$dir =~ s'/+$'';
$tar->add_files(glob "$dir/*");

Start it from the root of the directory you want to save, e.g.:
$ cd /home/domain1
$ at.pl public_html

For full details, take a look at perldoc Archive::Tar. If you're using this for anything but a small number of files, you should probably use the os tar cmd instead. Also, this script is very basic - it doesn't do much error checking, and doesn't handle nested directories correctly.


Featured Threads

Hot Threads This Week

Hot Threads This Month