Simple script I used to back up my Laptop before lease exchange. Was not looking to reinvent the wheel, saw rcopy after I wrote this and rcopy requires rsync. I was running XP with activestate perl, so seemed just as easy to write something quick that would do the job.
update: Thanks graff for pointing out the error I had with mkpath
eval { mkpath (["$copy_to/$dir"]); };
die "Could not create Path $copy_to $dir $@" if($@);
You seem to be checking for a failure of "mkpath" (using an eval block), but in the case where that actually fails, you keep moving ahead as if it succeeded.
I would recommend that you put an additional check before the "opendir()" call:
if ( ! -d "$copy_to/$dir" ) {
warn "Cannot copy/zip $src because $copy_to/$dir does not
+exist\n";
next;
}
opendir( $dh, $src );
...
That always returns true (because of the "1" at the end) regardless of return value from mkpath. In other words, there's no need for the eval at all, because you are defeating its purpose with the final "1".