.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Rsync 3pm" .TH Rsync 3pm "2022-12-08" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" File::Rsync \- perl module interface to rsync(1) http://rsync.samba.org/rsync/ .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use File::Rsync; \& \& $obj = File::Rsync\->new( \& archive => 1, \& compress => 1, \& rsh => \*(Aq/usr/local/bin/ssh\*(Aq, \& \*(Aqrsync\-path\*(Aq => \*(Aq/usr/local/bin/rsync\*(Aq \& ); \& \& $obj\->exec( src => \*(Aqlocaldir\*(Aq, dest => \*(Aqrhost:remotedir\*(Aq ) \& or warn "rsync failed\en"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Perl Convenience wrapper for the \fBrsync\fR\|(1) program. Written for \fIrsync\-2.3.2\fR and updated for \fIrsync\-3.1.1\fR but should perform properly with most recent versions. .SS "File::Rsync::new" .IX Subsection "File::Rsync::new" .Vb 1 \& $obj = new File::Rsync; \& \& or \& \& $obj = File::Rsync\->new; \& \& or \& \& $obj = File::Rsync\->new(@options); .Ve .PP Create a \fIFile::Rsync\fR object. Any options passed at creation are stored in the object as defaults for all future \fIexec\fR calls on that object. Options may be passed in the style of a hash (key/value pairs) and are the same as the long options in \fI\f(BIrsync\fI\|(1)\fR without the leading double-hyphen. Any leading single or double-hyphens are removed, and you may use underscore in place of hyphens in option names to simplify quoting and avoid possible equation parsing (subtraction). .PP Although options are key/value pairs, as of version 0.46 the order is now preserved. Passing a hash reference is still supported for backwards compatibility, but is deprecated as order cannot be preserved for this case. .PP An additional option of \fBpath-to-rsync\fR also exists which can be used to override the using \s-1PATH\s0 environemt variable to find the rsync command binary, and \fBmoddebug\fR which causes the module methods to print some debugging information to \s-1STDERR.\s0 .PP There are also 2 options to wrap the source and/or destination paths in double-quotes: these are \fBquote-src\fR and \fBquote-dst\fR, which may be useful in protecting the paths from shell expansion (particularly useful for paths containing spaces). This wraps all source and/or destination paths in double-quotes to limit remote shell expansion. It is similar but not necessarily the same result as the \fBprotect-args\fR option in rsync itself. .PP The \fBoutfun\fR and \fBerrfun\fR options take a function reference, called once for each line of output from the \fIrsync\fR program with the output line passed in as the first argument, the second arg is either 'out' or 'err' depending on the source. This makes it possible to use the same function for both and still determine where the output came from. .PP If options are passed as a hash reference (deprecated), the \fBexclude\fR needs an array reference as it's value since there cannot be duplicate keys in a hash. Since order cannot be preserved in a hash, this module currently limits the use of \fBexclude\fR or \fBinclude\fR together. They can be mixed together if options are in the form of a list or array ref. .PP Use the '+ ' or '\- ' prefix trick to put includes in an \fBexclude\fR array, or to put excludes in an \fBinclude\fR array (see \fI\f(BIrsync\fI\|(1)\fR for details). .PP Include/exclude options form an ordered list. The order must be retained for proper execution. There are also \fBsource\fR and \fBdest\fR keys. The key \fBsrc\fR is also accepted as an equivalent to \fBsource\fR, and \fBdst\fR or \&\fBdestination\fR may be used as equivalents to \fBdest\fR. The \fBsource\fR option may take a scalar or an array reference. If the source is the local system then multiple \fBsource\fR paths are allowed. In this case an array reference should be used. There is also a method for passing multiple source paths to a remote system. This method may be triggered in this module by passing the remote hostname to the \fBsrchost\fR key and passing an array reference to the \fBsource\fR key. If the source host is being accessed via an Rsync server, the remote hostname should have a single trailing colon on the name. When rsync is called, the \fBsrchost\fR value and the values in the \fBsource\fR array will be joined with a colon resulting in the double-colon required for server access. The \fBdest\fR key only takes a scalar since \fIrsync\fR only accepts a single destination path. .PP Version 2.6.0 of \fI\f(BIrsync\fI\|(1)\fR provides a new \fBfiles-from\fR option along with a few other supporting options (\fBfrom0\fR, \fBno-relative\fR, and \&\fBno-implied-dirs\fR). To support this wonderful new option at the level it deserves, this module now has an additional parameter. As of version 0.46 the value of \fBfiles-from\fR may be an array reference. The contents of the array are passed to \fBfiles-from\fR the same as the below method using \fBinfun\fR but implemented inside the module. .PP If \fBfiles-from\fR is set to '\-' (meaning read from stdin) you can define \&\fBinfun\fR to be a reference to a function that prints your file list to the default file handle. The output from the function is attached to stdin of the rsync call during exec. If \fBinfun\fR is defined it will be called regardless of the value of \&\fBfiles-from\fR, so it can provide any data expected on stdin, but keep in mind that stdin will not be attached to a tty so it is not very useful for sending passwords (see the \fI\f(BIrsync\fI\|(1)\fR and \fI\f(BIssh\fI\|(1)\fR man pages for ways to handle authentication). The \fI\f(BIrsync\fI\|(1)\fR man page has a more complete description of \fBfiles-from\fR. Also see File::Find for ideas to use with \fBfiles-from\fR and \fBinfun\fR. .PP The \fBinfun\fR option may also be used with the \fBinclude-from\fR or \&\fBexclude-from\fR options, but this is generally more clumsy than using the \&\fBinclude\fR or \fBexclude\fR arrays. .PP Version 2.6.3 of \fI\f(BIrsync\fI\|(1)\fR provides new options \fBpartial-dir\fR, \&\fBchecksum-seed\fR, \fBkeep-dirlinks\fR, \fBinplace\fR, \fBipv4\fR, and \fBipv6\fR. Version 2.6.4 of \fI\f(BIrsync\fI\|(1)\fR provides new options \fBdel\fR, \fBdelete-before\fR \&\fBdelete-during\fR, \fBdelay-updates\fR, \fBdirs\fR, \fBfilter\fR, \fBfuzzy\fR, \&\fBitemize-changes\fR, \fBlist-only\fR, \fBomit-dir-times\fR, \fBremove-sent-files\fR, \&\fBmax-size\fR, and \fBprotocol\fR. .PP Version 0.38 of this module also added support for the \fBacls\fR option that is not part of \fI\f(BIrsync\fI\|(1)\fR unless the patch has been applied, but people do use it. It also includes a new \fBliteral\fR option that takes an array reference similar to \fBinclude\fR, \fBexclude\fR, and \fBfilter\fR. Any arguments in the array are passed as literal arguments to rsync, and are passed first. They should have the proper single or double hyphen prefixes and the elements should be split up the way you want them passed to exec. The purpose of this option is to allow the use of arbitrary options added by patches, and/or to allow the use of new options in rsync without needing an immediate update to the module in addtition to \fI\f(BIrsync\fI\|(1)\fR itself. .SS "File::Rsync::defopts" .IX Subsection "File::Rsync::defopts" .Vb 1 \& $obj\->defopts(@options); \& \& or \& \& $obj\->defopts(\e@options); .Ve .PP Set default options for future exec calls for the object. See \fI\f(BIrsync\fI\|(1)\fR for a complete list of valid options. This is really the internal method that \fInew\fR calls but you can use it too. The \fBverbose\fR and \fBquiet\fR options to rsync are actually counters. When assigning the perl hash-style options you may specify the counter value directly and the module will pass the proper number of options to rsync. .SS "File::Rsync::getcmd" .IX Subsection "File::Rsync::getcmd" .Vb 1 \& my $cmd = $obj\->getcmd(@options); \& \& or \& \& my $cmd = $obj\->getcmd(\e@options); \& \& or \& \& my ($cmd, $infun, $outfun, $errfun, $debug) = $obj\->getcmd(\e@options); .Ve .PP \&\fIgetcmd\fR returns a reference to an array containing the real rsync command that would be called if the exec function were called. The last example above includes a reference to the optional stdin function, stdout function, stderr function, and the debug setting. This is the form used by the \fIexec\fR method to get the extra parameters it needs to do its job. The function is exposed to allow a user-defined exec function to be used, or for debugging purposes. .SS "File::Rsync::exec" .IX Subsection "File::Rsync::exec" .Vb 1 \& $obj\->exec(@options) or warn "rsync failed\en"; \& \& or \& \& $obj\->exec(\e@options) or warn "rsync failed\en"; .Ve .PP This is the method that does the real work. Any options passed to this routine are appended to any pre-set options and are not saved. They effect the current execution of \fIrsync\fR only. In the case of conflicts, the options passed directly to \fIexec\fR take precedence. It returns \fB1\fR if the return status was zero (or true), if the \fIrsync\fR return status was non-zero it returns \fB0\fR and stores the return status. You can examine the return status from \fIrsync\fR and any output to stdout and stderr with the methods listed below. .SS "File::Rsync::list" .IX Subsection "File::Rsync::list" .Vb 1 \& $out = $obj\->list(@options); \& \& or \& \& $out = $obj\->list(\e@options); \& \& or \& \& @out = $obj\->list(\e@options); .Ve .PP This is a wrapper for \fIexec\fR called without a destination to get a listing. It returns the output of stdout like the \fIout\fR function below. When no destination is given rsync returns the equivalent of 'ls \-l' or \&'ls \-lr' modified by any include/exclude/filter parameters you specify. This is useful for manual comparison without actual changes to the destination or for comparing against another listing taken at a different point in time. .PP (As of rsync version 2.6.4\-pre1 this can also be accomplished with the \&'list\-only' option regardless of whether a destination is given.) .SS "File::Rsync::status" .IX Subsection "File::Rsync::status" .Vb 1 \& $rval = $obj\->status; .Ve .PP Returns the status from last \fIexec\fR call right shifted 8 bits. .SS "File::Rsync::realstatus" .IX Subsection "File::Rsync::realstatus" .Vb 1 \& $rval = $obj\->realstatus; .Ve .PP Returns the real status from last \fIexec\fR call (not right shifted). .SS "File::Rsync::err" .IX Subsection "File::Rsync::err" .Vb 1 \& $aref = $obj\->err; .Ve .PP In scalar context this method will return a reference to an array containing all output to stderr from the last \fIexec\fR call, or zero (false) if there was no output. In an array context it will return an array of all output to stderr or an empty list. The scalar context can be used to efficiently test for the existence of output. \&\fIrsync\fR sends all messages from the remote \fIrsync\fR process and any error messages to stderr. This method's purpose is to make it easier for you to parse that output for appropriate information. .SS "File::Rsync::out" .IX Subsection "File::Rsync::out" .Vb 1 \& $aref = $obj\->out; .Ve .PP Similar to the \fIerr\fR method, in a scalar context it returns a reference to an array containing all output to stdout from the last \fIexec\fR call, or zero (false) if there was no output. In an array context it returns an array of all output to stdout or an empty list. \&\fIrsync\fR sends all informational messages (\fBverbose\fR option) from the local \&\fIrsync\fR process to stdout. .SS "File::Rsync::lastcmd" .IX Subsection "File::Rsync::lastcmd" .Vb 1 \& $aref = $obj\->lastcmd; .Ve .PP Returns the actual system command used by the last \fIexec\fR call, or '' before any calls to \fIexec\fR for the object. This can be useful in the case of an error condition to give a more informative message or for debugging purposes. In an array context it return an array of args as passed to the system, in a scalar context it returns a space-seperated string. See \fIgetcmd\fR for access to the command before execution. .SH "Author" .IX Header "Author" Lee Eakin .SH "Credits" .IX Header "Credits" The following people have contributed ideas, bug fixes, code or helped out by reporting or tracking down bugs in order to improve this module since it's initial release. See the Changelog for details: .PP Greg Ward .PP Boris Goldowsky .PP James Mello .PP Andreas Koenig .PP Joe Smith .PP Jonathan Pelletier .PP Heiko Jansen .PP Tong Zhu .PP Paul Egan .PP Ronald J Kimball .PP James \s-1CE\s0 Johnson .PP Bill Uhl .PP Peter teStrake .PP Harald Flaucher .PP Simon Myers .PP Gavin Carr .PP Petya Kohts .PP Neil Hooey .PP Erez Schatz .PP Max Maischein .SH "Inspiration and Assistance" .IX Header "Inspiration and Assistance" Gerard Hickey \f(CW\*(C`PGP::Pipe\*(C'\fR .PP Russ Allbery \f(CW\*(C`PGP::Sign\*(C'\fR .PP Graham Barr \f(CW\*(C`Net::*\*(C'\fR .PP Andrew Tridgell and Paul Mackerras \fBrsync\fR\|(1) .PP John Steele .PP Philip Kizer .PP Larry Wall \fBperl\fR\|(1) .PP I borrowed many clues on wrapping an external program from the \s-1PGP\s0 modules, and I would not have had such a useful tool to wrap except for the great work of the \fBrsync\fR authors. Thanks also to Graham Barr, the author of the libnet modules and many others, for looking over this code. Of course I must mention the other half of my brain, John Steele, and his good friend Philip Kizer for finding \fBrsync\fR and bringing it to my attention. And I would not have been able to enjoy writing useful tools if not for the creator of the \fBperl\fR language. .SH "Copyrights" .IX Header "Copyrights" .Vb 1 \& Copyright (c) 1999\-2015 Lee Eakin. All rights reserved. \& \& This program is free software; you can redistribute it and/or modify \& it under the same terms as Perl itself. .Ve