astroboy has asked for the wisdom of the Perl Monks concerning the following question:

I've been using snapback2, a fine Perl utility for performing remote backups using ssh and rsync. However, it relies on gnu "cp" - specifically the "cp -al" flags (archive and create hard links)

Unfortunately, my backup Mac OS X server doesn't recognize these flags. The way I got snapback2 working was to ignore the "make test" failures, continue with the snapback2 install, and then installed the gnu cp - you can specify alternate cp, mv and rm commands in the config file once snapback2 is installed.

It seems to me that a better solution would be to do the "cp -al" in native Perl, but I'm not sure if the hard-linking part is possible. Can it be done?

Replies are listed 'Best First'.
Re: Hard linking with Perl
by Zaxo (Archbishop) on Jul 21, 2005 at 21:19 UTC
Re: Hard linking with Perl
by friedo (Prior) on Jul 21, 2005 at 21:21 UTC
    You can create hard links with the builtin link function.

    link( $file, $newfile ) or die $!;
      Cheers guys. I take it that this means that in order to replicate "cp -al", I need to traverse the directory tree, and copy it by replicating the directory structure, and hard linking to each file in turn.
Re: Hard linking with Perl
by fmerges (Chaplain) on Jul 22, 2005 at 00:15 UTC