Gossamer Forum
Home : General : Perl Programming :

How to copy a complete directory to another place

Quote Reply
How to copy a complete directory to another place
What is the easyest way to copy my complete links-directory to somewhat like /backup/$date/links/ ...

So that I can backup ALL of my files before playing arround with the links-engine???

I habe tried with a script like that, but I get an error 500:

sub main {
# --------------------------------------------------------
# Backs up important database files.
#
my $date = &get_date;

# Try to do it the right way..
eval { require File::Copy; };
# if (!$@) {
print "\tBacking up links, category and email database (File::Copy) ... \n";
&File::Copy::copy ("/www/guxme.de/cgi-bin/links/*", "/www/guxme.de/backup00/$date/*") or &cgierr ("Unable to copy links backup. Reason: $!");

# }
# Otherwise, the ugly way.
# else {
# print "\tBacking up links, category and email database (Regular - $@) ... \n";
# foreach (qw!links categories email!) {
# open (TMP, "$db_script_path/data/$_.db") or &cgierr ("Unable to open $db_script_path/data/$_.db. Reason: $!");
# open (TMPOUT, ">$db_script_path/backup/$date.$_.db") or &cgierr ("Unable to open $db_script_path/$date.$_.db. Reason: $!");
# while (<TMP>) {
# print TMPOUT;
# }
# close TMP;
# close TMPOUT;
# }
# }
}

Thanks, Chris