Acrosync for Mac is a new rsync client for OS X with an easy-to-use GUI and Dropbox-like automatic upload. It can be also be configured to create hourly incremental network backups similar to Time Machine, but without the need to install server software. I am quite unsure with all options of rsync. Here my backup configuration: I am on Mac X (10.8) and want an exact copy of my HD to an external HD. I formatted the new USB drive with Mac OS extended (Journaled, Encrypted) and made in my shell the following command and got the following errors. RSYNCRSH The RSYNCRSH environment variable allows you to override the default shell used as the transport for rsync. This can be used instead of the -e option. RSYNCPROXY The RSYNCPROXY environment variable allows you to redirect your rsync client to use a web proxy when connecting to a rsync.
One of the most versatile utilities developed is rsync, however; learning to effectively use the application can be a daunting task. Rsync is useful for conducting backups to remote file servers or even mirroring a local drive to a removable one. It supports transferring files over ssh as well as it’s own protocol. Unfortunately, to use the built in rsync protocol you need to set up an rsync server, which on a Mac can be quite tricky.
On the one hand, you can simply type rsync —daemon and it will start a rsync daemon running on TCP port 873. But without the appropriate rsyncd.conf things can get a little messy. In addition, if you reboot the ‘server’ the process will not restart automatically. The worst thing is to have a system that has been operational for several months suddenly stop because someone rebooted the hardware and no one remembered that the process needed to be relaunched. Personally, I think it is much better to have the system offer some more resiliency by automating this process.
On the Mac, unfortunately inetd is no longer a viable option, thus you need to use launchd and launchdctl to load your XML described process file. So, I created the following plist (property list) file that I installed as root into /Library/LaunchDaemon.
You should also note that although I could have used the default 2.6.9 version of rsync that ships with most Macs, I have actually upgraded mine to 3.0.8 using the MacPorts.org system. In addition, I have created this plist to look for the rsyncd.conf in /usr/local/etc/rsyncd, because it is a more unified best practice way of doing things. Besides, like Mac OS X I am a fan of FreeBSD and it’s just the way I roll. The following is an example of a rsyncd.conf file that I have used in the past:
Once I have completed the basic setup it’s time to launch the daemon. To do this we need to use launchdctl to load the plist into the lauchd registry. I find it is easiest to use pushed to temporarily move to /Library/LaunchDaemons and run the command locally as follows;
At this point we have told the Mac (in my case a Snow Leopard Server) to make this service available. If you were to perform a ps ax | grep rsync you would likely not see anything. Once you make a connection attempt on the appropriate TCP port 873 launchd will setup the daemon. On my laptop at the command prompt I enter the appropriate command that will make the connection to the rsync service.
This above command will connect to the rsync daemon, which is a geeky way of saying service causing launchd on the remote server to instantiate a copy of rsyncd to launch and run answering the request. It does this on the fly in order to save system resources. Honestly there isn’t much reason to keep rsyncd around running just in case someone makes the call and supplies the correct credentials. You don’t keep your car running just in case you might decide to hop in and run up to 7 Eleven for a burrito and cup of Brazilian Bold do you? No, because that would be a gross waste of resources! On the server side when we make the call it answers with the following;
As soon as the connection to rsync has completed it’s transaction the daemon will end it’s run allowing those cycles and ram to return to the pool of resources that the server needs to use for doing other things like serving Minecraft or WordPress web sites. The following is an example of what it looks like from the client perspective,which in geek speak is basically a way of saying what happened on my laptop;
As you can see I am running rsync on my laptop with the –stats option which yields this handy output of what transpired during the session. After issuing the rsync command it prompts me for my password on the rsync server for that resource, which rsync calls a module. Assuming that I am listed in the module definition in rsyncd.conf as an auth user and enter the correct password noted in the appropriate “secrets” file then rsyncd will send the appropriate data to rsync on my laptop.
I understand all of this client server protocol negotiation may sound like “Blah blah blah blah” or one of the adults from a Peanuts comic because it’s definitely geek speak. Just keep the basics in mind; If you run rsync on your side of the connection to call rsyncd on the other end. This means that you are the client and the destination is the server. Of course this gets very muddy when you start talking about the X Windowing System but we shall save that for another day.
In summary rsync is an extremely useful service to have in your utility belt. I have used rsync to copy huge amounts of data to sites all over the world. When I was working on a project that required deliverables in Malaysia, China and Turkey from the US I used rsync to transport the data. The main reason I chose rsync is it’s ability to be automated and of course if you are using the rsync protocol you can not forget the ability resume a transfer if something breaks.
I hope this article helps you understand the power of rsync and sheds some insight into it’s uses. Please leave a comment on how you use rsync.
Related articles
- Advanced Mac OS X Shell Scripting (jafdip.com)
- How To rsync Server Setup for Centos (vijaynayani.wordpress.com)
- Performing MacPorts Magick (jafdip.com)
Remote file copy (Synchronize file trees)
Quick basic example: backup the desktop to the mybackups folder on an external hard drive:
Options
Additional details about the options above can be found on the rsync options and Exit Values page.
In many cases the Source and Destination will be a directory path, however either the Source or the Destination can be on a remote host:
Description
rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file already exists.
The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network link, using an efficient checksum-search algorithm described in the technical report that accompanies this package.
The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network link, using an efficient checksum-search algorithm described in the technical report that accompanies this package.
Some of the additional features of rsync are:
# support for copying links, devices, owners, groups and permissions
# exclude and exclude-from options are similar to GNU tar
# a CVS exclude mode for ignoring the same files that CVS would ignore
# can use any transparent remote shell, including rsh or ssh
# does not require root privileges
# pipelining of file transfers to minimize latency costs
# support for anonymous or authenticated rsync servers (ideal for mirroring)
# support for copying links, devices, owners, groups and permissions
# exclude and exclude-from options are similar to GNU tar
# a CVS exclude mode for ignoring the same files that CVS would ignore
# can use any transparent remote shell, including rsh or ssh
# does not require root privileges
# pipelining of file transfers to minimize latency costs
# support for anonymous or authenticated rsync servers (ideal for mirroring)
General
There are six different ways of using rsync. They are:
# for copying local files. This is invoked when neither source nor destination path contains a : separator
# for copying from the local machine to a remote machine using a remote shell program as the transport (such as rsh or ssh).
This is invoked when the destination path contains a single : separator.
# for copying from a remote machine to the local machine using a remote shell program. This is invoked when the source contains a : separator.
# for copying from a remote rsync server to the local machine. This is invoked when the source path contains a :: separator or a rsync:// URL.
# for copying from the local machine to a remote rsync server. This is invoked when the destination path contains a :: separator.
# for listing files on a remote machine. This is done the same way as rsync transfers except that you leave off the local destination.
Note that in all cases (other than listing) at least one of the source and destination paths must be local.
# for copying local files. This is invoked when neither source nor destination path contains a : separator
# for copying from the local machine to a remote machine using a remote shell program as the transport (such as rsh or ssh).
This is invoked when the destination path contains a single : separator.
# for copying from a remote machine to the local machine using a remote shell program. This is invoked when the source contains a : separator.
# for copying from a remote rsync server to the local machine. This is invoked when the source path contains a :: separator or a rsync:// URL.
# for copying from the local machine to a remote rsync server. This is invoked when the destination path contains a :: separator.
# for listing files on a remote machine. This is done the same way as rsync transfers except that you leave off the local destination.
Note that in all cases (other than listing) at least one of the source and destination paths must be local.
Usage
You use rsync in the same way you use rcp. You must specify a source and a destination, one of which can be remote.
Perhaps the best way to explain the syntax is some examples:
Perhaps the best way to explain the syntax is some examples:
This would transfer all files matching the pattern *.c from the current directory to the directory Source on the machine foo.
If any of the files already exist on the remote system then the rsync remote-update protocol is used to update the file by sending only the differences.
See the tech report for details.
If any of the files already exist on the remote system then the rsync remote-update protocol is used to update the file by sending only the differences.
See the tech report for details.
this would recursively transfer all files from the directory Source/bar on the machine foo into the /data/tmp/bar directory on the local machine.
The files are transferred in 'archive' mode, which ensures that symbolic links, devices, attributes, permissions, ownerships etc are preserved in the transfer. Additionally, compression will be used to reduce the size of data portions of the transfer.
The files are transferred in 'archive' mode, which ensures that symbolic links, devices, attributes, permissions, ownerships etc are preserved in the transfer. Additionally, compression will be used to reduce the size of data portions of the transfer.
a trailing slash on the source changes this behavior to transfer all files from the directory Source/bar on the machine foo into the /data/tmp/.
A trailing / on a source name means 'copy the contents of this directory'. Without a trailing slash it means 'copy the directory'.
This difference becomes particularly important when using the --delete option.
You can also use rsync in local-only mode, where both the source and destination don't have a ':' in the name. In this case it behaves like an improved copy command.
A trailing / on a source name means 'copy the contents of this directory'. Without a trailing slash it means 'copy the directory'.
This difference becomes particularly important when using the --delete option.
You can also use rsync in local-only mode, where both the source and destination don't have a ':' in the name. In this case it behaves like an improved copy command.
this would list all the anonymous rsync modules available on the host somehost.mydomain.com. (See the following section for more details.)
Connecting to an Rsync Server
It is also possible to use rsync without using rsh or ssh as the transport. In this case you will connect to a remote rsync server running on TCP port 873.
You can establish the connection via a web proxy by setting the environment variable RSYNC_PROXY to a hostname:port pair pointing to your web proxy. Note that your web proxy's configuration must allow proxying to port 873.
Using rsync in this way is the same as using it with rsh or ssh except that:
You can establish the connection via a web proxy by setting the environment variable RSYNC_PROXY to a hostname:port pair pointing to your web proxy. Note that your web proxy's configuration must allow proxying to port 873.
Using rsync in this way is the same as using it with rsh or ssh except that:
- you use a double colon :: instead of a single colon to separate the hostname from the path.
- the remote server might print a message of the day when you connect.
- if you specify no path name on the remote server then the list of accessible paths on the server will be shown.
- if you specify no local destination then a listing of the specified files on the remote server is provided.
Some paths on the remote server will require authentication. If so then you will receive a password prompt when you connect.
You can avoid the password prompt by setting the environment variable RSYNC_PASSWORD to the password you want to use or using the --password-file option. This may be useful when scripting rsync.
WARNING: On some systems environment variables are visible to all users. On those systems using --password-file is recommended.
You can avoid the password prompt by setting the environment variable RSYNC_PASSWORD to the password you want to use or using the --password-file option. This may be useful when scripting rsync.
WARNING: On some systems environment variables are visible to all users. On those systems using --password-file is recommended.
Running an Rsync Server
An rsync server is configured using a config file which by default is
called /etc/rsyncd.conf. Please see the rsyncd.conf(5) man page for more information.
called /etc/rsyncd.conf. Please see the rsyncd.conf(5) man page for more information.
Examples
To Backup the home directory using a cron job:
To Backup the home directory using a cron job:
Run the above over a PPP link to a duplicate directory on machine 'server64'.
To synchronize samba source trees use the following Makefile targets:
To synchronize samba source trees use the following Makefile targets:
this allows me to sync with a CVS directory at the other end of the link. I then do cvs operations on the remote machine, which saves a lot of time
as the remote cvs protocol isn't very efficient.
I mirror a directory between my 'old' and 'new' ftp sites with the command
as the remote cvs protocol isn't very efficient.
I mirror a directory between my 'old' and 'new' ftp sites with the command
this is launched from cron every few hours.
Exclude Patterns
The exclude and include patterns specified to rsync allow for flexible selection of which files to transfer and which files to skip.
rsync builds an ordered list of include/exclude options as specified on the command line. When a filename is encountered, rsync checks the name against each exclude/include pattern in turn. The first matching pattern is acted on.
If it is an exclude pattern, then that file is skipped.
If it is an include pattern then that filename is not skipped.
If no matching include/exclude pattern is found then the filename is not skipped.
Note that when used with -r (which is implied by -a), every subcomponent of every path is visited from top down, so include/exclude patterns get applied
recursively to each subcomponent.
Note also that the --include and --exclude options take one pattern each. To add multiple patterns use the --include-from and --exclude-from options
or multiple --include and --exclude options.
The patterns can take several forms. The rules are:
rsync builds an ordered list of include/exclude options as specified on the command line. When a filename is encountered, rsync checks the name against each exclude/include pattern in turn. The first matching pattern is acted on.
If it is an exclude pattern, then that file is skipped.
If it is an include pattern then that filename is not skipped.
If no matching include/exclude pattern is found then the filename is not skipped.
Note that when used with -r (which is implied by -a), every subcomponent of every path is visited from top down, so include/exclude patterns get applied
recursively to each subcomponent.
Note also that the --include and --exclude options take one pattern each. To add multiple patterns use the --include-from and --exclude-from options
or multiple --include and --exclude options.
The patterns can take several forms. The rules are:
- if the pattern starts with a / then it is matched against the start of the filename, otherwise it is matched against the end of the filename. Thus '/foo' would match a file called 'foo' at the base of the tree. On the other hand, 'foo' would match any file called 'foo' anywhere in the tree
because the algorithm is applied recursively from top down; it behaves as if each path component gets a turn at being the end of the file name. - if the pattern ends with a / then it will only match a directory, not a file, link or device.
- if the pattern contains a wildcard character from the set *?[ then expression matching is applied using the shell filename matching rules. Otherwise a simple string match is used.
- if the pattern includes a double asterisk '**' then all wildcards in the pattern will match slashes, otherwise they will stop at slashes.
- if the pattern contains a / (not counting a trailing /) then it is matched against the full filename, including any leading directory.
If the pattern doesn't contain a / then it is matched only against the final component of the filename. Again, remember that the algorithm is applied recursively so 'full filename' can actually be any portion of a path. - if the pattern starts with '+ ' (a plus followed by a space) then it is always considered an include pattern, even if specified as part of an exclude option.
The '+ ' part is discarded before matching. - if the pattern starts with '- ' (a minus followed by a space) then it is always considered an exclude pattern, even if specified as part of an include option. The '- ' part is discarded before matching.
- if the pattern is a single exclamation mark ! then the current include/exclude list is reset, removing all previously defined patterns.
The +/- rules are most useful in exclude lists, allowing you to have a single exclude list that contains both include and exclude options.
If you end an exclude list with --exclude '*', note that since the algorithm is applied recursively that unless you explicitly include parent directories of files
you want to include then the algorithm will stop at the parent directories and never see the files below them.
To include all directories, use --include '*/' before the --exclude '*'.
Here are some exclude/include examples:
# --exclude '*.o' would exclude all filenames matching *.o
# --exclude '/foo' would exclude a file in the base directory called foo
# --exclude 'foo/' would exclude any directory called foo.
# --exclude '/foo/*/bar' would exclude any file called bar two levels below a base directory called foo.
# --exclude '/foo/**/bar' would exclude any file called bar two or more levels below a base directory called foo.
# --include '*/' --include '*.c' --exclude '*' would include all directories and C source files
# --include 'foo/' --include 'foo/bar.c' --exclude '*'
would include only foo/bar.c (the foo/ directory must be explicitly included or it would be excluded by the '*')
If you end an exclude list with --exclude '*', note that since the algorithm is applied recursively that unless you explicitly include parent directories of files
you want to include then the algorithm will stop at the parent directories and never see the files below them.
To include all directories, use --include '*/' before the --exclude '*'.
Here are some exclude/include examples:
# --exclude '*.o' would exclude all filenames matching *.o
# --exclude '/foo' would exclude a file in the base directory called foo
# --exclude 'foo/' would exclude any directory called foo.
# --exclude '/foo/*/bar' would exclude any file called bar two levels below a base directory called foo.
# --exclude '/foo/**/bar' would exclude any file called bar two or more levels below a base directory called foo.
# --include '*/' --include '*.c' --exclude '*' would include all directories and C source files
# --include 'foo/' --include 'foo/bar.c' --exclude '*'
would include only foo/bar.c (the foo/ directory must be explicitly included or it would be excluded by the '*')
Batch Mode
The following call generates 4 files that encapsulate the information for synchronizing the contents of target_dir with the updates found in Source_dir
$ rsync -F [other rsync options here] /somewhere/Source_dir /somewhere/target_dir
The generated files are labeled with a common timestamp:
# rsync_argvs. command-line arguments
# rsync_flist. rsync internal file metadata
# rsync_csums. rsync checksums
# rsync_delta. data blocks for file update & change
$ rsync -F [other rsync options here] /somewhere/Source_dir /somewhere/target_dir
The generated files are labeled with a common timestamp:
# rsync_argvs.
# rsync_flist.
# rsync_csums.
# rsync_delta.
Symbolic Links
Rsync For Mac
Three basic behaviours are possible when rsync encounters a symbolic link in the source directory.
By default, symbolic links are not transferred at all. A message 'skipping non-regular' file is emitted for any symlinks that exist.
If --links is specified, then symlinks are recreated with the same target on the destination. Note that --archive implies --links.
If --copy-links is specified, then symlinks are 'collapsed' by copying their referent, rather than the symlink.
rsync also distinguishes 'safe' and 'unsafe' symbolic links.
An example where this might be used is a web site mirror that wishes ensure the rsync module they copy does not include symbolic links to /etc/passwd in the public section of the site. Using --copy-unsafe-links will cause any links to be copied as the file they point to on the destination.
Using --safe-links will cause unsafe links to be ommitted altogether.
By default, symbolic links are not transferred at all. A message 'skipping non-regular' file is emitted for any symlinks that exist.
If --links is specified, then symlinks are recreated with the same target on the destination. Note that --archive implies --links.
If --copy-links is specified, then symlinks are 'collapsed' by copying their referent, rather than the symlink.
rsync also distinguishes 'safe' and 'unsafe' symbolic links.
An example where this might be used is a web site mirror that wishes ensure the rsync module they copy does not include symbolic links to /etc/passwd in the public section of the site. Using --copy-unsafe-links will cause any links to be copied as the file they point to on the destination.
Using --safe-links will cause unsafe links to be ommitted altogether.
Diagnostics
rsync occasionally produces error messages that may seem a little cryptic.
The one that seems to cause the most confusion is 'protocol version mismatch - is your shell clean?'.
This message is usually caused by your startup scripts or remote shell facility producing unwanted garbage on the stream that rsync is using for its transport. The way to diagnose this problem is to run your remote shell like this:
The one that seems to cause the most confusion is 'protocol version mismatch - is your shell clean?'.
This message is usually caused by your startup scripts or remote shell facility producing unwanted garbage on the stream that rsync is using for its transport. The way to diagnose this problem is to run your remote shell like this:
Then look at out.dat. If everything is working correctly then out.dat should be a zero length file. If you are getting the above error from rsync then you will
probably find that out.dat contains some text or data. Look at the contents and try to work out what is producing it.
The most common cause is incorrectly configured shell startup scripts (such as .cshrc or .profile) that contain output statements for non-interactive logins.
If you are having trouble debugging include and exclude patterns, then try specifying the -vv option. At this level of verbosity rsync will show why each individual file is included or excluded.
probably find that out.dat contains some text or data. Look at the contents and try to work out what is producing it.
The most common cause is incorrectly configured shell startup scripts (such as .cshrc or .profile) that contain output statements for non-interactive logins.
If you are having trouble debugging include and exclude patterns, then try specifying the -vv option. At this level of verbosity rsync will show why each individual file is included or excluded.
Setup
See the file README for installation instructions.
Once installed you can use rsync to any machine that you can use rsh to. rsync uses rsh for its communications, unless both the source and destination are local.
You can also specify an alternative to rsh, either by using the -e command line option, or by setting the RSYNC_RSH environment variable.
One common substitute is to use ssh, which offers a high degree of security. Note that rsync must be installed on both the source and destination machines.
Once installed you can use rsync to any machine that you can use rsh to. rsync uses rsh for its communications, unless both the source and destination are local.
You can also specify an alternative to rsh, either by using the -e command line option, or by setting the RSYNC_RSH environment variable.
One common substitute is to use ssh, which offers a high degree of security. Note that rsync must be installed on both the source and destination machines.
Environment Variables
FILES
“I was the only kid in the audience who didn’t understand why Dorothy would ever want to go home. It was a mystery to me. To that awful black and white farm, with that aunt who was dressed badly, with smelly farm animals around. When she could live with winged monkeys and magic shoes and gay lions. I didn’t get it” ~ John Waters
Related macOS commands:
Update Rsync Mac Os X
rsync.samba.org - Download latest version (plus docs).
cp - Copy files.
install - Copy files and set attributes.
rcp - Remote file copy.
rsnapshot - Save multiple backups with rsync.
Grsync - GUI for rsync.
youtube-dl - Download video.
wikipedia entry for rsync
cp - Copy files.
install - Copy files and set attributes.
rcp - Remote file copy.
rsnapshot - Save multiple backups with rsync.
Grsync - GUI for rsync.
youtube-dl - Download video.
wikipedia entry for rsync
Rsync For Windows Download
Copyright © 1999-2020 SS64.com
Some rights reserved
Some rights reserved