Hi there --
I am involved with the writing of a script that is designed to first encrypt, then tar, and subsequently copy to tape. There are normally a series of subdirectories under the parent directory. The idea here is to individually encrypt and then tar the directories under the parent without having to make a separate copy of each encrypted file.
Listed below is the script that is being developed to accomplish this task:
Code:
#!/usr/local/bin/perl
# The purpose of this script is to run a tar backup on
# every file wihtin a specific directory. Each file in
# the directory will be tarred, and then encrypted.
# Once that is done, the encrypted file will then be
# copied to tape. After that, the encrypted and original
# tar files will then be deleted from the directory.
# This process will be repeated for every file within
# the directory.
# Uncomment the line below to debug the script.
# set -x
# Prompt the user for the directory in question:
print "Please enter the full path of the directory: \n";
$path = <STDIN>;
chomp $path;
print "You have entered the following path: $path \n";
# Confirm the directory that was entered is the correct one.
print "Is $path the correct directory? [y/n] \n";
$confirm = <STDIN>;
chomp $confirm;
# NOTE: The chomp command was inserted immediately after $confirm to ensure
# there was no end-of-line character (\n) that would intefere with script
# operations.
if ($confirm ne "y")
{exit;}
# Prompt the user for the full pathname of the destination tape drive
# echo "Please enter the full devicefile name of the tape drive: "
# read devicefile
print "Please enter the full path of the device file: \n";
$device = <STDIN>;
chomp $device;
print "You have entered the following device file: $device \n";
# Confirm the device file that was entered is the correct one.
print "Is $device the correct device file? [y/n] \n";
$confirm = <STDIN>;
chomp $confirm;
# NOTE: The chomp command was inserted immediately after $confirm to ensure
# there was no end-of-line character (\n) that would intefere with script
# operations.
if ($confirm ne "y")
{exit;}
# Remind the user there should already be a tape in the destination drive
# or else the script will fail.
print "Verify there is a tape in the destination drive before proceeding \n";
print "Shall we proceed? [y/n] \n";
$confirm = <STDIN>;
chomp $confirm;
# NOTE: The chomp command was inserted immediately after $confirm to ensure
# there was no end-of-line character (\n) that would intefere with script
# operations.
if ($confirm ne "y")
{exit;}
# Prompt the user for the password that will be assigned to encrypted
# files that will be created and backed up to tape
print "Please enter the password that will be assigned to all of the \n";
print "encrypted files that will be backed up to tape. \n";
print "\n";
print "***************************************************************\n";
print "WARNING: BE SURE TO KEEP A GOOD AND SECURE RECORD OF THE PASSWORD\n";
print "THAT IS ASSOCIATED WITH THIS BACKUP. LOSING THIS RECORD WILL RESULT\n";
print "IN THE BACKED UP FILES NO LONGER BEING RETRIEVABLE.\n";
print "***************************************************************\n";
$password = <STDIN>;
chomp $password;
print "You have entered the following password: $password \n";
print "Shall we proceed? [y/n] \n";
$confirm = <STDIN>;
chomp $confirm;
if ($confirm ne "y")
{exit;}
# Run the tar, openssl, and tar command again to copy the encrypted file
# to the tape drive. Once the file is copied over, delete the original and
# the encrypted files from the directory. Repeat this process for for all
# files within the directory.
$cmd= "(cd $path; tar -czvf $FILENAME|openssl des3 -salt3 -k $PASSWORD |tar -cvf $FILENAME.des3 $DEVICENAME
# Once the initial tar, encryption, and copying of the encrypted file are comple
ted,
# go back to the directory and remove the tar and encrypted files. After that,
# repeat the procedure for the subsequent files in the directory.
# rm -rf $FILENAME
# rm -rf $FILENAME.des3
# Confirm the backup completed successfully, and send a notification to
# the system administrators.
What would the correct syntax be in order for the script to accomplish what is desired? Thanks.