OPENRSYNC(1) | General Commands Manual | OPENRSYNC(1) |
openrsync
—
synchronise local and remote files
openrsync |
[-0468BCDEFHILOPRSTWVabcdghklnopqrtuvxy ]
[-e program]
[-f filter]
[--address =sourceaddr]
[--append ]
[--backup-dir =directory]
[--bwlimit =limit] [--cache
| --no-cache ]
[--checksum-seed =NUM]
[--compare-dest =directory]
[--contimeout =seconds]
[--copy-dest =directory]
[--copy-unsafe-links ]
[--del ] [--delay-updates ]
[--delete-before ]
[--delete-during ]
[--delete-delay ]
[--delete-after ]
[--delete-excluded ]
[--exclude pattern]
[--exclude-from =file]
[--files-from =filespec]
[--force ]
[--ignore-errors ]
[--ignore-existing ]
[--ignore-non-existing ]
[--include pattern]
[--include-from =file]
[--inplace ]
[--keep-dirlinks ]
[--link-dest =directory]
[--max-size =size]
[--min-size =size]
[--modify-window =sec]
[--no-motd ]
[--numeric-ids ]
[--partial ]
[--password-file =pwfile]
[--port =service]
[--progress ]
[--read-batch =file]
[--remove-source-files ]
[--rsync-path =program]
[--safe-links ]
[--size-only ]
[--sockopts =sockopts]
[--specials ]
[--suffix =suffix]
[--super ]
[--timeout =seconds]
[--only-write-batch =file |
--write-batch =file]
source ... directory |
openrsync |
--daemon [-46hv ]
[--address =bindaddr]
[--bwlimit =bwlimit]
[--config =configfile]
[--no-detach ]
[--log-file =logfile]
[--port =service]
[--sockopts =sockopts] |
The openrsync
utility synchronises files
in the destination directory with one or more
source files. Either the source
or the destination directory may be remote, but not
both. The arguments are as follows:
-4
,
--ipv4
openrsync
is configured to use an
--rsh
program named “ssh”, then it
will pass -4
to it.-6
,
--ipv6
-4
option,
openrsync
will pass -6
to
the --rsh
program if it is named
“ssh”.-a
,
--archive
-Dgloprt
.--address
=sourceaddr--append
--inplace
.-b
,
--backup
--backup-dir
directory--backup
flag,
openrsync
will store backups of files being
replaced in the designated backup directory on the receiving side. Can be
combined with the --suffix
flag to name the backup
files with a suffix. The default is to not append a suffix.
If specified as a relative path, the backup directory will be
contained within the copied tree, and may cause conflicts or be subject
to --delete
rules. It is advised to use an
absolute path outside of the copied tree, or a relative path such as
"../".
-B
,
--block-size
=BLOCKSIZE--blocking-io
--bwlimit
limit--max-size
definition of size.--cache
openrsync
sets F_NOCACHE
by default to limit memory growth. Setting this option will enabling
caching by not setting any flags.--no-cache
O_DIRECT
when reading and writing files to
avoid using the buffer cache. Setting this option can avoid filling the
cache with files that will not be read again, such as during a backup.
This is the default on macOS, where F_NOCACHE
is
used instead of O_DIRECT
.-c
,
--checksum
--checksum-seed
=NUMopenrsync
to
use time(3) as the checksum seed.--compare-dest
=directory--compare-dest
directories
may be provided. If directory is a relative path, it
is relative to the destination directory.--contimeout
=seconds--copy-dest
=directory--copy-dest
directories may be provided.
If directory is a relative path, it is relative to
the destination directory.-L
,
--copy-links
--copy-unsafe-links
-k
,
--copy-dirlinks
-C
,
--cvs-exclude
RCS | SCCS | CVS | CVS.adm |
RCSLOG | cvslog.* | tags | TAGS |
.make.state | .nse_depinfo | *~ | #* |
.#* | ,* | _$* | *$ |
*.old | *.bak | *.BAK | *.orig |
*.rej | .del-* | *.a | *.olb |
*.o | *.obj | *.so | *.exe |
*.Z | *.elc | *.ln | core |
.svn/ |
CVSIGNORE
environment variable.
The -C
flag also adds a
“dir-merge” CVS rule to include per-dir
.cvsignore files. All of these rules are
appended to the end of the filter list with the equivalent of specifying
-f
“-C”
-f
“:C”.
-D
--devices
--specials
.--del
,
--delete
-r
.--delay-updates
--delete-before
--delete
behavior
before the transfer begins. This is the default timing when--delete
--delete-during
,
--delete-delay
, and
--delete-after
.--delete-during
--delete
behavior as
the transfer happens, right before each directory to be transferred is
checked for updates. This option is mutually exclusive with
--delete-before
,
--delete-delay
, and
--delete-after
.--delete-delay
--delete
behavior
after the transfer happens, but collect the list to be deleted right
before each directory to be transferred is checked for updates. This
option is mutually exclusive with --delete-before
,
--delete-during
, and
--delete-after
.--delete-after
--delete
behavior
after the transfer has completed. This option is mutually exclusive with
--delete-before
,
--delete-during
, and
--delete-delay
.--delete-excluded
--delete
options, supplied
--exclude
patterns will not prevent a file from
being deleted.--exclude
pattern--exclude-from
=file-E
,
--executability
--perms
is also specified.-0
,
--from0
--exclude-from
,
--include-from
,
--files-from
, and any merged files specified in
--filter
rules. Does not affect
--cvs-exclude
.--files-from
=filespec--force
--delete
options are present.--ignore-errors
--delete
to delete files
despite I/O errors.-y
,
--fuzzy
Note that the use of the --delete
option might get rid of any potential fuzzy-matches, so either use
--delete-after
or specify some exclusions to
prevent this.
--ignore-existing
--ignore-non-existing
,
--existing
-I
,
--ignore-times
--include
pattern--include-from
=file--devices
-e
program,
--rsh
=programRSYNC_RSH
environment variable will be used if an -e
option
is not present. Note that openrsync
will generally
handle quotes, but it makes no attempt to deal with escape sequences. In
particular, escaped quotation marks will not be escaped.-F
-F
will add “:
/.rsync-filter” the first time it is seen, and “-
.rsync-filter” the second time it is seen. Subsequent uses have no
effect.-f
filter,
--filter
=filteropenrsync
filters.-g
,
--group
--numeric-ids
is also given or if the remote group
name is unknown on the local machine, set the numeric group ID to match
the source instead.-H
,
--hard-links
-h,
---human-readable
--help
-l
,
--links
--inplace
--keep-dirlinks
--link-dest
=directory--compare-dest
directories may be
provided. If directory is a relative path, it is
relative to the destination directory.--max-size
size--min-size
size--max-size
on the definition of
size.--modify-window
sec-n
,
--dry-run
-v
.--no-motd
--numeric-ids
-g
or -o
is
also given.-O
,
--omit-dir-times
--backup
without
--backup-dir
.-o
,
--owner
-g
. If --numeric-ids
is
also given or if the remote user name is unknown on the local machine, set
the numeric user ID to match the source instead. Only works if run as
root.-P
--partial
--progress
.-p
,
--perms
--partial
openrsync
is interrupted, which opens up the
possibility for them to be easily resumed later.--password-file
=pwfileopenrsync
is running as root.--port
=service-q
,
--quiet
--progress
-r
,
--recursive
--read-batch
=fileopenrsync
from file. See the
--write-batch
option for a description of a batch
file. When reading a batch file, the source
arguments are optional and ignored if specified.--remove-source-files
openrsync
will delete files as the transfer
progresses, but given its asynchronous nature there may be a noticeable
delay between a given file finishing its transfer and its subsequent
removal.
When combined with --delay-updates
,
files will be removed in a larger batch toward the end of the
transfer.
-R
,
--relative
--rsync-path
=program--size-only
--safe-links
--sockopts
=sockoptsSO_*
option
described in setsockopt(2). Note that only the following
options are currently supported:
SO_KEEPALIVE |
SO_REUSEADDR |
SO_SNDBUF |
SO_RCVBUF |
SO_SNDLOWAT |
SO_RCVLOWAT |
SO_SNDTIMEO |
SO_RCVTIMEO |
SO_REUSEPORT
May not be available on all systems. |
-S
,
--sparse
--specials
--suffix
suffix--backup-dir
where the default is an empty
string.--super
--owner
,
--group
, and --devices
options, which may be permitted to unprivileged users on the receiving end
in some configurations. --no-super
is also
supported to avoid them entirely.-T
,
--temp-dir
=directory--timeout
=seconds-t
,
--times
-u
,
--update
-v
,
--verbose
-x
,
--one-file-system
-V
,
--version
-W
,
--whole-file
--only-write-batch
=file--write-batch
option for a description
of a batch file.--write-batch
=file--read-batch
on the other side, the
transfer is simply replayed from the batch file against the application's
reeceiver, and the destination tree is updated accordingly.
Batch files are intended to reproduce an update to a destination tree to many other identical trees without needing to establish a direct connection between them. This mechanism also avoids having to perform many of the intermediate steps required for a transfer, such as receiver-side checksums and blocking.
A remote source or
directory has the syntax
host:path for connecting via
ssh(1), or
rsync
://host/path
or host::path for connecting to
a remote daemon. Subsequent to the first remote
source, the host may be dropped to become just
:path or ::path.
For connecting to a remote daemon with
rsync
://host or
host::path, the first path
component is interpreted as a "module":
host::module/path.
This only applies to the first source invocation;
subsequent to that, the module should not be specified.
By default, new destination files and directories are given the current time and the source file permissions. Updated files retain their existing permissions. It is an error if updated files have their file types change (e.g., updating a directory with a file).
At this time, source may only consist of
regular files, directories (only with -r
), or
symbolic links (only with -l
). The destination
directory must be a directory and is created if not
found.
openrsync
also supports a
--daemon
mode, which may be run either standalone or
may be invoked by, e.g., inetd(8) or similar services that
hand a socket off to an external program for handling.
Daemon options that are shared with the non-daemon mode of
openrsync
behave as described above. Options
specified to daemon mode are as follows:
--config
=configfileopenrsync
will look for its configuration at
/etc/rsyncd.conf. See
rsyncd.conf(5) for details of the format of this
file.--no-detach
openrsync
daemon in the foreground,
instead of the background.Note that the openrsync
daemon mode will
log to syslog(3) by default unless
--log-file
is specified, regardless of whether
--no-detach
has been specified to run in the
foreground or not.
The -f
, --include
,
--include-from
, --exclude
,
and --exclude-from
options may be used to load a
filter rule or a set of filter rules. A single filter rule consists of a
type, an optional set of
modifiers, and a pattern. Each
type has a short name and a long name. These will be
described in more depth shortly.
A filter file is a set of rules, one per line. Comments are accepted, starting with a ‘#’. Empty lines are ignored.
Each rule is of the following form:
<TYPE>[,<MODIFIERS>] <PATTERN>
If the short name is used, then the comma separating the modifiers from the rule type is optional. The delimiter between the type/modifiers and the pattern may also be an underbar instead of a space.
The following rule types are supported:
LONG NAME | SHORT NAME | DESCRIPTION |
exclude | - | Exclude a file from the transfer |
include | + | Include a file from the transfer |
merge | . | Merge rules in from a file |
dir-merge | : | Merge rules in from a per-directory file |
hide | H | Hide a file from the transfer |
show | S | “not hide a file from the transfer” |
protect | P | Protect a file from deletion |
risk | R | “not protect a file from deletion” |
clear | ! | Clear the current filter list |
The following rule modifiers are supported for the “exclude” and “include” rule types:
MODIFIER | DESCRIPTION |
/ | Match against the absolute pathname of the entry |
! | Take effect if the pattern does not match the entry |
C | Insert the global CVS exclusions |
s | Marks a rule as sender-side only |
r | Marks a rule as receiver-side only |
p | Marks a rule as perishable (do not prevent removal of a directory) |
The above modifiers will be ignored if applied to other rule types, with the exception of “merge” and “dir-merge” rules. See the Merge Rules section for more details of the semantics.
The six basic types of include and exclude rules briefly described above are “exclude”, “include”, “hide”, “show”, “protect”, “risk”.
The “hide” and “show” types are sender-side versions of the “exclude” and “include” rules, while the “protect” and “risk” types are their receiver-side equivalents.
Each of these rules take a pattern that is typically matched against the basename of a transfer candidate's name. A trailing ‘/’ in the pattern indicates that the entry should only match a directory name, while a leading ‘/’ indicates that the pattern is anchored to the beginning of the transfer path. The beginning of the transfer path is either the root of the transfer, or the directory containing a dir-merge file if the rule in question comes from a dir-merge file. A ‘/’ at any other position, or a “**” in the pattern, will match against the full path to the transfer entry beginning at the root of the transfer.
Patterns may contain any of the following wildcards.
WILDCARD | DESCRIPTION |
? | Matches any character, except ‘/’ |
* | Matches zero or more characters, except ‘/’ |
** | Matches zero or more characters |
[ | Character class, as in POSIX regular expressions |
/*** | Matches a directory and all of its contents |
Backslashes may be used to escape one of the above wildcard characters, but is ordinary when appearing before any other character.
Note that exclude rules with the “C” modifier applied do not take a pattern.
The merge rules, “merge” and
“dir-merge”, are another way to insert a filter rule file.
“merge” rules are evaluated once as soon as they are
processed, and the rules read in are inserted at the same position as the
merge file. “dir-merge” rules are evaluated as
openrsync
progresses through the file list,
searching each directory encountered for the file named in the rule's
pattern.
If a “dir-merge” rule appears before a “clear” rule, it will not be processed at all.
“dir-merge” rules are inserted into their own chain of rules, rather than directly into the global ruleset. “clear” rules appearing in a dir-merged file do not affect the global ruleset. As we find dir-merged files in the transfer, their rules are prepended to their dir-merge chain so that a deeper directory's rules take precedence over its parent's rules.
When one of the above exclude/include modifiers are applied to “merge” or “dir-merge” rule, those modifiers are applied to the exclude/include rules within the file. The following modifiers may additionally be specified for merge rules:
MODIFIER | DESCRIPTION |
- | All rules within are exclude rules |
+ | All rules within are include rules |
C | File processing should assume CVS-compatible parsing |
e | Exclude the file's name from the transfer |
n | Rules are not inherited by subdirectories |
w | Rules are word-split instead of line-split |
The CVS-compatible modifier implies the ‘-’, ‘n’ and ‘w’ modifiers. If a filename is not supplied with it, then “.cvsignore” is used.
The following environment variables affect execution of
openrsync
:
LOGNAME
LOGNAME
is not set, then
“nobody” will be used.USER
USER
is not set, then
LOGNAME
will be used.RSYNC_RSH
RSYNC_RSH
nor --rsh
are
specified.RSYNC_PASSWORD
--password-file
option is specified and passes the mode and owner check described above in
the option's description. On many systems, environment variables are
readable by other processes and should be considered insecure. Please
prefer a password file instead.The openrsync
utility exits 0 on success,
1 if an error occurs, or 2 if the remote protocol version is older than the
local protocol version.
A common invocation of openrsync
is for
archiving from a remote host to the local computer:
% openrsync -av --delete remote:rpath
/local/path
This will update the contents of /local/path/rpath with those on the remote server. Switching remote and local wil update the remote contents instead:
% openrsync -av --delete /local/path
remote:rpath
All examples use -t
so that destination
files inherit the source time. If not changed, subsequent invocations of
openrsync
will then consider the file up to date and
not transfer block hashes.
To update the out-of-date remote files host:dest/bar and host:dest/baz with the local ../src/bar and ../src/baz:
% openrsync -t ../src/bar ../src/baz
host:dest
To update the out-of-date local files bar and baz with the remote files host:src/bar and host:src/baz:
% openrsync -t host:src/bar :src/baz
.
To update the out-of-date local files ../dest/bar and ../dest/baz with bar and baz:
% openrsync -t bar baz
../dest
To update the out-of-date remote files in
host:dest on a remote host running
openrsync
with the local host running
rsync(1):
% rsync --rsync-path openrsync -t
../dest/* host:dest
openrsync
is compatible with rsync
protocol version 27 as supported by the samba.org implementation of
rsync.
The openrsync
utility has been available
since OpenBSD 6.5.
The openrsync
utility was written by
Kristaps Dzonsons
<kristaps@bsd.lv>.
June 10, 2024 | Mac OS X 14 |