
January 4th, 2002, 12:39 AM
|
|
Gödelian monster
|
|
Join Date: Jul 1999
Location: Central Florida, USA
|
|
tar -zpscf tarfilename.tar.gz directory/*
Here's a Perl script that will create a recursive tarfile, and name it with the date and time embedded in the filename. I usually place it in /usr/local/bin. Just call it while adjacent to the directory you want to archive, using the directory name as the argument:
myscript directory_name
or
myscript directory_name/
Code:
#!/usr/bin/perl -w
$dir_in=shift(@ARGV);
chomp($dir_in);
$dir_in =~ tr/\///d;
print "Archiving $dir_in/* ...\n";
use POSIX qw(strftime);
$now_string = strftime "%m-%d-%Y_%H%M", localtime;
$tarname=$dir_in."_".$now_string.".tar.gz";
$execstring="tar -zpscf ".$tarname." ".$dir_in."/*";
#print($execstring); # uncomment to debug
system($execstring);
print("\n");
|