1

I am trying to synchronise two different folders using rsync. I have copied all the data worth 4Tb from a network share to an external hdd using rsync -v -r /source /destination. Now I need to run regular backup to sync both the locations. Can anyone suggest rsync command which I can use to synchronise both the folders.

0

3 Answers 3

4

The best way is to continue to use rsync so as to maintain /destination synchronized with /source.

1st run:

rsync -avE /source /destination

next runs:

rsync -avE /source /destination

The -a option = --archive == -rlptgoD.

The -E option means copy extended attributes and ACL, and is mandatory on HFS+ filesystems.

Warning: the standard version of rsync on OS X, version 2.6.9 (see rsync --version) still have problems with extended attributes. These problems will be shown thanks to the -v option.

A verification of the output of rsync is mandatory.

This version 2.6.9 is too old and causing too many problems.


I advise any user willing to maintain in sync directories between different Macs (or between a Mac and another Unix machine) to install rsync version 3.1.2.

Here is the method I use:

  1. install MacPorts: MacPorts home page

    • go to the Quickstart section, install Xcode
    • choose the right version to install (Mavericks, Yosemite or El Capitan)
  2. Upgrade your PATH so as to find the port command in it for example, I installed it in /local/bin and modified my PATH like this:

    PATH=/local/bin:${PATH}
    export PATH
    
  3. Install rsync 3.1.2:

    port install rsync
    

With this version of rsync, the right options to use will be:

rsync -avAX /source /destination

and if you read me thus far, you are pretty good enough now to read

man rsync

to get the light from the source.

0
1

June, 2022 Update

As @dan suggested in his answer, using the ancient 2.6.9 version of rsync is an exercise in frustration and confusion. If you use rsync on relatively modern versions of mac os, you will encounter issues with respect to preserving ACLs and Extended Attributes.

You can peruse the release history of rsync. You can review the changes for each release (currently ver 3.2.4 released April, 2022). You may also notice that version 2.6.9 (released 6 Nov 2006) was followed by version 3.0.0 on 1 Mar 2008. Ver 3.0.0 contained many significant changes, most notably:

  1. Enhancements for xattr & ACL options in support of OS X users, &
  2. Adoption of GPLv3.

Apple's decision to "freeze" rsync at 2.6.9 - just as these OS X enhancements were added seems to speak of their priorities. Apple will not abide GPLv3 even when it has substantial benefit for their customers.

Use rsync to preserve all macOS metadata

In the current version of rsync (ver 3.2.4), the following options have demonstrated their ability to accurately preserve extended attributes and ACLs across the backup-restore cycle:

% rsync -rlAXtgoD --fake-super /source/ /destination

Here's a summary of some useful options:

#  -r                   recursive; recurse into directories  
#  -l                   copy symlinks as symlinks  
#  --acls, -A           preserve ACLs (implies --perms, -p)  
#  --xattrs, -X         preserve extended attributes  
#  -t                   preserve modification times  
#  -g                   preserve group  
#  -o                   preserve owner  
#  -D                   preserve devices and special files  
#  -v                   increased verbosity; may be repeated  
#  -i                   itemize changes  
#  --fake-super         store/recover privileged attrs using xattrs (for ACLs & XATTRs)  
#  --dry-run            perform a trial run with no changes made

Debugging rsync:

rsync can create a mess if options are applied will-nilly. It's a very good idea to make a dry run, and review rsync's proposed changes before committing. rsync provides options that support that:

% rsync -rlAXtgoDivv --dry-run --fake-super /source/ /destination

The -ivv options are useful for debugging, providing a detailed accounting of the changes. Using ivv with --dry-run will reliably inform you of what's going to happen before it happens.

Addendum:

This GitHub "recipe" contains a couple of scripts and a procedure that may be useful for those who wish to verify that rsync has faithfully replicated all extended attributes and ACLs.

-2

Easiest way to update rsync on MacOS Mojave as described at the following link.

https://bayton.org/2018/07/how-to-update-rsync-on-mac-os-high-sierra/

  1. Open the terminal and paste the command:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Now you are ready to install the new Rsync version, and can do so as follows:

    brew install rsync
  3. Once completed, you should sign out and back in to MacOS.

When entering the command below, you will see now that you are using rsync 3.1.3 (at time of writing), instead of rsync 2.6.9. You are no longer running a 12 year old version of Rsync!

<pre>rsync --version
rsync  version 3.1.3  protocol version 31</pre>

As simple as that.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .