Copy specific directories from one server to another

This is a really really simple script that copy specified directories from /apps/tools in one server (PRODUCTION1.com) to another (PRODUCTION2.com) under the location /apps/tools.

Substitute the directory names, USER1 and PRODUCTION1 for the real names.

Yes, there are a thousand better ways to do this, but I was just too lazy to find the most efficient solution. Use it at your own risk!
#/usr/bin/perl

# TITLE       : Copy specified directories under /apps/tools
# DESCRIPTION : This script is a very basic Perl script that copies 
#                all specified directories from PRODUCTION1.com to PRODUCTION2.com
# CREATED     : Arul John May 2007
# MODIFIED    : Arul John May 2009
# NOTES
# 0. Create an ssh password-less connection as described in http://aruljohn.com/info/sshwithoutpasswd/
# 1. Login to PRODUCTION2.com
# 2. Copy this script to PRODUCTION2.com and run it from the directory where you want the copied directories 

# Variables
my $directories_in_prod = <<DIRECTORIES;
bin
conf
feeds
htdocs
install
lib
utils
DIRECTORIES

# Create directory list
my @dirs = split("\n", $directories_in_prod);

# Check if these directories exist
foreach my $dir (@dirs) {
    if (-e $dir) {
	    print ">> $dir EXISTS... not copying\n";
    } else {
	    print "++ $dir - copying\n";
	    system('scp -r USER1@PRODUCTION1.com:/apps/tools/'.$dir.' .');
    }
}

# Goodbye
print "\n # Goodbye\n";
exit;

Last Updated: Fri Apr 23 16:36:08 2010