Since I was frustrated at having to constantly type:
tar -zpscf tarfilename directoryname, I whipped up this little Perl utility which compresses an entire directory, preserves permissions, and names the archive after the directory, while appending the current date and time into the name:
I called this "rarch" for "recursive archiver", and placed it in /usr/local/bin. Now, let's say I have a directory called "htmlfiles", and I want to archive and compress the whole directory, and be able to tell at a glance exactly when I did this, I just go one level outside that directory and type "rarch htmlfiles" (without the trailing slash "/"
. This creates a gzipped tarfile called htmlfiles_07-23-2001_1027.tar.gz (Assuming current time is 7/23/2001 at 10:27 AM)
Obviously, since this does not also use Seconds in the time, you will overwrite the last file if you call it twice in the same minute. I don't archive things often enough to worry about seconds ;-).
Anyone have any comments or additions? I would like to get a library of similar Perl system utilities together. Any good links for that sort of thing?
tar -zpscf tarfilename directoryname, I whipped up this little Perl utility which compresses an entire directory, preserves permissions, and names the archive after the directory, while appending the current date and time into the name:
Code:
#!/usr/bin/perl
$dir_in=shift(@ARGV);
chomp($dir_in);
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); # for debugging...
system($execstring);
print("\n");
I called this "rarch" for "recursive archiver", and placed it in /usr/local/bin. Now, let's say I have a directory called "htmlfiles", and I want to archive and compress the whole directory, and be able to tell at a glance exactly when I did this, I just go one level outside that directory and type "rarch htmlfiles" (without the trailing slash "/"
Obviously, since this does not also use Seconds in the time, you will overwrite the last file if you call it twice in the same minute. I don't archive things often enough to worry about seconds ;-).
Anyone have any comments or additions? I would like to get a library of similar Perl system utilities together. Any good links for that sort of thing?