.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Rsync 3pm" .TH Rsync 3pm "2009-08-18" "perl v5.14.2" "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" use File::Rsync; .PP \&\f(CW$obj\fR = File::Rsync\->new( { archive => 1, compress => 1, rsh => '/usr/local/bin/ssh', 'rsync\-path' => '/usr/local/bin/rsync' } ); .PP \&\f(CW$obj\fR\->exec( { src => 'localdir', dest => 'rhost:remdir' } ) or warn \*(L"rsync failed\en\*(R"; .SH "DESCRIPTION" .IX Header "DESCRIPTION" Perl Convenience wrapper for the \fIrsync\fR\|(1) program. Written for \fIrsync\-2.3.2\fR and updated for \fIrsync\-2.6.0\fR but should perform properly with most recent versions. .IP "File::Rsync::new" 4 .IX Item "File::Rsync::new" \&\f(CW$obj\fR = \fInew\fR File::Rsync; .Sp .Vb 1 \& or .Ve .Sp \&\f(CW$obj\fR = File::Rsync\->\fInew\fR; .Sp .Vb 1 \& or .Ve .Sp \&\f(CW$obj\fR = File::Rsync\->new(@options); .Sp .Vb 1 \& or .Ve .Sp \&\f(CW$obj\fR = File::Rsync\->new(\e%options); .Sp 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 form of a hash and are the same as the long options in \fI\fIrsync\fI\|(1)\fR with the leading double-dash removed. An additional option of \fBpath-to-rsync\fR also exists which can be used to override the hardcoded path to the rsync binary that is defined when the module is installed, and \fBdebug\fR which causes the module methods to print some debugging information to \s-1STDERR\s0. There are also 2 options to wrap the source and/or destination paths in double-quotes. They are \fBquote-src\fR and \fBquote-dst\fR, and may be useful in protecting the paths from shell expansion (particularly useful for paths containing spaces). The \&\fBoutfun\fR and \fBerrfun\fR options take a function reference. The function is 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. Options may also be passed as a reference to a hash. The \fBexclude\fR option needs an array reference as its value, since there cannot be duplicate keys in a hash. There is an equivalent \fBinclude\fR option. Only an \fBexclude\fR or \fBinclude\fR option should be used, not both. Use the '+ ' or '\- ' prefix trick to put includes in an \fBexclude\fR array, or to put excludes in an \fBinclude\fR array (see \fI\fIrsync\fI\|(1)\fR for details). 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. .Sp Version 2.6.0 of \fI\fIrsync\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. 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\fIrsync\fI\|(1)\fR and \fI\fIssh\fI\|(1)\fR man pages for ways to handle authentication). The \fI\fIrsync\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. The \fBinfun\fR option may also be used with the \fBinclude-from\fR or \fBexclude-from\fR settings, but this is generally more clumsy than using the \&\fBinclude\fR or \fBexclude\fR arrays. .Sp Version 2.6.3 of \fI\fIrsync\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\fIrsync\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. .Sp Version 0.38 of this module also adds support for the \fBacls\fR option that is not part of \fI\fIrsync\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 imediate update to the module in addtition to \fI\fIrsync\fI\|(1)\fR itself. .IP "File::Rsync::defopts" 4 .IX Item "File::Rsync::defopts" \&\f(CW$obj\fR\->defopts(@options); .Sp .Vb 1 \& or .Ve .Sp \&\f(CW$obj\fR\->defopts(\e%options); .Sp Set default options for future exec calls for the object. See \fI\fIrsync\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. .IP "File::Rsync::getcmd" 4 .IX Item "File::Rsync::getcmd" my \f(CW$cmd\fR = \f(CW$obj\fR\->getcmd(@options); .Sp .Vb 1 \& or .Ve .Sp my \f(CW$cmd\fR = \f(CW$obj\fR\->getcmd(\e%options); .Sp .Vb 1 \& or .Ve .Sp my ($cmd, \f(CW$infun\fR, \f(CW$outfun\fR, \f(CW$errfun\fR, \f(CW$debug\fR) = \f(CW$obj\fR\->getcmd(\e%options); .Sp \&\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. .IP "File::Rsync::exec" 4 .IX Item "File::Rsync::exec" \&\f(CW$obj\fR\->exec(@options) or warn \*(L"rsync failed\en\*(R"; .Sp .Vb 1 \& or .Ve .Sp \&\f(CW$obj\fR\->exec(\e%options) or warn \*(L"rsync failed\en\*(R"; .Sp 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. .IP "File::Rsync::list" 4 .IX Item "File::Rsync::list" \&\f(CW$out\fR = \f(CW$obj\fR\->list(@options); .Sp .Vb 1 \& or .Ve .Sp \&\f(CW$out\fR = \f(CW$obj\fR\->list(\e%options); .Sp .Vb 1 \& or .Ve .Sp \&\f(CW@out\fR = \f(CW$obj\fR\->list(\e%options); .Sp 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. .Sp (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.) .IP "File::Rsync::status" 4 .IX Item "File::Rsync::status" \&\f(CW$rval\fR = \f(CW$obj\fR\->\fIstatus\fR; .Sp Returns the status from last \fIexec\fR call right shifted 8 bits. .IP "File::Rsync::realstatus" 4 .IX Item "File::Rsync::realstatus" \&\f(CW$rval\fR = \f(CW$obj\fR\->\fIrealstatus\fR; .Sp Returns the real status from last \fIexec\fR call (not right shifted). .IP "File::Rsync::err" 4 .IX Item "File::Rsync::err" \&\f(CW$aref\fR = \f(CW$obj\fR\->\fIerr\fR; .Sp In a 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 existance 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. .IP "File::Rsync::out" 4 .IX Item "File::Rsync::out" \&\f(CW$aref\fR = \f(CW$obj\fR\->\fIout\fR; .Sp 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. .IP "File::Rsync::lastcmd" 4 .IX Item "File::Rsync::lastcmd" \&\f(CW$aref\fR = \f(CW$obj\fR\->\fIlastcmd\fR; .Sp 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 .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 \fIrsync\fR\|(1) .PP John Steele .PP Philip Kizer .PP Larry Wall \fIperl\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\-2005 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