File-RsyncP

 view release on metacpan or  search on metacpan

lib/File/RsyncP.pm  view on Meta::CPAN

=item go(localDir)

Run the client rsync.  localDir is the source directory on the
local machine if the client is sending files, or it is the
destination directory on the local machine if the client is
receiving files.  Returns undef on success.

=item serverClose()

Call this after go() to finish up.  Returns undef on success.

=item statsFinal()

This can be optionally called to pickup the transfer stats.  It
returns a hashref containing elements totalRead, totalWritten,
totalSize, plus whatever the FileIO module might add.

=item abort()

Call this function to abort the transfer.

=back

An example of sending files to a remote rsync is:

    #
    # Send files to remote destDirectory from local srcDirectory
    # by running rsyncCmd with rsyncArgs.
    #
    $rs->remoteStart(0, destDirectory);
    $rs->go(srcDirectory);
    $rs->serverClose;

An example of receiving files from a remote rsync is:

    #
    # Receive files from remote srcDirectory to local destDirectory
    # by running rsyncCmd with rsyncArgs.
    #
    $rs->remoteStart(1, srcDirectory);
    $rs->go(destDirectory);
    $rs->serverClose;

=head2 Talking to a remote Rsync daemon

File::RsyncP can connect to a remote Rsync daemon using this
sequence of functions:

=over 4

=item serverConnect(host, port)

Connect to the Rsync daemon on the given string host and integer
port. The port argument is optional and it defaults to 873. On
error serverConnect returns a string error message. On success it
returns undef.

=item serverService(module, authUser, authPasswd, authRequired)

Specify which module to use (a "module" is the symbolic name that
appears inside "[...]" /etc/rsyncd.conf), the user's credentials
(authUser and authPasswd) and whether authorization is mandatory
(authRequired). If set to a non-zero value, authRequired ensures
that the remote Rsync daemon requires authentication.  If necessary,
this is to ensure that you don't connect to an insecure Rsync daemon.
The auth arguments are optional if the selected rsyncd module doesn't
require authentication.

See the rsyncd.conf manual page for more information.  For example, if a
host called navajo had a /etc/rsyncd.conf contains these lines:

   [test]
           path = /data/test
           comment = test module
           auth users = craig, celia
           secrets file = /etc/rsyncd.secrets

and /etc/rsyncd.secrets contained:

    craig:xxx

then you could connect to this rsyncd using:

    $rs->serverConnect("navajo", 873);
    $rs->serverService("test", "craig", "xxx", 0);

The value of the authRequired argument doesn't matter in this case.

On error serverService returns a string error message.
On success it returns undef.

=item serverStart(remoteSend, remoteDir)

Starts the remote server.  If the client is receiving files from
the server then remoteSend should be non-zero.  If the client is
sending files to the remote server then remoteSend should be zero.
The remoteDir typically starts with the module name, followed by
any directory below the module.  Or remoteDir can be just "."
to refer to the top-level module directory.
Returns undef on success.

=item go(localDir)

Run the client rsync.  localDir is the source directory on the
local machine if the client is sending files, or it is the
destination directory on the local machine if the client is
receiving files.  Returns undef on success.

=item serverClose()

Call this after go() to finish up.  Returns undef on success.

=item abort()

Call this function to abort the transfer.

=back

An example of sending files to a remote rsyncd daemon is:

    #



( run in 0.547 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )